Skip to content

Commit 6e8d666

Browse files
committed
Disable "maybe-uninitialized" warning globally
Several build configurations had already disabled this warning because it generates a lot of false positives. But some had not, and it was still enabled for "allmodconfig" builds, for example. Looking at the warnings produced, every single one I looked at was a false positive, and the warnings are frequent enough (and big enough) that they can easily hide real problems that you don't notice in the noise generated by -Wmaybe-uninitialized. The warning is good in theory, but this is a classic case of a warning that causes more problems than the warning can solve. If gcc gets better at avoiding false positives, we may be able to re-enable this warning. But as is, we're better off without it, and I want to be able to see the *real* warnings. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 468fc7e commit 6e8d666

File tree

3 files changed

+5
-10
lines changed

3 files changed

+5
-10
lines changed

Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ LDFLAGS_MODULE =
370370
CFLAGS_KERNEL =
371371
AFLAGS_KERNEL =
372372
LDFLAGS_vmlinux =
373-
CFLAGS_GCOV = -fprofile-arcs -ftest-coverage -fno-tree-loop-im -Wno-maybe-uninitialized
373+
CFLAGS_GCOV = -fprofile-arcs -ftest-coverage -fno-tree-loop-im
374374
CFLAGS_KCOV = -fsanitize-coverage=trace-pc
375375

376376

@@ -619,12 +619,13 @@ ARCH_CFLAGS :=
619619
include arch/$(SRCARCH)/Makefile
620620

621621
KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks,)
622+
KBUILD_CFLAGS += $(call cc-disable-warning,maybe-uninitialized,)
622623

623624
ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
624-
KBUILD_CFLAGS += -Os $(call cc-disable-warning,maybe-uninitialized,)
625+
KBUILD_CFLAGS += -Os
625626
else
626627
ifdef CONFIG_PROFILE_ALL_BRANCHES
627-
KBUILD_CFLAGS += -O2 $(call cc-disable-warning,maybe-uninitialized,)
628+
KBUILD_CFLAGS += -O2
628629
else
629630
KBUILD_CFLAGS += -O2
630631
endif

arch/arc/Makefile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,7 @@ endif
7474
ifndef CONFIG_CC_OPTIMIZE_FOR_SIZE
7575
# Generic build system uses -O2, we want -O3
7676
# Note: No need to add to cflags-y as that happens anyways
77-
#
78-
# Disable the false maybe-uninitialized warings gcc spits out at -O3
79-
ARCH_CFLAGS += -O3 $(call cc-disable-warning,maybe-uninitialized,)
77+
ARCH_CFLAGS += -O3
8078
endif
8179

8280
# small data is default for elf32 tool-chain. If not usable, disable it

scripts/Makefile.ubsan

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,4 @@ ifdef CONFIG_UBSAN
1414
ifdef CONFIG_UBSAN_ALIGNMENT
1515
CFLAGS_UBSAN += $(call cc-option, -fsanitize=alignment)
1616
endif
17-
18-
# -fsanitize=* options makes GCC less smart than usual and
19-
# increase number of 'maybe-uninitialized false-positives
20-
CFLAGS_UBSAN += $(call cc-option, -Wno-maybe-uninitialized)
2117
endif

0 commit comments

Comments
 (0)