|
| 1 | +From 75b5ab134bb5f657ef7979a59106dce0657e8d87 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Nathan Chancellor < [email protected]> |
| 3 | +Date: Tue, 5 Mar 2024 15:12:47 -0700 |
| 4 | +Subject: kbuild: Move -Wenum-{compare-conditional,enum-conversion} into W=1 |
| 5 | + |
| 6 | +Clang enables -Wenum-enum-conversion and -Wenum-compare-conditional |
| 7 | +under -Wenum-conversion. A recent change in Clang strengthened these |
| 8 | +warnings and they appear frequently in common builds, primarily due to |
| 9 | +several instances in common headers but there are quite a few drivers |
| 10 | +that have individual instances as well. |
| 11 | + |
| 12 | + include/linux/vmstat.h:508:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion] |
| 13 | + 508 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS + |
| 14 | + | ~~~~~~~~~~~~~~~~~~~~~ ^ |
| 15 | + 509 | item]; |
| 16 | + | ~~~~ |
| 17 | + |
| 18 | + drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c:955:24: warning: conditional expression between different enumeration types ('enum iwl_mac_beacon_flags' and 'enum iwl_mac_beacon_flags_v1') [-Wenum-compare-conditional] |
| 19 | + 955 | flags |= is_new_rate ? IWL_MAC_BEACON_CCK |
| 20 | + | ^ ~~~~~~~~~~~~~~~~~~ |
| 21 | + 956 | : IWL_MAC_BEACON_CCK_V1; |
| 22 | + | ~~~~~~~~~~~~~~~~~~~~~ |
| 23 | + drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c:1120:21: warning: conditional expression between different enumeration types ('enum iwl_mac_beacon_flags' and 'enum iwl_mac_beacon_flags_v1') [-Wenum-compare-conditional] |
| 24 | + 1120 | 0) > 10 ? |
| 25 | + | ^ |
| 26 | + 1121 | IWL_MAC_BEACON_FILS : |
| 27 | + | ~~~~~~~~~~~~~~~~~~~ |
| 28 | + 1122 | IWL_MAC_BEACON_FILS_V1; |
| 29 | + | ~~~~~~~~~~~~~~~~~~~~~~ |
| 30 | + |
| 31 | +Doing arithmetic between or returning two different types of enums could |
| 32 | +be a bug, so each of the instance of the warning needs to be evaluated. |
| 33 | +Unfortunately, as mentioned above, there are many instances of this |
| 34 | +warning in many different configurations, which can break the build when |
| 35 | +CONFIG_WERROR is enabled. |
| 36 | + |
| 37 | +To avoid introducing new instances of the warnings while cleaning up the |
| 38 | +disruption for the majority of users, disable these warnings for the |
| 39 | +default build while leaving them on for W=1 builds. |
| 40 | + |
| 41 | + |
| 42 | +Closes: https://github.com/ClangBuiltLinux/linux/issues/2002 |
| 43 | +Link: https://github.com/llvm/llvm-project/commit/8c2ae42b3e1c6aa7c18f873edcebff7c0b45a37e |
| 44 | +Acked-by: Yonghong Song < [email protected]> |
| 45 | +Signed-off-by: Nathan Chancellor < [email protected]> |
| 46 | +Acked-by: Arnd Bergmann < [email protected]> |
| 47 | +Signed-off-by: Masahiro Yamada < [email protected]> |
| 48 | +--- |
| 49 | +Link: https://git.kernel.org/masahiroy/linux-kbuild/c/75b5ab134bb5f657ef7979a59106dce0657e8d87 |
| 50 | +--- |
| 51 | + scripts/Makefile.extrawarn | 2 ++ |
| 52 | + 1 file changed, 2 insertions(+) |
| 53 | + |
| 54 | +diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn |
| 55 | +index a9e552a1e9105b..2f25a1de129d10 100644 |
| 56 | +--- a/scripts/Makefile.extrawarn |
| 57 | ++++ b/scripts/Makefile.extrawarn |
| 58 | +@@ -132,6 +132,8 @@ KBUILD_CFLAGS += $(call cc-disable-warning, pointer-to-enum-cast) |
| 59 | + KBUILD_CFLAGS += -Wno-tautological-constant-out-of-range-compare |
| 60 | + KBUILD_CFLAGS += $(call cc-disable-warning, unaligned-access) |
| 61 | + KBUILD_CFLAGS += $(call cc-disable-warning, cast-function-type-strict) |
| 62 | ++KBUILD_CFLAGS += -Wno-enum-compare-conditional |
| 63 | ++KBUILD_CFLAGS += -Wno-enum-enum-conversion |
| 64 | + endif |
| 65 | + |
| 66 | + endif |
| 67 | +-- |
| 68 | +cgit 1.2.3-korg |
| 69 | + |
0 commit comments