Skip to contentSkip to conversation

linux-next: disabling -Wstringop-truncation

PATCH Applied Stephen Rothwell 4 participants 5 messages Aug 30, 2018 – Sep 20, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi Linus,

I am now mainly using gcc v8.2 for my builds and -Wstringop-truncation causes so many warnings that I am sure to miss others, so I have applied the below to my fixes tree until the noise reduces.

From: Stephen Rothwell <[email protected]>
Date: Fri, 31 Aug 2018 07:47:28 +1000
Subject: [PATCH] disable stringop truncation warnings for now

They are too noisy

---
 Makefile | 3 +++
 1 file changed, 3 insertions(+)
Makefile +3 -0
index 2b458801ba74..a34a9283ee90 100644
@@ -807,6 +807,9 @@ KBUILD_CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
 # disable pointer signed / unsigned warnings in gcc 4.0
 KBUILD_CFLAGS += $(call cc-disable-warning, pointer-sign)
 
+# disable stringop warnings in gcc 8+
+KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation)
+
 # disable invalid "can't wrap" optimizations for signed / pointers
 KBUILD_CFLAGS	+= $(call cc-option,-fno-strict-overflow)
 
Signature · 5 lines
2.19.0.rc1

-- 
Cheers,
Stephen Rothwell
#1 lore raw
Quoted 5 lines · Stephen Rothwell

Hi Linus,

I am now mainly using gcc v8.2 for my builds and -Wstringop-truncation causes so many warnings that I am sure to miss others, so I have applied the below to my fixes tree until the noise reduces.

I have the same problem.

However It's not clear if they're all false positives (I suspect not)

It would be better to move the warning to W=2 or so, and also needs someone actually looking at them.

-Andi

#2 lore raw

Hi Andi,

Quoted 10 lines · On Thu, 30 Aug 2018 15:32:06 -0700 Andi Kleen <[email protected]> wrote:
Quoted 3 lines · Stephen Rothwell

I am now mainly using gcc v8.2 for my builds and -Wstringop-truncation causes so many warnings that I am sure to miss others, so I have applied the below to my fixes tree until the noise reduces.

I have the same problem.

However It's not clear if they're all false positives (I suspect not)

Right.

Quoted 2 lines

It would be better to move the warning to W=2 or so, and also needs someone actually looking at them.

Sure, my patch was just a quick fix for linux-next to make it more manageable. Also, I am not worse off than when I was using older compilers.

Signature · 2 lines
Cheers,
Stephen Rothwell
#3 lore raw
In reply to Stephen Rothwell
Quoted 4 lines · Stephen Rothwell

I am now mainly using gcc v8.2 for my builds and -Wstringop-truncation causes so many warnings that I am sure to miss others, so I have applied the below to my fixes tree until the noise reduces.

Applied.

If people want the warning with W=xyz, then this is still the correct patch, and we should add a line to re-enable it in scripts/Makefile.extrawarn.

Linus

#4 lore raw

Hi Stephen, Andi, (Linus),

Quoted 11 lines · Linus Torvalds
Quoted 4 lines · Stephen Rothwell

I am now mainly using gcc v8.2 for my builds and -Wstringop-truncation causes so many warnings that I am sure to miss others, so I have applied the below to my fixes tree until the noise reduces.

Applied.

If people want the warning with W=xyz, then this is still the correct patch, and we should add a line to re-enable it in scripts/Makefile.extrawarn.

For reference, I am sending the v5 of the Compiler Attributes series with the __nonstring patches appended on top, and I am adding the warning back as well, on W=1.

I think W=1 is better: there are not that many warnings compared to those in W=2. AFAIK, it is relatively easy to achieve a clean W=1 (and most code should at least try be W=1 clean, no?). Also, note that now people can use __nonstring to suppress that warning (if applicable); and that using properly __nonstring can detect even more problems (i.e. adding __nonstring may trigger additional warnings, e.g. -Wstringop-overflow); so I think we should encourage the use of __nonstring.

Cheers,
Miguel