Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3525129imu; Mon, 7 Jan 2019 05:05:35 -0800 (PST) X-Google-Smtp-Source: ALg8bN4FbAuWg/KHpOCtIg9ew3uzSsXW+3qsb7vMELrVAQDIq2evVYmfx5q3Y4ucG+8qgCPPmsgl X-Received: by 2002:a17:902:6b0c:: with SMTP id o12mr62124479plk.291.1546866335561; Mon, 07 Jan 2019 05:05:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546866335; cv=none; d=google.com; s=arc-20160816; b=inTJziACJNWcLkyBFKTx64BC6iGspsTTL7ZV4ufLTZkovKi78mYNJvl46gG/mYuady kQdt4MsLOt+HBWU9YYSbCUBChUqetR1+04rVBXH6DupzMOV2Rx63TAXnLjayV9DHJgEn Ee/2Y00mAkKQBNmjoNYXSLBLdMn4/cLkDU8g69mzcTTF3pfwIazq0DUbZGN3C1Meze9b inijK5RMWInkZjH5LqfgkqxO0SnackX5H5+1gJR/NkvSzgb+XXqpRTfr1VFnj1M5UzuJ 5exGK+fbDQ7DrlOeo7JrnF0qBkKfxz0ZwcjFjo4ey2yqMXk8suPOp00T52CUArv6xBDF KBCQ== 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=WUxm1/MQ3gEaz5Y4uZDHeoY1Lx5Mgoh8eyAATWrGBpc=; b=ROTRdJkP3yhbZZm7j+xR9PkmRNsr9Xle/0lfVyPRJ/tRs6xit2sGJkA8tTfaoMm1Tr hsHE+Nnl7jIZfAUDZc6PtePbGVnnPTAyd5bbfkYTJZlEJQv34M/Rp3Rxr6vfVUpx4JSJ KdCCeoBW6T+JBW41abdYo21hgv/h+GsHsXdxagCKMNlgHWFIhfdf0qzxfOUCqUOK9zT5 zY4viuq7zHKaixeLblPS8zQcb7gzHMjq6mN/tKUPeJh0z/YT5aqC4N8mRBO8WmaPPkHB NZI0hHbIcfgQXTRCG3xcf2Cxo9GTP94pu2ALHcsE+nFwVKP4qBQ0QW9PPATifpxW+Sn5 LdfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=AmRp028W; 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 e4si62090581pgk.127.2019.01.07.05.05.20; Mon, 07 Jan 2019 05:05:35 -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=AmRp028W; 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 S1730818AbfAGNCa (ORCPT + 99 others); Mon, 7 Jan 2019 08:02:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:49984 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730811AbfAGNC2 (ORCPT ); Mon, 7 Jan 2019 08:02:28 -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 0374D2089F; Mon, 7 Jan 2019 13:02:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1546866147; bh=kgsarsr2h+YQRZCoqgtivf61iyC+XWcGcAFITkZ9gr0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AmRp028WcSIrPSxMm3vM9Fl0to5LzXQMpJp0iEmWIRYnRdmNBMk7Hg+jnlFWngdLU irkqwGeOgeK8eSiHUL9P21lv7N8yyZNU285FAL9qui3vI5P4VU3y9B4E6/W5IPeRwC bgrEbdJ+dPdqErMm3kefqKYezgn6GkhDKV+sQ8ow= 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.14 061/101] perf pmu: Suppress potential format-truncation warning Date: Mon, 7 Jan 2019 13:32:49 +0100 Message-Id: <20190107105336.273307525@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190107105330.372621917@linuxfoundation.org> References: <20190107105330.372621917@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.14-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 @@ -143,7 +143,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) @@ -173,7 +173,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) @@ -203,7 +203,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) @@ -221,7 +221,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)