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