All of lore.kernel.org
 help / color / mirror / Atom feed
* gcc trunk fails to build kernel on PowerPC64 due to oprofile warnings
@ 2017-01-25 23:00 Anton Blanchard
  2017-01-26 11:00 ` David Laight
  2017-01-26 15:46 ` William Cohen
  0 siblings, 2 replies; 7+ messages in thread
From: Anton Blanchard @ 2017-01-25 23:00 UTC (permalink / raw)
  To: Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras, rric
  Cc: linuxppc-dev, oprofile-list

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:
=20
linux/arch/powerpc/oprofile/../../../drivers/oprofile/oprofile_stats.c: In =
function =E2=80=98oprofile_create_stats_files=E2=80=99:
linux/arch/powerpc/oprofile/../../../drivers/oprofile/oprofile_stats.c:55:2=
5: error: =E2=80=98%d=E2=80=99 directive output may be truncated writing be=
tween 1 and 11 bytes into a region of size 7 [-Werror=3Dformat-truncation=
=3D]
   snprintf(buf, 10, "cpu%d", i);
                         ^~
linux/arch/powerpc/oprofile/../../../drivers/oprofile/oprofile_stats.c:55:2=
1: 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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: gcc trunk fails to build kernel on PowerPC64 due to oprofile warnings
  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
  1 sibling, 1 reply; 7+ messages in thread
From: David Laight @ 2017-01-26 11:00 UTC (permalink / raw)
  To: 'Anton Blanchard',
	Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras, rric
  Cc: oprofile-list, linuxppc-dev

RnJvbTogQW50b24gQmxhbmNoYXJkDQo+IFNlbnQ6IDI1IEphbnVhcnkgMjAxNyAyMzowMQ0KPiBn
Y2MgdHJ1bmsgaGFzIGZhaWxlZCB0byBidWlsZCBQb3dlclBDNjQga2VybmVscyBmb3IgYSBtb250
aCBvciBzby4gVGhlIGlzc3VlDQo+IGlzIGluIG9wcm9maWxlLCB3aGljaCBpcyBjb21tb24gY29k
ZSBidXQgZW5kcyB1cCBiZWluZyBzdWNrZWQgaW50bw0KPiBhcmNoL3Bvd2VycGMgYW5kIHRoZXJl
Zm9yZSBzdWJqZWN0IHRvIHRoZSAtV2Vycm9yIGFwcGxpZWQgdG8gYXJjaC9wb3dlcnBjOg0KLi4u
DQo+IGxpbnV4L2FyY2gvcG93ZXJwYy9vcHJvZmlsZS8uLi8uLi8uLi9kcml2ZXJzL29wcm9maWxl
L29wcm9maWxlX3N0YXRzLmM6NTU6MjU6IGVycm9yOiAlZCBkaXJlY3RpdmUNCj4gb3V0cHV0IG1h
eSBiZSB0cnVuY2F0ZWQgd3JpdGluZyBiZXR3ZWVuIDEgYW5kIDExIGJ5dGVzIGludG8gYSByZWdp
b24gb2Ygc2l6ZSA3IFstV2Vycm9yPWZvcm1hdC0NCj4gdHJ1bmNhdGlvbj1dDQo+ICAgIHNucHJp
bnRmKGJ1ZiwgMTAsICJjcHUlZCIsIGkpOw0KDQpGRlMgdGhlc2Ugd2FybmluZ3MgYXJlIGdldHRp
bmcgT1RULg0KVGhlIGNvbXBpbGVyIG5lZWRzIHRvIGJlIGFibGUgdG8gdHJhY2sgdGhlIGRvbWFp
biBvZiBpbnRlZ2VycyBiZWZvcmUgYXBwbHlpbmcNCnNvbWUgb2YgdGhlc2Ugd2FybmluZ3MuDQoN
CglEYXZpZA0KDQo=

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: gcc trunk fails to build kernel on PowerPC64 due to oprofile warnings
  2017-01-26 11:00 ` David Laight
@ 2017-01-26 12:57   ` Arnd Bergmann
  0 siblings, 0 replies; 7+ messages in thread
From: Arnd Bergmann @ 2017-01-26 12:57 UTC (permalink / raw)
  To: David Laight
  Cc: Anton Blanchard, Michael Ellerman, Benjamin Herrenschmidt,
	Paul Mackerras, rric, linuxppc-dev, oprofile-list,
	Linux Kernel Mailing List

On Thu, Jan 26, 2017 at 12:00 PM, David Laight <David.Laight@aculab.com> wrote:
> From: Anton Blanchard
>> Sent: 25 January 2017 23:01
>> 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: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);
>
> FFS these warnings are getting OTT.
> The compiler needs to be able to track the domain of integers before applying
> some of these warnings.

gcc-7 introduces lots of new warnings, some better than others. I'm
trying to categorize
both the new warnings and any others added in the recent years that we
may have missed
to see whether we want to turn them on by default or only in
scripts/Makefile.extrawarn
when building with W=1, W=2 or W=3.

I made a spreadsheet with the warnings that we have available in each version,
and also the number of unique output lines for that warning, see

https://docs.google.com/spreadsheets/d/1QemrLyvzrSDfm_MO3-_pwdfsTp2uqwjOdRBxxj6oo5M/edit?usp=sharing

For this specific warning, an ARM allmodconfig build shows 360
distinct warnings from a
total of 243 files. It's probably a good idea to look over them once
to see if anything sticks
out, but otherwise I think we change it to the W=2 level.

     Arnd

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: gcc trunk fails to build kernel on PowerPC64 due to oprofile warnings
  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 15:46 ` William Cohen
  2017-01-26 16:06   ` Robert Richter
  1 sibling, 1 reply; 7+ messages in thread
From: William Cohen @ 2017-01-26 15:46 UTC (permalink / raw)
  To: Anton Blanchard, Michael Ellerman, Benjamin Herrenschmidt,
	Paul Mackerras, rric
  Cc: oprofile-list, linuxppc-dev, Robert Richter

[-- 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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: gcc trunk fails to build kernel on PowerPC64 due to oprofile warnings
  2017-01-26 15:46 ` William Cohen
@ 2017-01-26 16:06   ` Robert Richter
  2017-01-30 15:35     ` William Cohen
  2017-02-02 17:21     ` William Cohen
  0 siblings, 2 replies; 7+ messages in thread
From: Robert Richter @ 2017-01-26 16:06 UTC (permalink / raw)
  To: William Cohen
  Cc: Anton Blanchard, Michael Ellerman, Benjamin Herrenschmidt,
	Paul Mackerras, oprofile-list, linuxppc-dev

On 26.01.17 10:46:43, William Cohen wrote:
> 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:

Please test gcc7 for other archs first. I don't think this is the only
change needed to avoid this warning in oprofile code.

Thanks,

-Robert

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: gcc trunk fails to build kernel on PowerPC64 due to oprofile warnings
  2017-01-26 16:06   ` Robert Richter
@ 2017-01-30 15:35     ` William Cohen
  2017-02-02 17:21     ` William Cohen
  1 sibling, 0 replies; 7+ messages in thread
From: William Cohen @ 2017-01-30 15:35 UTC (permalink / raw)
  To: Robert Richter
  Cc: Michael Ellerman, oprofile-list, Anton Blanchard,
	Benjamin Herrenschmidt, Paul Mackerras, linuxppc-dev

On 01/26/2017 11:06 AM, Robert Richter wrote:
> On 26.01.17 10:46:43, William Cohen wrote:
>> 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:
> 
> Please test gcc7 for other archs first. I don't think this is the only
> change needed to avoid this warning in oprofile code.
> 
> Thanks,
> 
> -Robert

Hi Robert,

It took me a little while to get a gcc-7 environment set up with Fedora Rawhide on x86_64.  I have a kernel building now with gcc-7 and will see what other issues pop up during the compile.

While watching the output of the build I see the gcc-7 error message about truncating output of snprintf output seems to occur for a number of other places besides the oprofile kernel code during the compile.

-Will

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: gcc trunk fails to build kernel on PowerPC64 due to oprofile warnings
  2017-01-26 16:06   ` Robert Richter
  2017-01-30 15:35     ` William Cohen
@ 2017-02-02 17:21     ` William Cohen
  1 sibling, 0 replies; 7+ messages in thread
From: William Cohen @ 2017-02-02 17:21 UTC (permalink / raw)
  To: Robert Richter
  Cc: Michael Ellerman, oprofile-list, Anton Blanchard,
	Benjamin Herrenschmidt, Paul Mackerras, linuxppc-dev

[-- Attachment #1: Type: text/plain, Size: 1432 bytes --]

On 01/26/2017 11:06 AM, Robert Richter wrote:
> On 26.01.17 10:46:43, William Cohen wrote:
>> 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:
> 
> Please test gcc7 for other archs first. I don't think this is the only
> change needed to avoid this warning in oprofile code.
> 
> Thanks,
> 
> -Robert
> 

Hi Robert,

I looked through the oprofile arch specific code for other snprintf uses with small character arrays and added those to the patch.  Attached is current patch to increase the size of the buffers to make sure that they will not be truncated.

OProfile since 1.0.0 has used the kernels perf infrastructure rather than the oprofile kernel driver.  OProfile 1.0 was released September 2014, over two years ago.  Would it make sense to deprecate and at some point remove the oprofile driver kernel from the kernel?  Recent Fedora distributions already have CONFIG_OPROFILE unset in the kernel configurations.

-Will


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Avoid-hypthetical-string-truncation-in-various-oprof.patch --]
[-- Type: text/x-patch; name="0001-Avoid-hypthetical-string-truncation-in-various-oprof.patch", Size: 5808 bytes --]

>From e5490da918186cbd42b8609da146946fbdadf0e5 Mon Sep 17 00:00:00 2001
From: William Cohen <wcohen@redhat.com>
Date: Thu, 2 Feb 2017 12:02:51 -0500
Subject: [PATCH] Avoid hypthetical string truncation in various oprofile
 buffers
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Increased the size of internal oprofile driver buffers ensuring that
the strings were never truncated for any possible values to avoid
warning/errors like 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>
---
 arch/alpha/oprofile/common.c         | 4 ++--
 arch/avr32/oprofile/op_model_avr32.c | 2 +-
 arch/mips/oprofile/common.c          | 4 ++--
 arch/powerpc/oprofile/common.c       | 4 ++--
 arch/x86/oprofile/nmi_int.c          | 2 +-
 drivers/oprofile/oprofile_perf.c     | 4 ++--
 drivers/oprofile/oprofile_stats.c    | 4 ++--
 7 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/arch/alpha/oprofile/common.c b/arch/alpha/oprofile/common.c
index 310a4ce..a1704ee 100644
--- a/arch/alpha/oprofile/common.c
+++ b/arch/alpha/oprofile/common.c
@@ -112,9 +112,9 @@ op_axp_create_files(struct dentry *root)
 
 	for (i = 0; i < model->num_counters; ++i) {
 		struct dentry *dir;
-		char buf[4];
+		char buf[32];
 
-		snprintf(buf, sizeof buf, "%d", i);
+		snprintf(buf, sizeof(buf), "%d", i);
 		dir = oprofilefs_mkdir(root, buf);
 
 		oprofilefs_create_ulong(dir, "enabled", &ctr[i].enabled);
diff --git a/arch/avr32/oprofile/op_model_avr32.c b/arch/avr32/oprofile/op_model_avr32.c
index 08308be..af1249b 100644
--- a/arch/avr32/oprofile/op_model_avr32.c
+++ b/arch/avr32/oprofile/op_model_avr32.c
@@ -101,7 +101,7 @@ static int avr32_perf_counter_create_files(struct dentry *root)
 {
 	struct dentry *dir;
 	unsigned int i;
-	char filename[4];
+	char filename[32];
 
 	for (i = 0; i < NR_counter; i++) {
 		snprintf(filename, sizeof(filename), "%u", i);
diff --git a/arch/mips/oprofile/common.c b/arch/mips/oprofile/common.c
index 2f33992..20583cd 100644
--- a/arch/mips/oprofile/common.c
+++ b/arch/mips/oprofile/common.c
@@ -41,9 +41,9 @@ static int op_mips_create_files(struct dentry *root)
 
 	for (i = 0; i < model->num_counters; ++i) {
 		struct dentry *dir;
-		char buf[4];
+		char buf[32];
 
-		snprintf(buf, sizeof buf, "%d", i);
+		snprintf(buf, sizeof(buf), "%d", i);
 		dir = oprofilefs_mkdir(root, buf);
 
 		oprofilefs_create_ulong(dir, "enabled", &ctr[i].enabled);
diff --git a/arch/powerpc/oprofile/common.c b/arch/powerpc/oprofile/common.c
index bf094c5..5ac7b88 100644
--- a/arch/powerpc/oprofile/common.c
+++ b/arch/powerpc/oprofile/common.c
@@ -157,9 +157,9 @@ static int op_powerpc_create_files(struct dentry *root)
 
 	for (i = 0; i < model->num_counters; ++i) {
 		struct dentry *dir;
-		char buf[4];
+		char buf[32];
 
-		snprintf(buf, sizeof buf, "%d", i);
+		snprintf(buf, sizeof(buf), "%d", i);
 		dir = oprofilefs_mkdir(root, buf);
 
 		oprofilefs_create_ulong(dir, "enabled", &ctr[i].enabled);
diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
index ffdbc48..dec2fd0 100644
--- a/arch/x86/oprofile/nmi_int.c
+++ b/arch/x86/oprofile/nmi_int.c
@@ -416,7 +416,7 @@ static int nmi_create_files(struct dentry *root)
 
 	for (i = 0; i < model->num_virt_counters; ++i) {
 		struct dentry *dir;
-		char buf[4];
+		char buf[32];
 
 		/* quick little hack to _not_ expose a counter if it is not
 		 * available for use.  This should protect userspace app.
diff --git a/drivers/oprofile/oprofile_perf.c b/drivers/oprofile/oprofile_perf.c
index d5b2732..acc74c4 100644
--- a/drivers/oprofile/oprofile_perf.c
+++ b/drivers/oprofile/oprofile_perf.c
@@ -144,9 +144,9 @@ static int oprofile_perf_create_files(struct dentry *root)
 
 	for (i = 0; i < num_counters; i++) {
 		struct dentry *dir;
-		char buf[4];
+		char buf[32];
 
-		snprintf(buf, sizeof buf, "%d", i);
+		snprintf(buf, sizeof(buf), "%d", i);
 		dir = oprofilefs_mkdir(root, buf);
 		oprofilefs_create_ulong(dir, "enabled", &counter_config[i].enabled);
 		oprofilefs_create_ulong(dir, "event", &counter_config[i].event);
diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
index 59659ce..14d0585 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[32];
 	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, sizeof(buf), "cpu%d", i);
 		cpudir = oprofilefs_mkdir(dir, buf);
 
 		/* Strictly speaking access to these ulongs is racy,
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-02-02 17:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2017-01-26 16:06   ` Robert Richter
2017-01-30 15:35     ` William Cohen
2017-02-02 17:21     ` William Cohen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.