From: William Cohen <wcohen@redhat.com>
To: Anton Blanchard <anton@samba.org>,
Michael Ellerman <mpe@ellerman.id.au>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Paul Mackerras <paulus@samba.org>,
rric@kernel.org
Cc: oprofile-list@lists.sf.net, linuxppc-dev@lists.ozlabs.org,
Robert Richter <rric@kernel.org>
Subject: Re: gcc trunk fails to build kernel on PowerPC64 due to oprofile warnings
Date: Thu, 26 Jan 2017 10:46:43 -0500 [thread overview]
Message-ID: <fe2c2fd9-d255-61ca-5328-ca5d45827f47@redhat.com> (raw)
In-Reply-To: <20170126100044.7e439f72@kryten>
[-- Attachment #1: Type: text/plain, Size: 1721 bytes --]
On 01/25/2017 06:00 PM, Anton Blanchard wrote:
> Hi,
>
> gcc trunk has failed to build PowerPC64 kernels for a month or so. The issue
> is in oprofile, which is common code but ends up being sucked into
> arch/powerpc and therefore subject to the -Werror applied to arch/powerpc:
>
> linux/arch/powerpc/oprofile/../../../drivers/oprofile/oprofile_stats.c: In function ‘oprofile_create_stats_files’:
> linux/arch/powerpc/oprofile/../../../drivers/oprofile/oprofile_stats.c:55:25: error: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size 7 [-Werror=format-truncation=]
> snprintf(buf, 10, "cpu%d", i);
> ^~
> linux/arch/powerpc/oprofile/../../../drivers/oprofile/oprofile_stats.c:55:21: note: using the range [1, -2147483648] for directive argument
> snprintf(buf, 10, "cpu%d", i);
> ^~~~~~~
> linux/arch/powerpc/oprofile/../../../drivers/oprofile/oprofile_stats.c:55:3: note: format output between 5 and 15 bytes into a destination of size 10
> snprintf(buf, 10, "cpu%d", i);
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> LD crypto/async_tx/built-in.o
> CC lib/random32.o
> cc1: all warnings being treated as errors
>
> Anton
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> _______________________________________________
> oprofile-list mailing list
> oprofile-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/oprofile-list
>
The attached patch should make the buffer large enough to eliminate the warning.
-Will
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Avoid-hypthetical-string-truncation-in-oprofile-stat.patch --]
[-- Type: text/x-patch; name="0001-Avoid-hypthetical-string-truncation-in-oprofile-stat.patch", Size: 2347 bytes --]
>From 7e46dbd7dc5bc941926a4a63c28ccebf46493e8d Mon Sep 17 00:00:00 2001
From: William Cohen <wcohen@redhat.com>
Date: Thu, 26 Jan 2017 10:33:59 -0500
Subject: [PATCH] Avoid hypthetical string truncation in oprofile stats buffer
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Increased the size of an internal oprofile driver buffer ensuring that
the string was never truncated for any possible int value to avoid the
following gcc-7 compiler error on ppc when building the kernel:
linux/arch/powerpc/oprofile/../../../drivers/oprofile/oprofile_stats.c: In function ‘oprofile_create_stats_files’:
linux/arch/powerpc/oprofile/../../../drivers/oprofile/oprofile_stats.c:55:25: error: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size 7 [-Werror=format-truncation=]
snprintf(buf, 10, "cpu%d", i);
^~
linux/arch/powerpc/oprofile/../../../drivers/oprofile/oprofile_stats.c:55:21: note: using the range [1, -2147483648] for directive argument
snprintf(buf, 10, "cpu%d", i);
^~~~~~~
linux/arch/powerpc/oprofile/../../../drivers/oprofile/oprofile_stats.c:55:3: note: format output between 5 and 15 bytes into a destination of size 10
snprintf(buf, 10, "cpu%d", i);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
LD crypto/async_tx/built-in.o
CC lib/random32.o
cc1: all warnings being treated as errors
Signed-off-by: William Cohen <wcohen@redhat.com>
---
drivers/oprofile/oprofile_stats.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
index 59659ce..6fe7538 100644
--- a/drivers/oprofile/oprofile_stats.c
+++ b/drivers/oprofile/oprofile_stats.c
@@ -43,7 +43,7 @@ void oprofile_create_stats_files(struct dentry *root)
struct oprofile_cpu_buffer *cpu_buf;
struct dentry *cpudir;
struct dentry *dir;
- char buf[10];
+ char buf[16];
int i;
dir = oprofilefs_mkdir(root, "stats");
@@ -52,7 +52,7 @@ void oprofile_create_stats_files(struct dentry *root)
for_each_possible_cpu(i) {
cpu_buf = &per_cpu(op_cpu_buffer, i);
- snprintf(buf, 10, "cpu%d", i);
+ snprintf(buf, 16, "cpu%d", i);
cpudir = oprofilefs_mkdir(dir, buf);
/* Strictly speaking access to these ulongs is racy,
--
2.9.3
next prev parent reply other threads:[~2017-01-26 15:46 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-25 23:00 gcc trunk fails to build kernel on PowerPC64 due to oprofile warnings Anton Blanchard
2017-01-26 11:00 ` David Laight
2017-01-26 12:57 ` Arnd Bergmann
2017-01-26 15:46 ` William Cohen [this message]
2017-01-26 16:06 ` Robert Richter
2017-01-30 15:35 ` William Cohen
2017-02-02 17:21 ` William Cohen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fe2c2fd9-d255-61ca-5328-ca5d45827f47@redhat.com \
--to=wcohen@redhat.com \
--cc=anton@samba.org \
--cc=benh@kernel.crashing.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=oprofile-list@lists.sf.net \
--cc=paulus@samba.org \
--cc=rric@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).