History

kbuild: avoid duplicate warning options

Some warning options are disabled at one place and then conditionally re-enabled later in scripts/Makefile.extrawarn. For consistency, rework this file so each of those warnings only gets etiher enabled or disabled based on the W= flags but not both.

Arnd Bergmann committed 3 years ago

Commit 2cd32711 parent e88ca241 file · +26 −17Browse files

Showing the changes to scripts (1 of 1 file). Show all

Unified · Split

scripts/Makefile.extrawarn+26−17
@@ -56,20 +56,12 @@ KBUILD_CFLAGS += -Wno-pointer-sign · 55 unmodified lines
56# globally built with -Wcast-function-type.56# globally built with -Wcast-function-type.
57KBUILD_CFLAGS += $(call cc-option, -Wcast-function-type)57KBUILD_CFLAGS += $(call cc-option, -Wcast-function-type)
58 58
59# disable stringop warnings in gcc 8+
60KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation)
61
62# We'll want to enable this eventually, but it's not going away for 5.7 at least59# We'll want to enable this eventually, but it's not going away for 5.7 at least
63KBUILD_CFLAGS += $(call cc-disable-warning, stringop-overflow)60KBUILD_CFLAGS += $(call cc-disable-warning, stringop-overflow)
64 61
65# Another good warning that we'll want to enable eventually62# Another good warning that we'll want to enable eventually
66KBUILD_CFLAGS += $(call cc-disable-warning, restrict)63KBUILD_CFLAGS += $(call cc-disable-warning, restrict)
67 64
68# Enabled with W=2, disabled by default as noisy
69ifdef CONFIG_CC_IS_GCC
70KBUILD_CFLAGS += -Wno-maybe-uninitialized
71endif
72
73# The allocators already balk at large sizes, so silence the compiler65# The allocators already balk at large sizes, so silence the compiler
74# warnings for bounds checks involving those possible values. While66# warnings for bounds checks involving those possible values. While
75# -Wno-alloc-size-larger-than would normally be used here, earlier versions67# -Wno-alloc-size-larger-than would normally be used here, earlier versions
@@ -96,8 +88,6 @@ KBUILD_CFLAGS += $(call cc-option,-Werror=designated-init) · 20 unmodified lines
96# Warn if there is an enum types mismatch88# Warn if there is an enum types mismatch
97KBUILD_CFLAGS += $(call cc-option,-Wenum-conversion)89KBUILD_CFLAGS += $(call cc-option,-Wenum-conversion)
98 90
99KBUILD_CFLAGS += $(call cc-disable-warning, packed-not-aligned)
100
101# backward compatibility91# backward compatibility
102KBUILD_EXTRA_WARN ?= $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)92KBUILD_EXTRA_WARN ?= $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)
103 93
@@ -122,11 +112,6 @@ KBUILD_CFLAGS += $(call cc-option, -Wunused-but-set-variable) · 18 unmodified lines
122KBUILD_CFLAGS += $(call cc-option, -Wunused-const-variable)112KBUILD_CFLAGS += $(call cc-option, -Wunused-const-variable)
123KBUILD_CFLAGS += $(call cc-option, -Wpacked-not-aligned)113KBUILD_CFLAGS += $(call cc-option, -Wpacked-not-aligned)
124KBUILD_CFLAGS += $(call cc-option, -Wstringop-truncation)114KBUILD_CFLAGS += $(call cc-option, -Wstringop-truncation)
125# The following turn off the warnings enabled by -Wextra
126KBUILD_CFLAGS += -Wno-missing-field-initializers
127KBUILD_CFLAGS += -Wno-sign-compare
128KBUILD_CFLAGS += -Wno-type-limits
129KBUILD_CFLAGS += -Wno-shift-negative-value
130 115
131KBUILD_CPPFLAGS += -Wundef116KBUILD_CPPFLAGS += -Wundef
132KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN1117KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN1
@@ -135,9 +120,12 @@ else · 2 unmodified lines
135 120
136# Some diagnostics enabled by default are noisy.121# Some diagnostics enabled by default are noisy.
137# Suppress them by using -Wno... except for W=1.122# Suppress them by using -Wno... except for W=1.
123KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
124KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
125KBUILD_CFLAGS += $(call cc-disable-warning, packed-not-aligned)
126KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation)
138 127
139ifdef CONFIG_CC_IS_CLANG128ifdef CONFIG_CC_IS_CLANG
140KBUILD_CFLAGS += -Wno-initializer-overrides
141# Clang before clang-16 would warn on default argument promotions.129# Clang before clang-16 would warn on default argument promotions.
142ifneq ($(call clang-min-version, 160000),y)130ifneq ($(call clang-min-version, 160000),y)
143# Disable -Wformat131# Disable -Wformat
@@ -151,7 +139,6 @@ ifeq ($(call clang-min-version, 120000),y) · 7 unmodified lines
151KBUILD_CFLAGS += -Wformat-insufficient-args139KBUILD_CFLAGS += -Wformat-insufficient-args
152endif140endif
153endif141endif
154KBUILD_CFLAGS += -Wno-sign-compare
155KBUILD_CFLAGS += $(call cc-disable-warning, pointer-to-enum-cast)142KBUILD_CFLAGS += $(call cc-disable-warning, pointer-to-enum-cast)
156KBUILD_CFLAGS += -Wno-tautological-constant-out-of-range-compare143KBUILD_CFLAGS += -Wno-tautological-constant-out-of-range-compare
157KBUILD_CFLAGS += $(call cc-disable-warning, unaligned-access)144KBUILD_CFLAGS += $(call cc-disable-warning, unaligned-access)
@@ -173,8 +160,25 @@ KBUILD_CFLAGS += -Wtype-limits · 15 unmodified lines
173KBUILD_CFLAGS += $(call cc-option, -Wmaybe-uninitialized)160KBUILD_CFLAGS += $(call cc-option, -Wmaybe-uninitialized)
174KBUILD_CFLAGS += $(call cc-option, -Wunused-macros)161KBUILD_CFLAGS += $(call cc-option, -Wunused-macros)
175 162
163ifdef CONFIG_CC_IS_CLANG
164KBUILD_CFLAGS += -Winitializer-overrides
165endif
166
176KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN2167KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN2
177 168
169else
170
171# The following turn off the warnings enabled by -Wextra
172KBUILD_CFLAGS += -Wno-missing-field-initializers
173KBUILD_CFLAGS += -Wno-type-limits
174KBUILD_CFLAGS += -Wno-shift-negative-value
175
176ifdef CONFIG_CC_IS_CLANG
177KBUILD_CFLAGS += -Wno-initializer-overrides
178else
179KBUILD_CFLAGS += -Wno-maybe-uninitialized
180endif
181
178endif182endif
179 183
180#184#
@@ -196,6 +200,11 @@ KBUILD_CFLAGS += $(call cc-option, -Wpacked-bitfield-compat) · 15 unmodified lines
196 200
197KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN3201KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN3
198 202
203else
204
205# The following turn off the warnings enabled by -Wextra
206KBUILD_CFLAGS += -Wno-sign-compare
207
199endif208endif
200 209
201#210#