18c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci# ========================================================================== 38c2ecf20Sopenharmony_ci# make W=... settings 48c2ecf20Sopenharmony_ci# 58c2ecf20Sopenharmony_ci# There are three warning groups enabled by W=1, W=2, W=3. 68c2ecf20Sopenharmony_ci# They are independent, and can be combined like W=12 or W=123. 78c2ecf20Sopenharmony_ci# ========================================================================== 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ciKBUILD_CFLAGS += $(call cc-disable-warning, packed-not-aligned) 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci# backward compatibility 128c2ecf20Sopenharmony_ciKBUILD_EXTRA_WARN ?= $(KBUILD_ENABLE_EXTRA_GCC_CHECKS) 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ciifeq ("$(origin W)", "command line") 158c2ecf20Sopenharmony_ci KBUILD_EXTRA_WARN := $(W) 168c2ecf20Sopenharmony_ciendif 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ciexport KBUILD_EXTRA_WARN 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci# 218c2ecf20Sopenharmony_ci# W=1 - warnings which may be relevant and do not occur too often 228c2ecf20Sopenharmony_ci# 238c2ecf20Sopenharmony_ciifneq ($(findstring 1, $(KBUILD_EXTRA_WARN)),) 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -Wextra -Wunused -Wno-unused-parameter 268c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -Wmissing-declarations 278c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -Wmissing-format-attribute 288c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -Wmissing-prototypes 298c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -Wold-style-definition 308c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -Wmissing-include-dirs 318c2ecf20Sopenharmony_ciKBUILD_CFLAGS += $(call cc-option, -Wunused-but-set-variable) 328c2ecf20Sopenharmony_ciKBUILD_CFLAGS += $(call cc-option, -Wunused-const-variable) 338c2ecf20Sopenharmony_ciKBUILD_CFLAGS += $(call cc-option, -Wpacked-not-aligned) 348c2ecf20Sopenharmony_ciKBUILD_CFLAGS += $(call cc-option, -Wstringop-truncation) 358c2ecf20Sopenharmony_ci# The following turn off the warnings enabled by -Wextra 368c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -Wno-missing-field-initializers 378c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -Wno-sign-compare 388c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -Wno-type-limits 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ciKBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN1 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_cielse 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci# Some diagnostics enabled by default are noisy. 458c2ecf20Sopenharmony_ci# Suppress them by using -Wno... except for W=1. 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ciifdef CONFIG_CC_IS_CLANG 488c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -Wno-initializer-overrides 498c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -Wno-format 508c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -Wno-sign-compare 518c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -Wno-format-zero-length 528c2ecf20Sopenharmony_ciKBUILD_CFLAGS += $(call cc-disable-warning, pointer-to-enum-cast) 538c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -Wno-tautological-constant-out-of-range-compare 548c2ecf20Sopenharmony_ciKBUILD_CFLAGS += $(call cc-disable-warning, unaligned-access) 558c2ecf20Sopenharmony_ciKBUILD_CFLAGS += $(call cc-disable-warning, cast-function-type-strict) 568c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -Wno-declaration-after-statement 578c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -Wno-strict-prototypes 588c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -Wno-int-conversion 598c2ecf20Sopenharmony_ciendif 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ciendif 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci# 648c2ecf20Sopenharmony_ci# W=2 - warnings which occur quite often but may still be relevant 658c2ecf20Sopenharmony_ci# 668c2ecf20Sopenharmony_ciifneq ($(findstring 2, $(KBUILD_EXTRA_WARN)),) 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -Wdisabled-optimization 698c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -Wnested-externs 708c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -Wshadow 718c2ecf20Sopenharmony_ciKBUILD_CFLAGS += $(call cc-option, -Wlogical-op) 728c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -Wmissing-field-initializers 738c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -Wtype-limits 748c2ecf20Sopenharmony_ciKBUILD_CFLAGS += $(call cc-option, -Wmaybe-uninitialized) 758c2ecf20Sopenharmony_ciKBUILD_CFLAGS += $(call cc-option, -Wunused-macros) 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ciKBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN2 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ciendif 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci# 828c2ecf20Sopenharmony_ci# W=3 - more obscure warnings, can most likely be ignored 838c2ecf20Sopenharmony_ci# 848c2ecf20Sopenharmony_ciifneq ($(findstring 3, $(KBUILD_EXTRA_WARN)),) 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -Wbad-function-cast 878c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -Wcast-align 888c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -Wcast-qual 898c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -Wconversion 908c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -Wpacked 918c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -Wpadded 928c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -Wpointer-arith 938c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -Wredundant-decls 948c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -Wsign-compare 958c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -Wswitch-default 968c2ecf20Sopenharmony_ciKBUILD_CFLAGS += $(call cc-option, -Wpacked-bitfield-compat) 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ciKBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN3 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_ciendif 101