Skip to content

Commit 738fc99

Browse files
nathanchancemasahir0y
authored andcommitted
scripts/Makefile.extrawarn: Do not show clang's non-kprintf warnings at W=1
Clang's -Wformat-overflow and -Wformat-truncation have chosen to check '%p' unlike GCC but it does not know about the kernel's pointer extensions in lib/vsprintf.c, so the developers split that part of the warning out for the kernel to disable because there will always be false positives. Commit 908dd50 ("kbuild: enable -Wformat-truncation on clang") did disabled these warnings but only in a block that would be called when W=1 was not passed, so they would appear with W=1. Move the disabling of the non-kprintf warnings to a block that always runs so that they are never seen, regardless of warning level. Fixes: 908dd50 ("kbuild: enable -Wformat-truncation on clang") Reported-by: kernel test robot <[email protected]> Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/ Signed-off-by: Nathan Chancellor <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]>
1 parent 2014c95 commit 738fc99

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

scripts/Makefile.extrawarn

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ KBUILD_CFLAGS-$(CONFIG_CC_NO_ARRAY_BOUNDS) += -Wno-array-bounds
3131
ifdef CONFIG_CC_IS_CLANG
3232
# The kernel builds with '-std=gnu11' so use of GNU extensions is acceptable.
3333
KBUILD_CFLAGS += -Wno-gnu
34+
35+
# Clang checks for overflow/truncation with '%p', while GCC does not:
36+
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111219
37+
KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow-non-kprintf)
38+
KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation-non-kprintf)
3439
else
3540

3641
# gcc inanely warns about local variables called 'main'
@@ -105,11 +110,6 @@ KBUILD_CFLAGS += $(call cc-disable-warning, packed-not-aligned)
105110
KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow)
106111
ifdef CONFIG_CC_IS_GCC
107112
KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation)
108-
else
109-
# Clang checks for overflow/truncation with '%p', while GCC does not:
110-
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111219
111-
KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow-non-kprintf)
112-
KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation-non-kprintf)
113113
endif
114114
KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation)
115115

0 commit comments

Comments
 (0)