From patchwork Fri Aug 11 14:03:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 13350926 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 666ECC0015E for ; Fri, 11 Aug 2023 14:03:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234123AbjHKODp (ORCPT ); Fri, 11 Aug 2023 10:03:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234098AbjHKODn (ORCPT ); Fri, 11 Aug 2023 10:03:43 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AE3D2D7B; Fri, 11 Aug 2023 07:03:41 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D3B7867363; Fri, 11 Aug 2023 14:03:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3921C433CD; Fri, 11 Aug 2023 14:03:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691762620; bh=j+eOKQYti+AN7EczMgi60CP1M65iTD27prSKu2KILxM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EFca2cxkebiISpHQkQRzdb+UxNgasyUOKqgT46/xbyJZzh7SCIMOREecRSuDzEgQn oK/QDQO001KiF/9foe5meWYNB76P2p+myTvmQSCrRE1V2o6sNtPXtKjL2Nb5mfnRyc Z+vWOFS5v1sF6Cm4/XUQIgP+0g1S1aDY20cugUMRHn6zEVVuVn1taFPKInbnIWSdZF YRXa21egHU56n9g+2v20hCIJaKFsuRtRfqK3cy2bBEhNam3qIGIKDV/HIUR+l/EsmN SX88i0U+rLbmPLUK7nruN0EuGcx2Q3Bj5uY4tNDJZakmjWK/hflnfJOCoQ58CrmKtA +SLkrv//TPGoQ== From: Arnd Bergmann To: Masahiro Yamada Cc: Arnd Bergmann , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , Guenter Roeck , Lee Jones , Stephen Rothwell , linux-kbuild@vger.kernel.org, linux-arch@vger.kernel.org Subject: [PATCH 1/9] Kbuild: only pass -fno-inline-functions-called-once for gcc Date: Fri, 11 Aug 2023 16:03:19 +0200 Message-Id: <20230811140327.3754597-2-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230811140327.3754597-1-arnd@kernel.org> References: <20230811140327.3754597-1-arnd@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org From: Arnd Bergmann clang ignores the -fno-inline-functions-called-once option, but warns when building with -Wignored-optimization-argument enabled: clang: error: optimization flag '-fno-inline-functions-called-once' is not supported [-Werror,-Wignored-optimization-argument] Move it back to using cc-option for this one. Fixes: 7d73c3e9c514 ("Makefile: remove stale cc-option checks") Signed-off-by: Arnd Bergmann --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index bf5a6100cf66e..991c02f8e9ac0 100644 --- a/Makefile +++ b/Makefile @@ -967,7 +967,7 @@ endif # We trigger additional mismatches with less inlining ifdef CONFIG_DEBUG_SECTION_MISMATCH -KBUILD_CFLAGS += -fno-inline-functions-called-once +KBUILD_CFLAGS += $(call cc-option,-fno-inline-functions-called-once) endif # `rustc`'s `-Zfunction-sections` applies to data too (as of 1.59.0). From patchwork Fri Aug 11 14:03:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 13350927 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BAF34C04A94 for ; Fri, 11 Aug 2023 14:03:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235743AbjHKODq (ORCPT ); Fri, 11 Aug 2023 10:03:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235522AbjHKODo (ORCPT ); Fri, 11 Aug 2023 10:03:44 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 075932D7F; Fri, 11 Aug 2023 07:03:44 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8B6FC67362; Fri, 11 Aug 2023 14:03:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC40BC43397; Fri, 11 Aug 2023 14:03:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691762623; bh=z8lCn6cz4GCn6Uq4H3sjrBefukkYhIMpxI1IVSZWGJE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dtkAWn1JseFw7rCDuZ09oj36A4qZezPTUkEYFMdyFm6L6ObW+GMDhEYwjfDmQQRbh dnL++isRsNuiVxHziHxysl6eqouottx9ipVIGDKUtMlK6pGr00WENW+bFIFYP7Wqw5 fGxRu+SULyHOcH7xwKg+UXmcgBrp5CsxucrDtyWDzgMexLf4HhXLX0qif3hAWJFN3v ONq3tW9fXCAy4owKYNeAk5yak2ep8o1rLoa2IHoFbmoCDgmdAf6tHTwq4mGITR1N7i ilCodlg7TbC5ErdLXZSvVR0RAVkSaoXpta86cNUEaCcYfkTv/tZk+sdzqZDBFsYo3O qQAuufMyksFtg== From: Arnd Bergmann To: Masahiro Yamada Cc: Arnd Bergmann , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , Guenter Roeck , Lee Jones , Stephen Rothwell , linux-kbuild@vger.kernel.org, linux-arch@vger.kernel.org Subject: [PATCH 2/9] Kbuild: consolidate warning flags in scripts/Makefile.extrawarn Date: Fri, 11 Aug 2023 16:03:20 +0200 Message-Id: <20230811140327.3754597-3-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230811140327.3754597-1-arnd@kernel.org> References: <20230811140327.3754597-1-arnd@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org From: Arnd Bergmann Warning options are enabled and disabled in inconsistent ways and inconsistent locations. Start rearranging those by moving all options into Makefile.extrawarn. This should not change any behavior, but makes sure we can group them in a way that ensures that each warning that got temporarily disabled is turned back on at an appropriate W=1 level later on. Signed-off-by: Arnd Bergmann --- Makefile | 88 ------------------------------------- scripts/Makefile.extrawarn | 90 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+), 88 deletions(-) diff --git a/Makefile b/Makefile index 991c02f8e9ac0..781ff496f4aed 100644 --- a/Makefile +++ b/Makefile @@ -563,14 +563,6 @@ KBUILD_CFLAGS += -funsigned-char KBUILD_CFLAGS += -fno-common KBUILD_CFLAGS += -fno-PIE KBUILD_CFLAGS += -fno-strict-aliasing -KBUILD_CFLAGS += -Wall -KBUILD_CFLAGS += -Wundef -KBUILD_CFLAGS += -Werror=implicit-function-declaration -KBUILD_CFLAGS += -Werror=implicit-int -KBUILD_CFLAGS += -Werror=return-type -KBUILD_CFLAGS += -Werror=strict-prototypes -KBUILD_CFLAGS += -Wno-format-security -KBUILD_CFLAGS += -Wno-trigraphs KBUILD_CPPFLAGS := -D__KERNEL__ KBUILD_RUSTFLAGS := $(rust_common_flags) \ @@ -823,10 +815,6 @@ endif # may-sync-config endif # need-config KBUILD_CFLAGS += -fno-delete-null-pointer-checks -KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,) -KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation) -KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow) -KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member) ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE KBUILD_CFLAGS += -O2 @@ -857,40 +845,15 @@ ifdef CONFIG_READABLE_ASM KBUILD_CFLAGS += -fno-reorder-blocks -fno-ipa-cp-clone -fno-partial-inlining endif -ifneq ($(CONFIG_FRAME_WARN),0) -KBUILD_CFLAGS += -Wframe-larger-than=$(CONFIG_FRAME_WARN) -endif - stackp-flags-y := -fno-stack-protector stackp-flags-$(CONFIG_STACKPROTECTOR) := -fstack-protector stackp-flags-$(CONFIG_STACKPROTECTOR_STRONG) := -fstack-protector-strong KBUILD_CFLAGS += $(stackp-flags-y) -KBUILD_CPPFLAGS-$(CONFIG_WERROR) += -Werror -KBUILD_CPPFLAGS += $(KBUILD_CPPFLAGS-y) -KBUILD_CFLAGS-$(CONFIG_CC_NO_ARRAY_BOUNDS) += -Wno-array-bounds - KBUILD_RUSTFLAGS-$(CONFIG_WERROR) += -Dwarnings KBUILD_RUSTFLAGS += $(KBUILD_RUSTFLAGS-y) -ifdef CONFIG_CC_IS_CLANG -# The kernel builds with '-std=gnu11' so use of GNU extensions is acceptable. -KBUILD_CFLAGS += -Wno-gnu -else - -# gcc inanely warns about local variables called 'main' -KBUILD_CFLAGS += -Wno-main -endif - -# These warnings generated too much noise in a regular build. -# Use make W=1 to enable them (see scripts/Makefile.extrawarn) -KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable) -KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable) - -# These result in bogus false positives -KBUILD_CFLAGS += $(call cc-disable-warning, dangling-pointer) - ifdef CONFIG_FRAME_POINTER KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls KBUILD_RUSTFLAGS += -Cforce-frame-pointers=y @@ -1025,51 +988,12 @@ endif # arch Makefile may override CC so keep this after arch Makefile is included NOSTDINC_FLAGS += -nostdinc -# Variable Length Arrays (VLAs) should not be used anywhere in the kernel -KBUILD_CFLAGS += -Wvla - -# disable pointer signed / unsigned warnings in gcc 4.0 -KBUILD_CFLAGS += -Wno-pointer-sign - -# In order to make sure new function cast mismatches are not introduced -# in the kernel (to avoid tripping CFI checking), the kernel should be -# globally built with -Wcast-function-type. -KBUILD_CFLAGS += $(call cc-option, -Wcast-function-type) - # To gain proper coverage for CONFIG_UBSAN_BOUNDS and CONFIG_FORTIFY_SOURCE, # the kernel uses only C99 flexible arrays for dynamically sized trailing # arrays. Enforce this for everything that may examine structure sizes and # perform bounds checking. KBUILD_CFLAGS += $(call cc-option, -fstrict-flex-arrays=3) -# disable stringop warnings in gcc 8+ -KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation) - -# We'll want to enable this eventually, but it's not going away for 5.7 at least -KBUILD_CFLAGS += $(call cc-disable-warning, stringop-overflow) - -# Another good warning that we'll want to enable eventually -KBUILD_CFLAGS += $(call cc-disable-warning, restrict) - -# Enabled with W=2, disabled by default as noisy -ifdef CONFIG_CC_IS_GCC -KBUILD_CFLAGS += -Wno-maybe-uninitialized -endif - -# The allocators already balk at large sizes, so silence the compiler -# warnings for bounds checks involving those possible values. While -# -Wno-alloc-size-larger-than would normally be used here, earlier versions -# of gcc (<9.1) weirdly don't handle the option correctly when _other_ -# warnings are produced (?!). Using -Walloc-size-larger-than=SIZE_MAX -# doesn't work (as it is documented to), silently resolving to "0" prior to -# version 9.1 (and producing an error more recently). Numeric values larger -# than PTRDIFF_MAX also don't work prior to version 9.1, which are silently -# ignored, continuing to default to PTRDIFF_MAX. So, left with no other -# choice, we must perform a versioned check to disable this warning. -# https://lore.kernel.org/lkml/20210824115859.187f272f@canb.auug.org.au -KBUILD_CFLAGS-$(call gcc-min-version, 90100) += -Wno-alloc-size-larger-than -KBUILD_CFLAGS += $(KBUILD_CFLAGS-y) $(CONFIG_CC_IMPLICIT_FALLTHROUGH) - # disable invalid "can't wrap" optimizations for signed / pointers KBUILD_CFLAGS += -fno-strict-overflow @@ -1081,18 +1005,6 @@ ifdef CONFIG_CC_IS_GCC KBUILD_CFLAGS += -fconserve-stack endif -# Prohibit date/time macros, which would make the build non-deterministic -KBUILD_CFLAGS += -Werror=date-time - -# enforce correct pointer usage -KBUILD_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types) - -# Require designated initializers for all marked structures -KBUILD_CFLAGS += $(call cc-option,-Werror=designated-init) - -# Warn if there is an enum types mismatch -KBUILD_CFLAGS += $(call cc-option,-Wenum-conversion) - # change __FILE__ to the relative path from the srctree KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=) diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn index 40cd13eca82e8..9cc0e52ebd7eb 100644 --- a/scripts/Makefile.extrawarn +++ b/scripts/Makefile.extrawarn @@ -6,6 +6,96 @@ # They are independent, and can be combined like W=12 or W=123e. # ========================================================================== +# Default set of warnings, always enabled +KBUILD_CFLAGS += -Wall +KBUILD_CFLAGS += -Wundef +KBUILD_CFLAGS += -Werror=implicit-function-declaration +KBUILD_CFLAGS += -Werror=implicit-int +KBUILD_CFLAGS += -Werror=return-type +KBUILD_CFLAGS += -Werror=strict-prototypes +KBUILD_CFLAGS += -Wno-format-security +KBUILD_CFLAGS += -Wno-trigraphs +KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,) +KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation) +KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow) +KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member) + +ifneq ($(CONFIG_FRAME_WARN),0) +KBUILD_CFLAGS += -Wframe-larger-than=$(CONFIG_FRAME_WARN) +endif + +KBUILD_CPPFLAGS-$(CONFIG_WERROR) += -Werror +KBUILD_CPPFLAGS += $(KBUILD_CPPFLAGS-y) +KBUILD_CFLAGS-$(CONFIG_CC_NO_ARRAY_BOUNDS) += -Wno-array-bounds + +ifdef CONFIG_CC_IS_CLANG +# The kernel builds with '-std=gnu11' so use of GNU extensions is acceptable. +KBUILD_CFLAGS += -Wno-gnu +else + +# gcc inanely warns about local variables called 'main' +KBUILD_CFLAGS += -Wno-main +endif + +# These warnings generated too much noise in a regular build. +# Use make W=1 to enable them (see scripts/Makefile.extrawarn) +KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable) +KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable) + +# These result in bogus false positives +KBUILD_CFLAGS += $(call cc-disable-warning, dangling-pointer) + +# Variable Length Arrays (VLAs) should not be used anywhere in the kernel +KBUILD_CFLAGS += -Wvla + +# disable pointer signed / unsigned warnings in gcc 4.0 +KBUILD_CFLAGS += -Wno-pointer-sign + +# In order to make sure new function cast mismatches are not introduced +# in the kernel (to avoid tripping CFI checking), the kernel should be +# globally built with -Wcast-function-type. +KBUILD_CFLAGS += $(call cc-option, -Wcast-function-type) + +# disable stringop warnings in gcc 8+ +KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation) + +# We'll want to enable this eventually, but it's not going away for 5.7 at least +KBUILD_CFLAGS += $(call cc-disable-warning, stringop-overflow) + +# Another good warning that we'll want to enable eventually +KBUILD_CFLAGS += $(call cc-disable-warning, restrict) + +# Enabled with W=2, disabled by default as noisy +ifdef CONFIG_CC_IS_GCC +KBUILD_CFLAGS += -Wno-maybe-uninitialized +endif + +# The allocators already balk at large sizes, so silence the compiler +# warnings for bounds checks involving those possible values. While +# -Wno-alloc-size-larger-than would normally be used here, earlier versions +# of gcc (<9.1) weirdly don't handle the option correctly when _other_ +# warnings are produced (?!). Using -Walloc-size-larger-than=SIZE_MAX +# doesn't work (as it is documented to), silently resolving to "0" prior to +# version 9.1 (and producing an error more recently). Numeric values larger +# than PTRDIFF_MAX also don't work prior to version 9.1, which are silently +# ignored, continuing to default to PTRDIFF_MAX. So, left with no other +# choice, we must perform a versioned check to disable this warning. +# https://lore.kernel.org/lkml/20210824115859.187f272f@canb.auug.org.au +KBUILD_CFLAGS-$(call gcc-min-version, 90100) += -Wno-alloc-size-larger-than +KBUILD_CFLAGS += $(KBUILD_CFLAGS-y) $(CONFIG_CC_IMPLICIT_FALLTHROUGH) + +# Prohibit date/time macros, which would make the build non-deterministic +KBUILD_CFLAGS += -Werror=date-time + +# enforce correct pointer usage +KBUILD_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types) + +# Require designated initializers for all marked structures +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 += $(call cc-disable-warning, packed-not-aligned) # backward compatibility From patchwork Fri Aug 11 14:03:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 13350928 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C943C0015E for ; Fri, 11 Aug 2023 14:03:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234373AbjHKODw (ORCPT ); Fri, 11 Aug 2023 10:03:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235802AbjHKODr (ORCPT ); Fri, 11 Aug 2023 10:03:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD9822D78; Fri, 11 Aug 2023 07:03:46 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 434E067358; Fri, 11 Aug 2023 14:03:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7219BC433C7; Fri, 11 Aug 2023 14:03:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691762625; bh=I/TFxqUUMSUrllQ7NnImM26eIykZcRmEoTOopHwYd+A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jiFFLBBe683hDMqkrqXjki+Jgksmk3yd9MF6wrqhLw4KOlx9gi7wwJjHzfToXmdqQ FYrluGVxAKgtexrj4+lJlQfKgI6TPh4txEaAaWoGs75CWlAAtzUU4MXmc2ytImIGOp j4Fnk1Wecm7uCrN068yGLAjxpfUR4Jj/3hm0/fAdIs2Y8qtCpn5TXPPsw+Iohsldj3 TJzB0IZauX0fOYyVXaBpEiZzU5BKmXYnIrEmEah7TezXtUnGuSooLfk+8InkgUQ9cW x4nNFOl6c6yQmC/ao+Ei9D9GP6bMToPpa92J/n9vAKn8daHUfjWeMBcolrc4ud6IoS wenSkxCe0eFVw== From: Arnd Bergmann To: Masahiro Yamada Cc: Arnd Bergmann , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , Guenter Roeck , Lee Jones , Stephen Rothwell , linux-kbuild@vger.kernel.org, linux-arch@vger.kernel.org Subject: [PATCH 3/9] Kbuild: avoid duplicate warning options Date: Fri, 11 Aug 2023 16:03:21 +0200 Message-Id: <20230811140327.3754597-4-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230811140327.3754597-1-arnd@kernel.org> References: <20230811140327.3754597-1-arnd@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org From: Arnd Bergmann Some warning options are disabled at one place and then conditionally re-enabled later in scripts/Makefile.extrawarn. For consistency, rework this file so each of those warnings only gets etiher enabled or disabled based on the W= flags but not both. Signed-off-by: Arnd Bergmann --- scripts/Makefile.extrawarn | 43 +++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn index 9cc0e52ebd7eb..8afbe4706ff11 100644 --- a/scripts/Makefile.extrawarn +++ b/scripts/Makefile.extrawarn @@ -56,20 +56,12 @@ KBUILD_CFLAGS += -Wno-pointer-sign # globally built with -Wcast-function-type. KBUILD_CFLAGS += $(call cc-option, -Wcast-function-type) -# disable stringop warnings in gcc 8+ -KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation) - # We'll want to enable this eventually, but it's not going away for 5.7 at least KBUILD_CFLAGS += $(call cc-disable-warning, stringop-overflow) # Another good warning that we'll want to enable eventually KBUILD_CFLAGS += $(call cc-disable-warning, restrict) -# Enabled with W=2, disabled by default as noisy -ifdef CONFIG_CC_IS_GCC -KBUILD_CFLAGS += -Wno-maybe-uninitialized -endif - # The allocators already balk at large sizes, so silence the compiler # warnings for bounds checks involving those possible values. While # -Wno-alloc-size-larger-than would normally be used here, earlier versions @@ -96,8 +88,6 @@ 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 += $(call cc-disable-warning, packed-not-aligned) - # backward compatibility KBUILD_EXTRA_WARN ?= $(KBUILD_ENABLE_EXTRA_GCC_CHECKS) @@ -122,11 +112,6 @@ 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, -Wstringop-truncation) -# The following turn off the warnings enabled by -Wextra -KBUILD_CFLAGS += -Wno-missing-field-initializers -KBUILD_CFLAGS += -Wno-sign-compare -KBUILD_CFLAGS += -Wno-type-limits -KBUILD_CFLAGS += -Wno-shift-negative-value KBUILD_CPPFLAGS += -Wundef KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN1 @@ -135,9 +120,12 @@ else # Some diagnostics enabled by default are noisy. # 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, packed-not-aligned) +KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation) ifdef CONFIG_CC_IS_CLANG -KBUILD_CFLAGS += -Wno-initializer-overrides # Clang before clang-16 would warn on default argument promotions. ifneq ($(call clang-min-version, 160000),y) # Disable -Wformat @@ -151,7 +139,6 @@ ifeq ($(call clang-min-version, 120000),y) KBUILD_CFLAGS += -Wformat-insufficient-args endif endif -KBUILD_CFLAGS += -Wno-sign-compare 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) @@ -173,8 +160,25 @@ KBUILD_CFLAGS += -Wtype-limits KBUILD_CFLAGS += $(call cc-option, -Wmaybe-uninitialized) KBUILD_CFLAGS += $(call cc-option, -Wunused-macros) +ifdef CONFIG_CC_IS_CLANG +KBUILD_CFLAGS += -Winitializer-overrides +endif + KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN2 +else + +# The following turn off the warnings enabled by -Wextra +KBUILD_CFLAGS += -Wno-missing-field-initializers +KBUILD_CFLAGS += -Wno-type-limits +KBUILD_CFLAGS += -Wno-shift-negative-value + +ifdef CONFIG_CC_IS_CLANG +KBUILD_CFLAGS += -Wno-initializer-overrides +else +KBUILD_CFLAGS += -Wno-maybe-uninitialized +endif + endif # @@ -196,6 +200,11 @@ KBUILD_CFLAGS += $(call cc-option, -Wpacked-bitfield-compat) KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN3 +else + +# The following turn off the warnings enabled by -Wextra +KBUILD_CFLAGS += -Wno-sign-compare + endif # From patchwork Fri Aug 11 14:03:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 13350929 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86C8FC04A94 for ; Fri, 11 Aug 2023 14:03:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235655AbjHKODx (ORCPT ); Fri, 11 Aug 2023 10:03:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235816AbjHKODv (ORCPT ); Fri, 11 Aug 2023 10:03:51 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67E3C2D7D; Fri, 11 Aug 2023 07:03:49 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id F05EE67368; Fri, 11 Aug 2023 14:03:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2AD6EC433C8; Fri, 11 Aug 2023 14:03:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691762628; bh=jcJprh47OwtgCNUJpCeFBNe9idE06uF1RkKWw9KW+8Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fHjEwQn9seGxZDoFIyUggXp5NicGSLVnHHNn5H4v6io3AEtbzcT01UdQZqUswjN6u og2SuFQ+5YbpUNfNz+YwLEL6eHEtgt30iFk/ZeGPESxCVXSaz7RFIXJg3KcPDVZr3Z mZ38bAbL4DEP5fWtg1QO8q/QAC/k1oCMAyXB3GUEKQns9IP+jrhM1hRuAtCSJ9xyZf v/BOpfu/Pbxhc4PYpLZNKXa+oIrLFHSdFqhu/je1OgcsgmlU9VSxr4doAhUrxxR3uM kDnBsGXYaO+H7mcmn5IWN5B2fl6QQQXQXLEPgTbZlpR77ioJaA08svgoiikZo54sBp 7SdZ3gG+A4irg== From: Arnd Bergmann To: Masahiro Yamada Cc: Arnd Bergmann , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , Guenter Roeck , Lee Jones , Stephen Rothwell , linux-kbuild@vger.kernel.org, linux-arch@vger.kernel.org Subject: [PATCH 4/9] extrawarn: don't turn off -Wshift-negative-value for gcc-9 Date: Fri, 11 Aug 2023 16:03:22 +0200 Message-Id: <20230811140327.3754597-5-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230811140327.3754597-1-arnd@kernel.org> References: <20230811140327.3754597-1-arnd@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org From: Arnd Bergmann The warning does nothing for newer versions of gcc since -fno-strict-overflow is used, on old versions it warns about lines that would be undefined otherwise: fs/isofs/util.c: In function 'iso_date': fs/isofs/util.c:40:14: error: left shift of negative value [-Werror=shift-negative-value] tz |= (-1 << 8); ^~ drivers/video/fbdev/tdfxfb.c: In function 'tdfxfb_probe': drivers/video/fbdev/tdfxfb.c:1482:17: error: left shift of negative value [-Werror=shift-negative-value] (PAGE_MASK << 1); ^~ drivers/tty/serial/8250/8250_core.c: In function 'serial8250_request_rsa_resource': drivers/tty/serial/8250/8250_core.c:350:38: error: left shift of negative value [-Werror=shift-negative-value] unsigned long start = UART_RSA_BASE << up->port.regshift; ^~ drivers/tty/serial/8250/8250_core.c: In function 'serial8250_release_rsa_resource': drivers/tty/serial/8250/8250_core.c:371:39: error: left shift of negative value [-Werror=shift-negative-value] unsigned long offset = UART_RSA_BASE << up->port.regshift; ^~ drivers/clk/mvebu/dove-divider.c: In function 'dove_set_clock': drivers/clk/mvebu/dove-divider.c:145:14: error: left shift of negative value [-Werror=shift-negative-value] mask = ~(~0 << dc->div_bit_size) << dc->div_bit_start; ^~ drivers/block/drbd/drbd_main.c: In function 'dcbp_set_pad_bits': drivers/block/drbd/drbd_main.c:1098:37: error: left shift of negative value [-Werror=shift-negative-value] p->encoding = (p->encoding & (~0x7 << 4)) | (n << 4); Disable these conditionally to keep the command line a little shorter. Signed-off-by: Arnd Bergmann --- scripts/Makefile.extrawarn | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn index 8afbe4706ff11..87bfe153198f1 100644 --- a/scripts/Makefile.extrawarn +++ b/scripts/Makefile.extrawarn @@ -171,12 +171,14 @@ else # The following turn off the warnings enabled by -Wextra KBUILD_CFLAGS += -Wno-missing-field-initializers KBUILD_CFLAGS += -Wno-type-limits -KBUILD_CFLAGS += -Wno-shift-negative-value ifdef CONFIG_CC_IS_CLANG KBUILD_CFLAGS += -Wno-initializer-overrides else KBUILD_CFLAGS += -Wno-maybe-uninitialized +ifneq ($(call gcc-min-version, 90100),y) +KBUILD_CFLAGS += $(call cc-disable-warning, shift-negative-value) +endif endif endif From patchwork Fri Aug 11 14:03:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 13350930 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AFCEBC41513 for ; Fri, 11 Aug 2023 14:03:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235533AbjHKODx (ORCPT ); Fri, 11 Aug 2023 10:03:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234098AbjHKODw (ORCPT ); Fri, 11 Aug 2023 10:03:52 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0EA8CEA; Fri, 11 Aug 2023 07:03:52 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A18416735F; Fri, 11 Aug 2023 14:03:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5C91C433C9; Fri, 11 Aug 2023 14:03:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691762631; bh=StEZnUgwBbzkGTrOg3LGjjgmffFdTIC8SG8G5XNIROI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dRNzmLWbEY+goLxMckredhCEwaMrn8Ei+wLNo5nytuIhvNtSnqSQkc2qtE59S0+M1 7ra59Zz2jXvdScAu5q6ffhN1XBeTkSfuYDWkHCv5b1V4dSIAjDRv4wn2NbFer9YdXZ 46HqpcR3Xlo45uCAw2W/juCNHlXXpSKQ+iQlUEsf0k2HyYLND37Igp6UphAMdcEibB r9Mri16bhi0S8Zbz+Ci31EHew97KfyD/m01GTp/YDB1d7Xx79nkZAq/GbOrjb/WM/b xYDA9h4q5XNqAtmxy/RWaLVeY3xOgk4IA8S/QuiI/bBuNR5HozTnjGhA3ol3u6JFlS uwUnRYpolbidA== From: Arnd Bergmann To: Masahiro Yamada Cc: Arnd Bergmann , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , Guenter Roeck , Lee Jones , Stephen Rothwell , linux-kbuild@vger.kernel.org, linux-arch@vger.kernel.org Subject: [PATCH 5/9] extrawarn: enable format and stringop overflow warnings in W=1 Date: Fri, 11 Aug 2023 16:03:23 +0200 Message-Id: <20230811140327.3754597-6-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230811140327.3754597-1-arnd@kernel.org> References: <20230811140327.3754597-1-arnd@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org From: Arnd Bergmann The stringop and format warnings got disabled globally when they were newly introduced in commit bd664f6b3e376 ("disable new gcc-7.1.1 warnings for now"), 217c3e0196758 ("disable stringop truncation warnings for now") and 5a76021c2eff7 ("gcc-10: disable 'stringop-overflow' warning for now"). In all cases, the sentiment at the time was that the warnings are useful, and we actually addressed a number of real bugs based on them, but we never managed to eliminate them all because even the build bots using W=1 builds only see the -Wstringop-truncation warnings that are enabled at that level. Move these into the W=1 section to give them a larger build coverage and actually eliminate them over time. Signed-off-by: Arnd Bergmann --- scripts/Makefile.extrawarn | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn index 87bfe153198f1..ec528972371fa 100644 --- a/scripts/Makefile.extrawarn +++ b/scripts/Makefile.extrawarn @@ -16,8 +16,6 @@ KBUILD_CFLAGS += -Werror=strict-prototypes KBUILD_CFLAGS += -Wno-format-security KBUILD_CFLAGS += -Wno-trigraphs KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,) -KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation) -KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow) KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member) ifneq ($(CONFIG_FRAME_WARN),0) @@ -56,9 +54,6 @@ KBUILD_CFLAGS += -Wno-pointer-sign # globally built with -Wcast-function-type. KBUILD_CFLAGS += $(call cc-option, -Wcast-function-type) -# We'll want to enable this eventually, but it's not going away for 5.7 at least -KBUILD_CFLAGS += $(call cc-disable-warning, stringop-overflow) - # Another good warning that we'll want to enable eventually KBUILD_CFLAGS += $(call cc-disable-warning, restrict) @@ -111,6 +106,9 @@ 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) KBUILD_CFLAGS += $(call cc-option, -Wstringop-truncation) KBUILD_CPPFLAGS += -Wundef @@ -123,6 +121,9 @@ else 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, packed-not-aligned) +KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow) +KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation) +KBUILD_CFLAGS += $(call cc-disable-warning, stringop-overflow) KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation) ifdef CONFIG_CC_IS_CLANG From patchwork Fri Aug 11 14:03:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 13350931 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA282C41513 for ; Fri, 11 Aug 2023 14:04:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235802AbjHKOD7 (ORCPT ); Fri, 11 Aug 2023 10:03:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235788AbjHKODy (ORCPT ); Fri, 11 Aug 2023 10:03:54 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C66B82D78; Fri, 11 Aug 2023 07:03:54 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5B1E667368; Fri, 11 Aug 2023 14:03:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8848AC433C7; Fri, 11 Aug 2023 14:03:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691762633; bh=i4a8p6VpCCZVTYFHFo1ukva43aBF5vKJz8iLhLj/cfg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fQhabiPgoDUxJ1/WWsaCqFwAFlRKGjtZOKWy+Hr6jzFAaijzQsgKR1NkpBdkrWTFy UmJuel14wtHaYvv4BeorNZvGbuaD2AY4t0uZ9MyV2f7Vz34J/J6pAfqHXEe8Oj0ebv DnaHBlwRha57WdyDZFoSi9ZZBDbaxewYpFxkPatifaXKKu0WRWwL6q6mZwfUkVWj0U SLuA83rQ3AqECXGkwvJ/htSWU00oTRQT1Cnv3AD75e2mZC4sj3IL2ke3PTBXnT3sEd XALwAtFlALoGMt4H2H+CXBp4ExaDj9HSUQJm7AidPNuEAH9nYz5ccHQcanGSes8Hws 2J51cHR3rxSLg== From: Arnd Bergmann To: Masahiro Yamada Cc: Arnd Bergmann , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , Guenter Roeck , Lee Jones , Stephen Rothwell , linux-kbuild@vger.kernel.org, linux-arch@vger.kernel.org Subject: [PATCH 6/9] extrawarn: move -Wrestrict into W=1 warnings Date: Fri, 11 Aug 2023 16:03:24 +0200 Message-Id: <20230811140327.3754597-7-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230811140327.3754597-1-arnd@kernel.org> References: <20230811140327.3754597-1-arnd@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org From: Arnd Bergmann There are few of these, so enable them whenever W=1 is enabled. Signed-off-by: Arnd Bergmann --- scripts/Makefile.extrawarn | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn index ec528972371fa..8abe90270b335 100644 --- a/scripts/Makefile.extrawarn +++ b/scripts/Makefile.extrawarn @@ -54,9 +54,6 @@ KBUILD_CFLAGS += -Wno-pointer-sign # globally built with -Wcast-function-type. KBUILD_CFLAGS += $(call cc-option, -Wcast-function-type) -# Another good warning that we'll want to enable eventually -KBUILD_CFLAGS += $(call cc-disable-warning, restrict) - # The allocators already balk at large sizes, so silence the compiler # warnings for bounds checks involving those possible values. While # -Wno-alloc-size-larger-than would normally be used here, earlier versions @@ -99,6 +96,7 @@ 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 @@ -120,6 +118,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, format-overflow) KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation) From patchwork Fri Aug 11 14:03:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 13350932 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90C12C04A94 for ; Fri, 11 Aug 2023 14:04:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232559AbjHKOEA (ORCPT ); Fri, 11 Aug 2023 10:04:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235761AbjHKOD7 (ORCPT ); Fri, 11 Aug 2023 10:03:59 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E7F930DB; Fri, 11 Aug 2023 07:03:57 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1C24B6735E; Fri, 11 Aug 2023 14:03:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4017EC433C8; Fri, 11 Aug 2023 14:03:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691762636; bh=GmdrJTF67LqqSDhqJe2Ev839NzUGDS7J99o002Hoczw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I9C+58jE/avwtKmSfjqOdvA2khscq1q/teSn07CaTH6PyhLjoRB2wkfe/U3mkZnRg ImSQvQoNp0wMlKDwOr2UIqWkaDYbggRiG+vqbbz33C91Byk8dtrPyEQh8sJKByAN2c zuOrurOHfKWVj9ioh818xRLy9tPTtWWFlyKXQs8SCkYS3s3Lw8Ty/5NbrVpNWgKlC1 CqvjlUJCPP0UZFZKCvqad7+KRz7CvuA6J+5yEub7JJ1hh0r8gG4U9hjlvc9kLjSTLP CfPHYS+cIIKyPPdnCGFtO/0yIyo/eVSp4VxCQENiRwOIT1kH5NClwRUAOSdMGMRw/D GDQbfwDskPPcg== From: Arnd Bergmann To: Masahiro Yamada Cc: Arnd Bergmann , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , Guenter Roeck , Lee Jones , Stephen Rothwell , linux-kbuild@vger.kernel.org, linux-arch@vger.kernel.org Subject: [PATCH 7/9] extrawarn: do not disable -Wmain at W=1 level Date: Fri, 11 Aug 2023 16:03:25 +0200 Message-Id: <20230811140327.3754597-8-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230811140327.3754597-1-arnd@kernel.org> References: <20230811140327.3754597-1-arnd@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org From: Arnd Bergmann There is only one function in architecture independent code that has a local variable named main(), and it seems fine to warn about this at the W=1 level, so move it there to declutter the normal command line slightly. Signed-off-by: Arnd Bergmann --- scripts/Makefile.extrawarn | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn index 8abe90270b335..8fd76da9042f8 100644 --- a/scripts/Makefile.extrawarn +++ b/scripts/Makefile.extrawarn @@ -29,10 +29,6 @@ KBUILD_CFLAGS-$(CONFIG_CC_NO_ARRAY_BOUNDS) += -Wno-array-bounds ifdef CONFIG_CC_IS_CLANG # The kernel builds with '-std=gnu11' so use of GNU extensions is acceptable. KBUILD_CFLAGS += -Wno-gnu -else - -# gcc inanely warns about local variables called 'main' -KBUILD_CFLAGS += -Wno-main endif # These warnings generated too much noise in a regular build. @@ -143,6 +139,8 @@ 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) +else +KBUILD_CFLAGS += -Wno-main endif endif From patchwork Fri Aug 11 14:03:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 13350933 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9AC78C001DE for ; Fri, 11 Aug 2023 14:04:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235909AbjHKOEG (ORCPT ); Fri, 11 Aug 2023 10:04:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235805AbjHKOEF (ORCPT ); Fri, 11 Aug 2023 10:04:05 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B05710E4; Fri, 11 Aug 2023 07:04:00 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C408D67368; Fri, 11 Aug 2023 14:03:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F368CC433C9; Fri, 11 Aug 2023 14:03:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691762639; bh=1bMXyvoJWAnWRA0OT2v/oEuLQrJAr/mI1Zeo9rXeZ1w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JFg49Hu5DNwyNGwn6+X5k4CSMpFKXl6HdAY+m8LjwiTMyHb+RyUGus60FLoEucFF+ ke+hqsgNP3iphbK7yObfbhFB7/1yyR/e1WP1SlSE9yIpfymznvgV65vP9SkuFDnoat EHoh+buXPp4/etPuIK918VZRX4tV4CMJW/MNmX/Yqy49wB8zoLPrU74VlTBjK2f49E XqAQ1VMkJZmZp+lq7e/hKsKwqI3NQRjChWacO2SZlhtBeJ8050mvCpA2WSUtQcazJw K4Z4LJPX36Pd5y81rtsVicZuJtBj4nsHMUHtBY9R0Z39m3hu9fsO1LoxXOhnNDk68r 0CUTOvNcxLz2w== From: Arnd Bergmann To: Masahiro Yamada Cc: Arnd Bergmann , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , Guenter Roeck , Lee Jones , Stephen Rothwell , linux-kbuild@vger.kernel.org, linux-arch@vger.kernel.org Subject: [PATCH 8/9] extrawarn: enable more warnings in W=2 Date: Fri, 11 Aug 2023 16:03:26 +0200 Message-Id: <20230811140327.3754597-9-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230811140327.3754597-1-arnd@kernel.org> References: <20230811140327.3754597-1-arnd@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org From: Arnd Bergmann These four warning options are always disabled, but actually meet the criteria for W=2, as they are sometimes useful and not prohibitively noisy: -Wformat-security -Wframe-address -Waddress-of-packed-member -Wtrigraphs Signed-off-by: Arnd Bergmann --- scripts/Makefile.extrawarn | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn index 8fd76da9042f8..1e6822b22c260 100644 --- a/scripts/Makefile.extrawarn +++ b/scripts/Makefile.extrawarn @@ -13,10 +13,6 @@ KBUILD_CFLAGS += -Werror=implicit-function-declaration KBUILD_CFLAGS += -Werror=implicit-int KBUILD_CFLAGS += -Werror=return-type KBUILD_CFLAGS += -Werror=strict-prototypes -KBUILD_CFLAGS += -Wno-format-security -KBUILD_CFLAGS += -Wno-trigraphs -KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,) -KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member) ifneq ($(CONFIG_FRAME_WARN),0) KBUILD_CFLAGS += -Wframe-larger-than=$(CONFIG_FRAME_WARN) @@ -157,6 +153,10 @@ KBUILD_CFLAGS += -Wmissing-field-initializers KBUILD_CFLAGS += -Wtype-limits KBUILD_CFLAGS += $(call cc-option, -Wmaybe-uninitialized) KBUILD_CFLAGS += $(call cc-option, -Wunused-macros) +KBUILD_CFLAGS += $(call cc-option, -Waddress-of-packed-member) +KBUILD_CFLAGS += $(call cc-option, -Wframe-address) +KBUILD_CFLAGS += -Wformat-security +KBUILD_CFLAGS += -Wtrigraphs ifdef CONFIG_CC_IS_CLANG KBUILD_CFLAGS += -Winitializer-overrides @@ -169,6 +169,10 @@ else # The following turn off the warnings enabled by -Wextra KBUILD_CFLAGS += -Wno-missing-field-initializers KBUILD_CFLAGS += -Wno-type-limits +KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member) +KBUILD_CFLAGS += $(call cc-disable-warning, frame-address) +KBUILD_CFLAGS += -Wno-format-security +KBUILD_CFLAGS += -Wno-trigraphs ifdef CONFIG_CC_IS_CLANG KBUILD_CFLAGS += -Wno-initializer-overrides From patchwork Fri Aug 11 14:03:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 13350934 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD8DBC0015E for ; Fri, 11 Aug 2023 14:04:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235945AbjHKOEK (ORCPT ); Fri, 11 Aug 2023 10:04:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235829AbjHKOEF (ORCPT ); Fri, 11 Aug 2023 10:04:05 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E69432D78; Fri, 11 Aug 2023 07:04:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7B6076735E; Fri, 11 Aug 2023 14:04:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A5FE0C433CC; Fri, 11 Aug 2023 14:03:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691762641; bh=DhAl8HXBxHnrafao1NZ+4HVKfS5+Q+yRkDdvMwW757U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UBTE4peUFMl8fwF6tR3VJPzYHvfo3jb8bZ+yRNVQnXQGLDZEN1Swf9sM0erOcJR0y PpmV8zhkk6ArFJDNH9zv+TL3rp8FIZHMSU/X8x2JBBr/cYfMNkTELTNIQguT2zvqWl 0QVL9k4OJz0DhHtiWIVw/t1+epfnq0QthNNrpuUoDJqmxrnHHYtRjLUCF+p4SDc7zH d2fx76ieptOkXuqscbtuiA777WspE0SMX8JKMoeN4I++xaSK8rGVcwfqQ/rktBMvKh t6bmHPI0qTDn99Akt9Q+3xJxoeyMbXStVufQCfYyf7RG8iJ4u0PWK8m0+hH3CKe2ep PPWw7tnoLYRrQ== From: Arnd Bergmann To: Masahiro Yamada Cc: Arnd Bergmann , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , Guenter Roeck , Lee Jones , Stephen Rothwell , linux-kbuild@vger.kernel.org, linux-arch@vger.kernel.org Subject: [PATCH 9/9] [RFC] extrawarn: enable more W=1 warnings by default Date: Fri, 11 Aug 2023 16:03:27 +0200 Message-Id: <20230811140327.3754597-10-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230811140327.3754597-1-arnd@kernel.org> References: <20230811140327.3754597-1-arnd@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org From: Arnd Bergmann 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 --- scripts/Makefile.extrawarn | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) 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