Commit 28bc20dc authored by Sam Ravnborg's avatar Sam Ravnborg Committed by Michal Marek

kbuild: implement several W= levels

Building a kernel with "make W=1" produces far too much noise to be
useful.

Divide the warning options in three groups:

    W=1 - warnings that may be relevant and does not occur too often
    W=2 - warnings that occur quite often but may still be relevant
    W=3 - the more obscure warnings, can most likely be ignored

When building the whole kernel, those levels produce:

W=1 - 4859 warnings
W=2 - 1394 warnings
W=3 - 86666 warnings

respectively. Warnings have been counted with Geert's script at

http://www.kernel.org/pub/linux/kernel/people/geert/linux-log/linux-log-summary.pl

Many warnings occur from .h files so fixing one file may have a nice
effect on the total number of warnings.

With these changes I am actually tempted to try W=1 now and then.
Previously there was just too much noise.

Borislav:

- make the W= levels exclusive
- move very noisy and making little sense for the kernel warnings to W=3
- drop -Woverlength-strings due to useless warning message
- copy explanatory text for the different warning levels to 'make help'
- recount warnings per level
Signed-off-by: default avatarSam Ravnborg <sam@ravnborg.org>
Signed-off-by: default avatarBorislav Petkov <bp@alien8.de>
Cc: Dave Jones <davej@redhat.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: default avatarMichal Marek <mmarek@suse.cz>
parent 40df759e
...@@ -103,7 +103,7 @@ ifeq ("$(origin O)", "command line") ...@@ -103,7 +103,7 @@ ifeq ("$(origin O)", "command line")
endif endif
ifeq ("$(origin W)", "command line") ifeq ("$(origin W)", "command line")
export KBUILD_ENABLE_EXTRA_GCC_CHECKS := 1 export KBUILD_ENABLE_EXTRA_GCC_CHECKS := $(W)
endif endif
# That's our default target when none is given on the command line # That's our default target when none is given on the command line
...@@ -1274,7 +1274,11 @@ help: ...@@ -1274,7 +1274,11 @@ help:
@echo ' make O=dir [targets] Locate all output files in "dir", including .config' @echo ' make O=dir [targets] Locate all output files in "dir", including .config'
@echo ' make C=1 [targets] Check all c source with $$CHECK (sparse by default)' @echo ' make C=1 [targets] Check all c source with $$CHECK (sparse by default)'
@echo ' make C=2 [targets] Force check of all c source with $$CHECK' @echo ' make C=2 [targets] Force check of all c source with $$CHECK'
@echo ' make W=1 [targets] Enable extra gcc checks' @echo ' make W=n [targets] Enable extra gcc checks, n=1,2,3 where'
@echo ' 1: warnings which may be relevant and do not occur too often'
@echo ' 2: warnings which occur quite often but may still be relevant'
@echo ' 3: more obscure warnings, can most likely be ignored'
@echo '' @echo ''
@echo 'Execute "make" or "make all" to build all targets marked with [*] ' @echo 'Execute "make" or "make all" to build all targets marked with [*] '
@echo 'For further info see the ./README file' @echo 'For further info see the ./README file'
......
...@@ -51,36 +51,47 @@ ifeq ($(KBUILD_NOPEDANTIC),) ...@@ -51,36 +51,47 @@ ifeq ($(KBUILD_NOPEDANTIC),)
endif endif
# #
# make W=1 settings # make W=... settings
# #
# $(call cc-option... ) handles gcc -W.. options which # W=1 - warnings that may be relevant and does not occur too often
# W=2 - warnings that occur quite often but may still be relevant
# W=3 - the more obscure warnings, can most likely be ignored
#
# $(call cc-option, -W...) handles gcc -W.. options which
# are not supported by all versions of the compiler # are not supported by all versions of the compiler
ifdef KBUILD_ENABLE_EXTRA_GCC_CHECKS ifdef KBUILD_ENABLE_EXTRA_GCC_CHECKS
KBUILD_EXTRA_WARNINGS := -Wextra warning-1 := -Wextra -Wunused -Wno-unused-parameter
KBUILD_EXTRA_WARNINGS += -Wunused -Wno-unused-parameter warning-1 += -Wmissing-declarations
KBUILD_EXTRA_WARNINGS += -Waggregate-return warning-1 += -Wmissing-format-attribute
KBUILD_EXTRA_WARNINGS += -Wbad-function-cast warning-1 += -Wmissing-prototypes
KBUILD_EXTRA_WARNINGS += -Wcast-qual warning-1 += -Wold-style-definition
KBUILD_EXTRA_WARNINGS += -Wcast-align warning-1 += $(call cc-option, -Wmissing-include-dirs)
KBUILD_EXTRA_WARNINGS += -Wconversion
KBUILD_EXTRA_WARNINGS += -Wdisabled-optimization warning-2 := -Waggregate-return
KBUILD_EXTRA_WARNINGS += -Wlogical-op warning-2 += -Wcast-align
KBUILD_EXTRA_WARNINGS += -Wmissing-declarations warning-2 += -Wdisabled-optimization
KBUILD_EXTRA_WARNINGS += -Wmissing-format-attribute warning-2 += -Wnested-externs
KBUILD_EXTRA_WARNINGS += $(call cc-option, -Wmissing-include-dirs,) warning-2 += -Wshadow
KBUILD_EXTRA_WARNINGS += -Wmissing-prototypes warning-2 += $(call cc-option, -Wlogical-op)
KBUILD_EXTRA_WARNINGS += -Wnested-externs
KBUILD_EXTRA_WARNINGS += -Wold-style-definition warning-3 := -Wbad-function-cast
KBUILD_EXTRA_WARNINGS += $(call cc-option, -Woverlength-strings,) warning-3 += -Wcast-qual
KBUILD_EXTRA_WARNINGS += -Wpacked warning-3 += -Wconversion
KBUILD_EXTRA_WARNINGS += -Wpacked-bitfield-compat warning-3 += -Wpacked
KBUILD_EXTRA_WARNINGS += -Wpadded warning-3 += -Wpadded
KBUILD_EXTRA_WARNINGS += -Wpointer-arith warning-3 += -Wpointer-arith
KBUILD_EXTRA_WARNINGS += -Wredundant-decls warning-3 += -Wredundant-decls
KBUILD_EXTRA_WARNINGS += -Wshadow warning-3 += -Wswitch-default
KBUILD_EXTRA_WARNINGS += -Wswitch-default warning-3 += $(call cc-option, -Wpacked-bitfield-compat)
KBUILD_EXTRA_WARNINGS += $(call cc-option, -Wvla,) warning-3 += $(call cc-option, -Wvla)
KBUILD_CFLAGS += $(KBUILD_EXTRA_WARNINGS)
warning := $(warning-$(KBUILD_ENABLE_EXTRA_GCC_CHECKS))
ifeq ("$(warning)","")
$(error W=$(KBUILD_ENABLE_EXTRA_GCC_CHECKS) is unknown)
endif
KBUILD_CFLAGS += $(warning)
endif endif
include scripts/Makefile.lib include scripts/Makefile.lib
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment