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