Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3518697imu; Mon, 7 Jan 2019 05:00:27 -0800 (PST) X-Google-Smtp-Source: ALg8bN78YbVQD8ql0+xx6uqeMVYvxirqIs4EkRlTJS5utihWWqN5eMgnDiqCHaKGMG0WWNwZSrwe X-Received: by 2002:a63:f74f:: with SMTP id f15mr29994627pgk.190.1546866027800; Mon, 07 Jan 2019 05:00:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546866027; cv=none; d=google.com; s=arc-20160816; b=IsV3MBYRBM5oOSO4qnDOyxKv1zgbHdsQotaue9WEM95LLkUgWWgMOmqlt/y3UiS2v2 +UIRPEDSChOBeuV73Wg0itBKWCLWjNvtyxKTMue4Da8vODIKqIOkzZCw6AF2OezGm/wg 5HPbsFy0x324tbUxy6xQ8dN0mQW2Nh1uNZa+P98yyAVARHb/ng10BDHC9C08ebmZKA2F HnoIhRpuYiM9omGnx3yuJwQJAFp9dUF4wF2swF0JG9auJoqDrVg4TkO3RxTIQY7Z4tOJ iIVz2Yg7xORfmadlq6akMwMAiVsOAaDtepgBgSJdviyrgQxx8wfzfzHPysk35VAFkmNQ kOgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8veIMWS+ZGbQAsuLxoHN5lUmIyHAV9/9/s6iei7LZeo=; b=isHt6/H7m1rH2tIkVoxdx5c0CEII8SXT2dMz+5I09pb1NBIG+cxB3o8qF46r62g7Gf 2dsAHd/w/L0Xi40Wv41EhPTa9ge+TmBohAF8PRMOY26iMFeuP4Gqql/rJtdM6wVOm+73 CPTJpR3qXUM5wxzrgSah0BAfqxdszQou87abYkFYtVKJzBl6zuVOJKZef0bw2OoTqYBI LprwSZ6hpMR8Os/uKVIUyfnV23C7EPZA5IcMCkBpeSaYFkxEoMfPG8v07AbwpRNpL7Ng U8fuwNB6pOGS5LjSaqQSVVlsk52kGoQcG5FZ9B2eYHyzgmJtAvFDQs1BTMoBkQJmoUnz LJ7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=A01p7wul; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n4si7287120pgv.512.2019.01.07.05.00.12; Mon, 07 Jan 2019 05:00:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=A01p7wul; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729759AbfAGM5B (ORCPT + 99 others); Mon, 7 Jan 2019 07:57:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:44796 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728459AbfAGM5A (ORCPT ); Mon, 7 Jan 2019 07:57:00 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B3FE520651; Mon, 7 Jan 2019 12:56:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1546865818; bh=kPXaZzCDmz1vdwM226Ossvk5DbaR74xUSKEcjkMgLog=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A01p7wulDHazzHWTtxD5fdvZ6a3R+pRSC/S5oJUmIKTOhGaskhL6f2md1OAzCy24Y 5pLJLAORLxoI9eIo3E2Q/gld/GPK1oj9poNgGIcD0GYq47JGdsJutalP58uMxR0r23 DjiiI8fAARU2BpAwz0HVEzFAcecqYuRteRLjP3lM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ben Hutchings , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Peter Zijlstra , Arnaldo Carvalho de Melo Subject: [PATCH 4.19 103/170] perf pmu: Suppress potential format-truncation warning Date: Mon, 7 Jan 2019 13:32:10 +0100 Message-Id: <20190107104505.139407002@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190107104452.953560660@linuxfoundation.org> References: <20190107104452.953560660@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ben Hutchings commit 11a64a05dc649815670b1be9fe63d205cb076401 upstream. Depending on which functions are inlined in util/pmu.c, the snprintf() calls in perf_pmu__parse_{scale,unit,per_pkg,snapshot}() might trigger a warning: util/pmu.c: In function 'pmu_aliases': util/pmu.c:178:31: error: '%s' directive output may be truncated writing up to 255 bytes into a region of size between 0 and 4095 [-Werror=format-truncation=] snprintf(path, PATH_MAX, "%s/%s.unit", dir, name); ^~ I found this when trying to build perf from Linux 3.16 with gcc 8. However I can reproduce the problem in mainline if I force __perf_pmu__new_alias() to be inlined. Suppress this by using scnprintf() as has been done elsewhere in perf. Signed-off-by: Ben Hutchings Cc: Alexander Shishkin Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Cc: stable@vger.kernel.org Link: http://lkml.kernel.org/r/20181111184524.fux4taownc6ndbx6@decadent.org.uk Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Greg Kroah-Hartman --- tools/perf/util/pmu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -145,7 +145,7 @@ static int perf_pmu__parse_scale(struct int fd, ret = -1; char path[PATH_MAX]; - snprintf(path, PATH_MAX, "%s/%s.scale", dir, name); + scnprintf(path, PATH_MAX, "%s/%s.scale", dir, name); fd = open(path, O_RDONLY); if (fd == -1) @@ -175,7 +175,7 @@ static int perf_pmu__parse_unit(struct p ssize_t sret; int fd; - snprintf(path, PATH_MAX, "%s/%s.unit", dir, name); + scnprintf(path, PATH_MAX, "%s/%s.unit", dir, name); fd = open(path, O_RDONLY); if (fd == -1) @@ -205,7 +205,7 @@ perf_pmu__parse_per_pkg(struct perf_pmu_ char path[PATH_MAX]; int fd; - snprintf(path, PATH_MAX, "%s/%s.per-pkg", dir, name); + scnprintf(path, PATH_MAX, "%s/%s.per-pkg", dir, name); fd = open(path, O_RDONLY); if (fd == -1) @@ -223,7 +223,7 @@ static int perf_pmu__parse_snapshot(stru char path[PATH_MAX]; int fd; - snprintf(path, PATH_MAX, "%s/%s.snapshot", dir, name); + scnprintf(path, PATH_MAX, "%s/%s.snapshot", dir, name); fd = open(path, O_RDONLY); if (fd == -1)