Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1412548yba; Tue, 2 Apr 2019 08:24:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqxWrNCzVkHnOkKLVNaiYj+5GxbkJWfRdCHpO/mLCRlFIfYhm0xhRDak75ucKRfIKbxWHANt X-Received: by 2002:a17:902:e091:: with SMTP id cb17mr47385116plb.222.1554218653232; Tue, 02 Apr 2019 08:24:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554218653; cv=none; d=google.com; s=arc-20160816; b=mwpQmfH3QxAnum7620Rl0Nn+/ZY6HTgLeVKMBjKEsQC1IYicNXHFVh9sg+Cb3e6Zey 1JssTmaC9fKmhBY+ER+tG1avcQjPVQjEezTwADj0eG+GCPECoR0npRid3sggMkeDh/Gl Uzgj15dhilP9dY3giLaOMw0vwzlHLRVNGPCHLSt4+NgjkB7KvEim2L/mPNblPAfmut0n HtJiBr9lb0w5yQMOYrD1uXJD9PDDN7Dasr02ABVVC39PKHKZmUNcnBx91JZSdPrXkv9N D7jNvdruq8ODgR9/Z3bvqH9ncJCjMQxa/mMD6xkTxMeRM/78iDrPKQgY88bQEo3rJwOD +3Og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=1ZNyUlx8QnZ9bwLYB57DgJLMKoWQcq3XJN+7kfFqBRM=; b=Gmb1xySfqeGyB4kfHekEttYJ3dKWUNSulHwvg/kgutcqno++l6kMKRf5AFI1Jis6+o +Lbdqlub3TLYk5z0NZwwsZO26knqqggTfmVzjpu4NZJEQ1hmTEGVmlwiU0qK9In9BiJz pfNJNUW/Oj1khyvud5iGD7Lng0C+amOC/BgtU8fmjQIAx7/kzfLfZ0PHqFpz+hHJ6/sR n0kATzJPXINusjFZ2Aahq34TdAP2FEpMesfJ+SgXzeGA85HWmxcODEdqBlUXbXRndvYc hB/D/nuNzpauOhvcCqNxMJWY13JDVg6mVgr2bOjESRFMMx7X4uQDU05qxuxWo6hXWD99 STfQ== ARC-Authentication-Results: i=1; mx.google.com; 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 x17si11313636pgj.195.2019.04.02.08.23.57; Tue, 02 Apr 2019 08:24:13 -0700 (PDT) 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; 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 S1731939AbfDBNng (ORCPT + 99 others); Tue, 2 Apr 2019 09:43:36 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:43620 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731513AbfDBNkL (ORCPT ); Tue, 2 Apr 2019 09:40:11 -0400 Received: from [167.98.27.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hBJdu-0002mf-UK; Tue, 02 Apr 2019 14:39:59 +0100 Received: from ben by deadeye with local (Exim 4.92) (envelope-from ) id 1hBJdu-0004rU-15; Tue, 02 Apr 2019 14:39:58 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, Denis Kirjanov , "Peter Zijlstra" , "Alexander Shishkin" , "Namhyung Kim" , "Jiri Olsa" , "Arnaldo Carvalho de Melo" Date: Tue, 02 Apr 2019 14:38:27 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 13/99] perf pmu: Suppress potential format-truncation warning In-Reply-To: X-SA-Exim-Connect-IP: 167.98.27.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.65-rc1 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 Link: http://lkml.kernel.org/r/20181111184524.fux4taownc6ndbx6@decadent.org.uk Signed-off-by: Arnaldo Carvalho de Melo [bwh: Dropped the parts that don't apply to 3.16] Signed-off-by: Ben Hutchings --- 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 @@ -107,7 +107,7 @@ static int perf_pmu__parse_scale(struct char path[PATH_MAX]; const char *lc; - 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) @@ -150,7 +150,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)