~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/scripts/Makefile.extrawarn

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /scripts/Makefile.extrawarn (Version linux-6.12-rc7) and /scripts/Makefile.extrawarn (Version linux-6.7.12)


  1 # SPDX-License-Identifier: GPL-2.0                  1 # SPDX-License-Identifier: GPL-2.0
  2 # ============================================      2 # ==========================================================================
  3 # make W=... settings                               3 # make W=... settings
  4 #                                                   4 #
  5 # There are four warning groups enabled by W=1      5 # There are four warning groups enabled by W=1, W=2, W=3, and W=e
  6 # They are independent, and can be combined li      6 # They are independent, and can be combined like W=12 or W=123e.
  7 # ============================================      7 # ==========================================================================
  8                                                     8 
  9 # Default set of warnings, always enabled           9 # Default set of warnings, always enabled
 10 KBUILD_CFLAGS += -Wall                             10 KBUILD_CFLAGS += -Wall
 11 KBUILD_CFLAGS += -Wundef                           11 KBUILD_CFLAGS += -Wundef
 12 KBUILD_CFLAGS += -Werror=implicit-function-dec     12 KBUILD_CFLAGS += -Werror=implicit-function-declaration
 13 KBUILD_CFLAGS += -Werror=implicit-int              13 KBUILD_CFLAGS += -Werror=implicit-int
 14 KBUILD_CFLAGS += -Werror=return-type               14 KBUILD_CFLAGS += -Werror=return-type
 15 KBUILD_CFLAGS += -Werror=strict-prototypes         15 KBUILD_CFLAGS += -Werror=strict-prototypes
 16 KBUILD_CFLAGS += -Wno-format-security              16 KBUILD_CFLAGS += -Wno-format-security
 17 KBUILD_CFLAGS += -Wno-trigraphs                    17 KBUILD_CFLAGS += -Wno-trigraphs
 18 KBUILD_CFLAGS += $(call cc-disable-warning,fra     18 KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,)
 19 KBUILD_CFLAGS += $(call cc-disable-warning, ad     19 KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
 20 KBUILD_CFLAGS += -Wmissing-declarations        << 
 21 KBUILD_CFLAGS += -Wmissing-prototypes          << 
 22                                                    20 
 23 ifneq ($(CONFIG_FRAME_WARN),0)                     21 ifneq ($(CONFIG_FRAME_WARN),0)
 24 KBUILD_CFLAGS += -Wframe-larger-than=$(CONFIG_     22 KBUILD_CFLAGS += -Wframe-larger-than=$(CONFIG_FRAME_WARN)
 25 endif                                              23 endif
 26                                                    24 
 27 KBUILD_CPPFLAGS-$(CONFIG_WERROR) += -Werror        25 KBUILD_CPPFLAGS-$(CONFIG_WERROR) += -Werror
 28 KBUILD_CPPFLAGS += $(KBUILD_CPPFLAGS-y)            26 KBUILD_CPPFLAGS += $(KBUILD_CPPFLAGS-y)
 29 KBUILD_CFLAGS-$(CONFIG_CC_NO_ARRAY_BOUNDS) +=      27 KBUILD_CFLAGS-$(CONFIG_CC_NO_ARRAY_BOUNDS) += -Wno-array-bounds
 30                                                    28 
 31 ifdef CONFIG_CC_IS_CLANG                           29 ifdef CONFIG_CC_IS_CLANG
 32 # The kernel builds with '-std=gnu11' so use o     30 # The kernel builds with '-std=gnu11' so use of GNU extensions is acceptable.
 33 KBUILD_CFLAGS += -Wno-gnu                          31 KBUILD_CFLAGS += -Wno-gnu
 34 else                                               32 else
 35                                                    33 
 36 # gcc inanely warns about local variables call     34 # gcc inanely warns about local variables called 'main'
 37 KBUILD_CFLAGS += -Wno-main                         35 KBUILD_CFLAGS += -Wno-main
 38 endif                                              36 endif
 39                                                    37 
                                                   >>  38 # These warnings generated too much noise in a regular build.
                                                   >>  39 # Use make W=1 to enable them (see scripts/Makefile.extrawarn)
                                                   >>  40 KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
                                                   >>  41 KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
                                                   >>  42 
 40 # These result in bogus false positives            43 # These result in bogus false positives
 41 KBUILD_CFLAGS += $(call cc-disable-warning, da     44 KBUILD_CFLAGS += $(call cc-disable-warning, dangling-pointer)
 42                                                    45 
 43 # Variable Length Arrays (VLAs) should not be      46 # Variable Length Arrays (VLAs) should not be used anywhere in the kernel
 44 KBUILD_CFLAGS += -Wvla                             47 KBUILD_CFLAGS += -Wvla
 45                                                    48 
 46 # disable pointer signed / unsigned warnings i     49 # disable pointer signed / unsigned warnings in gcc 4.0
 47 KBUILD_CFLAGS += -Wno-pointer-sign                 50 KBUILD_CFLAGS += -Wno-pointer-sign
 48                                                    51 
 49 # In order to make sure new function cast mism     52 # In order to make sure new function cast mismatches are not introduced
 50 # in the kernel (to avoid tripping CFI checkin     53 # in the kernel (to avoid tripping CFI checking), the kernel should be
 51 # globally built with -Wcast-function-type.        54 # globally built with -Wcast-function-type.
 52 KBUILD_CFLAGS += $(call cc-option, -Wcast-func     55 KBUILD_CFLAGS += $(call cc-option, -Wcast-function-type)
 53                                                    56 
 54 # The allocators already balk at large sizes,      57 # The allocators already balk at large sizes, so silence the compiler
 55 # warnings for bounds checks involving those p     58 # warnings for bounds checks involving those possible values. While
 56 # -Wno-alloc-size-larger-than would normally b     59 # -Wno-alloc-size-larger-than would normally be used here, earlier versions
 57 # of gcc (<9.1) weirdly don't handle the optio     60 # of gcc (<9.1) weirdly don't handle the option correctly when _other_
 58 # warnings are produced (?!). Using -Walloc-si     61 # warnings are produced (?!). Using -Walloc-size-larger-than=SIZE_MAX
 59 # doesn't work (as it is documented to), silen     62 # doesn't work (as it is documented to), silently resolving to "0" prior to
 60 # version 9.1 (and producing an error more rec     63 # version 9.1 (and producing an error more recently). Numeric values larger
 61 # than PTRDIFF_MAX also don't work prior to ve     64 # than PTRDIFF_MAX also don't work prior to version 9.1, which are silently
 62 # ignored, continuing to default to PTRDIFF_MA     65 # ignored, continuing to default to PTRDIFF_MAX. So, left with no other
 63 # choice, we must perform a versioned check to     66 # choice, we must perform a versioned check to disable this warning.
 64 # https://lore.kernel.org/lkml/20210824115859.     67 # https://lore.kernel.org/lkml/20210824115859.187f272f@canb.auug.org.au
 65 KBUILD_CFLAGS-$(call gcc-min-version, 90100) +     68 KBUILD_CFLAGS-$(call gcc-min-version, 90100) += -Wno-alloc-size-larger-than
 66 KBUILD_CFLAGS += $(KBUILD_CFLAGS-y) $(CONFIG_C     69 KBUILD_CFLAGS += $(KBUILD_CFLAGS-y) $(CONFIG_CC_IMPLICIT_FALLTHROUGH)
 67                                                    70 
 68 # Prohibit date/time macros, which would make      71 # Prohibit date/time macros, which would make the build non-deterministic
 69 KBUILD_CFLAGS += -Werror=date-time                 72 KBUILD_CFLAGS += -Werror=date-time
 70                                                    73 
 71 # enforce correct pointer usage                    74 # enforce correct pointer usage
 72 KBUILD_CFLAGS += $(call cc-option,-Werror=inco     75 KBUILD_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types)
 73                                                    76 
 74 # Require designated initializers for all mark     77 # Require designated initializers for all marked structures
 75 KBUILD_CFLAGS += $(call cc-option,-Werror=desi     78 KBUILD_CFLAGS += $(call cc-option,-Werror=designated-init)
 76                                                    79 
 77 # Warn if there is an enum types mismatch          80 # Warn if there is an enum types mismatch
 78 KBUILD_CFLAGS += $(call cc-option,-Wenum-conve     81 KBUILD_CFLAGS += $(call cc-option,-Wenum-conversion)
 79                                                    82 
 80 KBUILD_CFLAGS += -Wextra                       !!  83 # backward compatibility
 81 KBUILD_CFLAGS += -Wunused                      !!  84 KBUILD_EXTRA_WARN ?= $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)
                                                   >>  85 
                                                   >>  86 ifeq ("$(origin W)", "command line")
                                                   >>  87   KBUILD_EXTRA_WARN := $(W)
                                                   >>  88 endif
                                                   >>  89 
                                                   >>  90 export KBUILD_EXTRA_WARN
 82                                                    91 
 83 #                                                  92 #
 84 # W=1 - warnings which may be relevant and do      93 # W=1 - warnings which may be relevant and do not occur too often
 85 #                                                  94 #
 86 ifneq ($(findstring 1, $(KBUILD_EXTRA_WARN)),)     95 ifneq ($(findstring 1, $(KBUILD_EXTRA_WARN)),)
 87                                                    96 
                                                   >>  97 KBUILD_CFLAGS += -Wextra -Wunused -Wno-unused-parameter
                                                   >>  98 KBUILD_CFLAGS += -Wmissing-declarations
                                                   >>  99 KBUILD_CFLAGS += $(call cc-option, -Wrestrict)
 88 KBUILD_CFLAGS += -Wmissing-format-attribute       100 KBUILD_CFLAGS += -Wmissing-format-attribute
                                                   >> 101 KBUILD_CFLAGS += -Wmissing-prototypes
                                                   >> 102 KBUILD_CFLAGS += -Wold-style-definition
 89 KBUILD_CFLAGS += -Wmissing-include-dirs           103 KBUILD_CFLAGS += -Wmissing-include-dirs
                                                   >> 104 KBUILD_CFLAGS += $(call cc-option, -Wunused-but-set-variable)
 90 KBUILD_CFLAGS += $(call cc-option, -Wunused-co    105 KBUILD_CFLAGS += $(call cc-option, -Wunused-const-variable)
                                                   >> 106 KBUILD_CFLAGS += $(call cc-option, -Wpacked-not-aligned)
                                                   >> 107 KBUILD_CFLAGS += $(call cc-option, -Wformat-overflow)
                                                   >> 108 KBUILD_CFLAGS += $(call cc-option, -Wformat-truncation)
                                                   >> 109 KBUILD_CFLAGS += $(call cc-option, -Wstringop-overflow)
                                                   >> 110 KBUILD_CFLAGS += $(call cc-option, -Wstringop-truncation)
 91                                                   111 
 92 KBUILD_CPPFLAGS += -Wundef                        112 KBUILD_CPPFLAGS += -Wundef
 93 KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN1           113 KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN1
 94                                                   114 
 95 else                                              115 else
 96                                                   116 
 97 # Some diagnostics enabled by default are nois    117 # Some diagnostics enabled by default are noisy.
 98 # Suppress them by using -Wno... except for W=    118 # Suppress them by using -Wno... except for W=1.
 99 KBUILD_CFLAGS += $(call cc-disable-warning, un    119 KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
100 KBUILD_CFLAGS += $(call cc-disable-warning, un    120 KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
                                                   >> 121 KBUILD_CFLAGS += $(call cc-disable-warning, restrict)
101 KBUILD_CFLAGS += $(call cc-disable-warning, pa    122 KBUILD_CFLAGS += $(call cc-disable-warning, packed-not-aligned)
102 KBUILD_CFLAGS += $(call cc-disable-warning, fo    123 KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow)
103 ifdef CONFIG_CC_IS_GCC                         << 
104 KBUILD_CFLAGS += $(call cc-disable-warning, fo    124 KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation)
105 else                                           !! 125 KBUILD_CFLAGS += $(call cc-disable-warning, stringop-overflow)
106 # Clang checks for overflow/truncation with '% << 
107 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id << 
108 KBUILD_CFLAGS += $(call cc-disable-warning, fo << 
109 KBUILD_CFLAGS += $(call cc-disable-warning, fo << 
110 endif                                          << 
111 KBUILD_CFLAGS += $(call cc-disable-warning, st    126 KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation)
112                                                   127 
113 KBUILD_CFLAGS += -Wno-override-init # alias fo << 
114                                                << 
115 ifdef CONFIG_CC_IS_CLANG                          128 ifdef CONFIG_CC_IS_CLANG
116 # Clang before clang-16 would warn on default     129 # Clang before clang-16 would warn on default argument promotions.
117 ifneq ($(call clang-min-version, 160000),y)       130 ifneq ($(call clang-min-version, 160000),y)
118 # Disable -Wformat                                131 # Disable -Wformat
119 KBUILD_CFLAGS += -Wno-format                      132 KBUILD_CFLAGS += -Wno-format
120 # Then re-enable flags that were part of the -    133 # Then re-enable flags that were part of the -Wformat group that aren't
121 # problematic.                                    134 # problematic.
122 KBUILD_CFLAGS += -Wformat-extra-args -Wformat-    135 KBUILD_CFLAGS += -Wformat-extra-args -Wformat-invalid-specifier
123 KBUILD_CFLAGS += -Wformat-zero-length -Wnonnul    136 KBUILD_CFLAGS += -Wformat-zero-length -Wnonnull
124 # Requires clang-12+.                             137 # Requires clang-12+.
125 ifeq ($(call clang-min-version, 120000),y)        138 ifeq ($(call clang-min-version, 120000),y)
126 KBUILD_CFLAGS += -Wformat-insufficient-args       139 KBUILD_CFLAGS += -Wformat-insufficient-args
127 endif                                             140 endif
128 endif                                             141 endif
129 KBUILD_CFLAGS += $(call cc-disable-warning, po    142 KBUILD_CFLAGS += $(call cc-disable-warning, pointer-to-enum-cast)
130 KBUILD_CFLAGS += -Wno-tautological-constant-ou    143 KBUILD_CFLAGS += -Wno-tautological-constant-out-of-range-compare
131 KBUILD_CFLAGS += $(call cc-disable-warning, un    144 KBUILD_CFLAGS += $(call cc-disable-warning, unaligned-access)
                                                   >> 145 KBUILD_CFLAGS += $(call cc-disable-warning, cast-function-type-strict)
132 KBUILD_CFLAGS += -Wno-enum-compare-conditional    146 KBUILD_CFLAGS += -Wno-enum-compare-conditional
133 KBUILD_CFLAGS += -Wno-enum-enum-conversion        147 KBUILD_CFLAGS += -Wno-enum-enum-conversion
134 endif                                             148 endif
135                                                   149 
136 endif                                             150 endif
137                                                   151 
138 #                                                 152 #
139 # W=2 - warnings which occur quite often but m    153 # W=2 - warnings which occur quite often but may still be relevant
140 #                                                 154 #
141 ifneq ($(findstring 2, $(KBUILD_EXTRA_WARN)),)    155 ifneq ($(findstring 2, $(KBUILD_EXTRA_WARN)),)
142                                                   156 
143 KBUILD_CFLAGS += -Wdisabled-optimization          157 KBUILD_CFLAGS += -Wdisabled-optimization
144 KBUILD_CFLAGS += -Wshadow                         158 KBUILD_CFLAGS += -Wshadow
145 KBUILD_CFLAGS += $(call cc-option, -Wlogical-o    159 KBUILD_CFLAGS += $(call cc-option, -Wlogical-op)
                                                   >> 160 KBUILD_CFLAGS += -Wmissing-field-initializers
                                                   >> 161 KBUILD_CFLAGS += -Wtype-limits
                                                   >> 162 KBUILD_CFLAGS += $(call cc-option, -Wmaybe-uninitialized)
146 KBUILD_CFLAGS += $(call cc-option, -Wunused-ma    163 KBUILD_CFLAGS += $(call cc-option, -Wunused-macros)
147                                                   164 
                                                   >> 165 ifdef CONFIG_CC_IS_CLANG
                                                   >> 166 KBUILD_CFLAGS += -Winitializer-overrides
                                                   >> 167 endif
                                                   >> 168 
148 KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN2           169 KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN2
149                                                   170 
150 else                                              171 else
151                                                   172 
152 # The following turn off the warnings enabled     173 # The following turn off the warnings enabled by -Wextra
153 KBUILD_CFLAGS += -Wno-missing-field-initialize    174 KBUILD_CFLAGS += -Wno-missing-field-initializers
154 KBUILD_CFLAGS += -Wno-type-limits                 175 KBUILD_CFLAGS += -Wno-type-limits
155 KBUILD_CFLAGS += -Wno-shift-negative-value        176 KBUILD_CFLAGS += -Wno-shift-negative-value
156                                                   177 
157 ifdef CONFIG_CC_IS_GCC                         !! 178 ifdef CONFIG_CC_IS_CLANG
                                                   >> 179 KBUILD_CFLAGS += -Wno-initializer-overrides
                                                   >> 180 else
158 KBUILD_CFLAGS += -Wno-maybe-uninitialized         181 KBUILD_CFLAGS += -Wno-maybe-uninitialized
159 endif                                             182 endif
160                                                   183 
161 endif                                             184 endif
162                                                   185 
163 #                                                 186 #
164 # W=3 - more obscure warnings, can most likely    187 # W=3 - more obscure warnings, can most likely be ignored
165 #                                                 188 #
166 ifneq ($(findstring 3, $(KBUILD_EXTRA_WARN)),)    189 ifneq ($(findstring 3, $(KBUILD_EXTRA_WARN)),)
167                                                   190 
168 KBUILD_CFLAGS += -Wbad-function-cast              191 KBUILD_CFLAGS += -Wbad-function-cast
169 KBUILD_CFLAGS += -Wcast-align                     192 KBUILD_CFLAGS += -Wcast-align
170 KBUILD_CFLAGS += -Wcast-qual                      193 KBUILD_CFLAGS += -Wcast-qual
171 KBUILD_CFLAGS += -Wconversion                     194 KBUILD_CFLAGS += -Wconversion
172 KBUILD_CFLAGS += -Wpacked                         195 KBUILD_CFLAGS += -Wpacked
173 KBUILD_CFLAGS += -Wpadded                         196 KBUILD_CFLAGS += -Wpadded
174 KBUILD_CFLAGS += -Wpointer-arith                  197 KBUILD_CFLAGS += -Wpointer-arith
175 KBUILD_CFLAGS += -Wredundant-decls                198 KBUILD_CFLAGS += -Wredundant-decls
176 KBUILD_CFLAGS += -Wsign-compare                   199 KBUILD_CFLAGS += -Wsign-compare
177 KBUILD_CFLAGS += -Wswitch-default                 200 KBUILD_CFLAGS += -Wswitch-default
                                                   >> 201 KBUILD_CFLAGS += $(call cc-option, -Wpacked-bitfield-compat)
178                                                   202 
179 KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN3           203 KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN3
180                                                   204 
181 else                                              205 else
182                                                   206 
183 # The following turn off the warnings enabled     207 # The following turn off the warnings enabled by -Wextra
184 KBUILD_CFLAGS += -Wno-sign-compare                208 KBUILD_CFLAGS += -Wno-sign-compare
185 KBUILD_CFLAGS += -Wno-unused-parameter         << 
186                                                   209 
187 endif                                             210 endif
188                                                   211 
189 #                                                 212 #
190 # W=e - error out on warnings                     213 # W=e - error out on warnings
191 #                                                 214 #
192 ifneq ($(findstring e, $(KBUILD_EXTRA_WARN)),)    215 ifneq ($(findstring e, $(KBUILD_EXTRA_WARN)),)
193                                                   216 
194 KBUILD_CFLAGS += -Werror                          217 KBUILD_CFLAGS += -Werror
195                                                   218 
196 endif                                             219 endif
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php