diff mbox series

[9/9,RFC] extrawarn: enable more W=1 warnings by default

Message ID 20230811140327.3754597-10-arnd@kernel.org (mailing list archive)
State New, archived
Headers show
Series Kbuild: warning options cleanup and more warnings | expand

Commit Message

Arnd Bergmann Aug. 11, 2023, 2:03 p.m. UTC
From: Arnd Bergmann <arnd@arndb.de>

A number of warning options from the W=1 set are completely clean in current
kernels, so we should just enable them by default, including a lot of warnings
that are part of -Wextra, so just turn on -Wextra by default.

The -Woverride-init, -Wvoid-pointer-to-enum-cast and
-Wmissing-format-attribute warnings are part of -Wextra but still produce
some legitimate warnings that need to be fixed, so leave them at the
W=1 level but turn them off otherwise.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 scripts/Makefile.extrawarn | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

Comments

Nathan Chancellor Aug. 11, 2023, 4:09 p.m. UTC | #1
On Fri, Aug 11, 2023 at 04:03:27PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> A number of warning options from the W=1 set are completely clean in current
> kernels, so we should just enable them by default, including a lot of warnings
> that are part of -Wextra, so just turn on -Wextra by default.
> 
> The -Woverride-init, -Wvoid-pointer-to-enum-cast and
> -Wmissing-format-attribute warnings are part of -Wextra but still produce
> some legitimate warnings that need to be fixed, so leave them at the
> W=1 level but turn them off otherwise.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
...
> -KBUILD_CFLAGS += -Wno-tautological-constant-out-of-range-compare
> -KBUILD_CFLAGS += $(call cc-disable-warning, unaligned-access)
> -KBUILD_CFLAGS += $(call cc-disable-warning, cast-function-type-strict)

I am still running through my builds but I don't think that dropping
these three is acceptable at the moment. I see a good number of all of
these warnings in -next still. I see some patches that I have picked up
to address a couple of the really noisy ones but some others that I
looked at are not fixed. I'll have a list eventually.

Cheers,
Nathan
Arnd Bergmann Aug. 11, 2023, 6:23 p.m. UTC | #2
On Fri, Aug 11, 2023, at 18:09, Nathan Chancellor wrote:
> On Fri, Aug 11, 2023 at 04:03:27PM +0200, Arnd Bergmann wrote:
>> From: Arnd Bergmann <arnd@arndb.de>
>> 
>> A number of warning options from the W=1 set are completely clean in current
>> kernels, so we should just enable them by default, including a lot of warnings
>> that are part of -Wextra, so just turn on -Wextra by default.
>> 
>> The -Woverride-init, -Wvoid-pointer-to-enum-cast and
>> -Wmissing-format-attribute warnings are part of -Wextra but still produce
>> some legitimate warnings that need to be fixed, so leave them at the
>> W=1 level but turn them off otherwise.
>> 
>> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ...
>> -KBUILD_CFLAGS += -Wno-tautological-constant-out-of-range-compare
>> -KBUILD_CFLAGS += $(call cc-disable-warning, unaligned-access)
>> -KBUILD_CFLAGS += $(call cc-disable-warning, cast-function-type-strict)
>
> I am still running through my builds but I don't think that dropping
> these three is acceptable at the moment. I see a good number of all of
> these warnings in -next still. I see some patches that I have picked up
> to address a couple of the really noisy ones but some others that I
> looked at are not fixed. I'll have a list eventually.

Ok, thanks. I have a backlog of warning fixes in my randconfig
tree, which is currently clean with these warnings addressed, at
least on arm/arm64/x86 and it looks like there are a couple that
I've never sent out so far. I'll drop the above for now, as I
won't have time to send all the fixes before my vacation.

I can provide the ones I have off-list for reference, but there
are a couple that are missing changelog texts or that I'm not
entirely sure about myself.

    Arnd
Nathan Chancellor Aug. 14, 2023, 7:52 p.m. UTC | #3
On Fri, Aug 11, 2023 at 08:23:45PM +0200, Arnd Bergmann wrote:
> On Fri, Aug 11, 2023, at 18:09, Nathan Chancellor wrote:
> > On Fri, Aug 11, 2023 at 04:03:27PM +0200, Arnd Bergmann wrote:
> >> From: Arnd Bergmann <arnd@arndb.de>
> >> 
> >> A number of warning options from the W=1 set are completely clean in current
> >> kernels, so we should just enable them by default, including a lot of warnings
> >> that are part of -Wextra, so just turn on -Wextra by default.
> >> 
> >> The -Woverride-init, -Wvoid-pointer-to-enum-cast and
> >> -Wmissing-format-attribute warnings are part of -Wextra but still produce
> >> some legitimate warnings that need to be fixed, so leave them at the
> >> W=1 level but turn them off otherwise.
> >> 
> >> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> > ...
> >> -KBUILD_CFLAGS += -Wno-tautological-constant-out-of-range-compare
> >> -KBUILD_CFLAGS += $(call cc-disable-warning, unaligned-access)
> >> -KBUILD_CFLAGS += $(call cc-disable-warning, cast-function-type-strict)
> >
> > I am still running through my builds but I don't think that dropping
> > these three is acceptable at the moment. I see a good number of all of
> > these warnings in -next still. I see some patches that I have picked up
> > to address a couple of the really noisy ones but some others that I
> > looked at are not fixed. I'll have a list eventually.
> 
> Ok, thanks. I have a backlog of warning fixes in my randconfig
> tree, which is currently clean with these warnings addressed, at
> least on arm/arm64/x86 and it looks like there are a couple that
> I've never sent out so far. I'll drop the above for now, as I
> won't have time to send all the fixes before my vacation.

Thanks, that takes care of the vast majority of extra warnings that this
series produces. I have included all my build logs at [1].

The slightly-filtered-warnings file is the result of searching for all
warnings in the log files and passing them through 'sort | uniq -c',
additionally ignoring the instances of -Wnull-pointer-arithmetic that
are present in certain configurations, as those are pretty well known at
this point.

The more-filtered-warnings file does the same thing but also ignores
instances of the three warnings above, which just reveals some instances
of -Wunused-but-set-parameter, which I am pretty sure I have seen you
sent fixes for recently, so I think with those three warnings left as
disabled, this series should be safe.

[1]: https://github.com/nathanchance/bug-files/tree/9100c6a21cbdce3c03fbca1bd00a7c34f316a137/enable-more-W%3D1-warnings-by-default

Cheers,
Nathan
diff mbox series

Patch

diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index 1e6822b22c260..9185d69727542 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -72,6 +72,12 @@  KBUILD_CFLAGS += $(call cc-option,-Werror=designated-init)
 # Warn if there is an enum types mismatch
 KBUILD_CFLAGS += $(call cc-option,-Wenum-conversion)
 
+KBUILD_CFLAGS += -Wextra
+KBUILD_CFLAGS += -Wunused -Wno-unused-parameter
+KBUILD_CFLAGS += -Wold-style-definition
+KBUILD_CFLAGS += -Wmissing-include-dirs
+KBUILD_CFLAGS += $(call cc-option, -Wpacked-not-aligned)
+
 # backward compatibility
 KBUILD_EXTRA_WARN ?= $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)
 
@@ -86,16 +92,11 @@  export KBUILD_EXTRA_WARN
 #
 ifneq ($(findstring 1, $(KBUILD_EXTRA_WARN)),)
 
-KBUILD_CFLAGS += -Wextra -Wunused -Wno-unused-parameter
 KBUILD_CFLAGS += -Wmissing-declarations
-KBUILD_CFLAGS += $(call cc-option, -Wrestrict)
 KBUILD_CFLAGS += -Wmissing-format-attribute
 KBUILD_CFLAGS += -Wmissing-prototypes
-KBUILD_CFLAGS += -Wold-style-definition
-KBUILD_CFLAGS += -Wmissing-include-dirs
 KBUILD_CFLAGS += $(call cc-option, -Wunused-but-set-variable)
 KBUILD_CFLAGS += $(call cc-option, -Wunused-const-variable)
-KBUILD_CFLAGS += $(call cc-option, -Wpacked-not-aligned)
 KBUILD_CFLAGS += $(call cc-option, -Wformat-overflow)
 KBUILD_CFLAGS += $(call cc-option, -Wformat-truncation)
 KBUILD_CFLAGS += $(call cc-option, -Wstringop-overflow)
@@ -110,8 +111,7 @@  else
 # Suppress them by using -Wno... except for W=1.
 KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
 KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
-KBUILD_CFLAGS += $(call cc-disable-warning, restrict)
-KBUILD_CFLAGS += $(call cc-disable-warning, packed-not-aligned)
+KBUILD_CFLAGS += $(call cc-disable-warning, missing-format-attribute)
 KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow)
 KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation)
 KBUILD_CFLAGS += $(call cc-disable-warning, stringop-overflow)
@@ -131,12 +131,10 @@  ifeq ($(call clang-min-version, 120000),y)
 KBUILD_CFLAGS += -Wformat-insufficient-args
 endif
 endif
-KBUILD_CFLAGS += $(call cc-disable-warning, pointer-to-enum-cast)
-KBUILD_CFLAGS += -Wno-tautological-constant-out-of-range-compare
-KBUILD_CFLAGS += $(call cc-disable-warning, unaligned-access)
-KBUILD_CFLAGS += $(call cc-disable-warning, cast-function-type-strict)
+KBUILD_CFLAGS += -Wno-void-pointer-to-enum-cast
 else
 KBUILD_CFLAGS += -Wno-main
+KBUILD_CFLAGS += -Wno-override-init
 endif
 
 endif