Back to home page

LXR

 
 

    


0001 # ==========================================================================
0002 #
0003 # make W=... settings
0004 #
0005 # W=1 - warnings that may be relevant and does not occur too often
0006 # W=2 - warnings that occur quite often but may still be relevant
0007 # W=3 - the more obscure warnings, can most likely be ignored
0008 #
0009 # $(call cc-option, -W...) handles gcc -W.. options which
0010 # are not supported by all versions of the compiler
0011 # ==========================================================================
0012 
0013 ifeq ("$(origin W)", "command line")
0014   export KBUILD_ENABLE_EXTRA_GCC_CHECKS := $(W)
0015 endif
0016 
0017 ifdef KBUILD_ENABLE_EXTRA_GCC_CHECKS
0018 warning-  := $(empty)
0019 
0020 warning-1 := -Wextra -Wunused -Wno-unused-parameter
0021 warning-1 += -Wmissing-declarations
0022 warning-1 += -Wmissing-format-attribute
0023 warning-1 += $(call cc-option, -Wmissing-prototypes)
0024 warning-1 += -Wold-style-definition
0025 warning-1 += $(call cc-option, -Wmissing-include-dirs)
0026 warning-1 += $(call cc-option, -Wunused-but-set-variable)
0027 warning-1 += $(call cc-option, -Wunused-const-variable)
0028 warning-1 += $(call cc-disable-warning, missing-field-initializers)
0029 warning-1 += $(call cc-disable-warning, sign-compare)
0030 
0031 warning-2 := -Waggregate-return
0032 warning-2 += -Wcast-align
0033 warning-2 += -Wdisabled-optimization
0034 warning-2 += -Wnested-externs
0035 warning-2 += -Wshadow
0036 warning-2 += $(call cc-option, -Wlogical-op)
0037 warning-2 += $(call cc-option, -Wmissing-field-initializers)
0038 warning-2 += $(call cc-option, -Wsign-compare)
0039 warning-2 += $(call cc-option, -Wmaybe-uninitialized)
0040 
0041 warning-3 := -Wbad-function-cast
0042 warning-3 += -Wcast-qual
0043 warning-3 += -Wconversion
0044 warning-3 += -Wpacked
0045 warning-3 += -Wpadded
0046 warning-3 += -Wpointer-arith
0047 warning-3 += -Wredundant-decls
0048 warning-3 += -Wswitch-default
0049 warning-3 += $(call cc-option, -Wpacked-bitfield-compat)
0050 warning-3 += $(call cc-option, -Wvla)
0051 
0052 warning := $(warning-$(findstring 1, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)))
0053 warning += $(warning-$(findstring 2, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)))
0054 warning += $(warning-$(findstring 3, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)))
0055 
0056 ifeq ("$(strip $(warning))","")
0057         $(error W=$(KBUILD_ENABLE_EXTRA_GCC_CHECKS) is unknown)
0058 endif
0059 
0060 KBUILD_CFLAGS += $(warning)
0061 else
0062 
0063 ifeq ($(cc-name),clang)
0064 KBUILD_CFLAGS += $(call cc-disable-warning, initializer-overrides)
0065 KBUILD_CFLAGS += $(call cc-disable-warning, unused-value)
0066 KBUILD_CFLAGS += $(call cc-disable-warning, format)
0067 KBUILD_CFLAGS += $(call cc-disable-warning, unknown-warning-option)
0068 KBUILD_CFLAGS += $(call cc-disable-warning, sign-compare)
0069 KBUILD_CFLAGS += $(call cc-disable-warning, format-zero-length)
0070 KBUILD_CFLAGS += $(call cc-disable-warning, uninitialized)
0071 endif
0072 endif