Re: [PATCH v2] kbuild: Move -Wenum-{compare-conditional,enum-conversion} into W=1

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Mar 6, 2024 at 7:12 AM Nathan Chancellor <nathan@xxxxxxxxxx> wrote:
>
> Clang enables -Wenum-enum-conversion and -Wenum-compare-conditional
> under -Wenum-conversion. A recent change in Clang strengthened these
> warnings and they appear frequently in common builds, primarily due to
> several instances in common headers but there are quite a few drivers
> that have individual instances as well.
>
>   include/linux/vmstat.h:508:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
>     508 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
>         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
>     509 |                            item];
>         |                            ~~~~
>
>   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]
>     955 |                 flags |= is_new_rate ? IWL_MAC_BEACON_CCK
>         |                                      ^ ~~~~~~~~~~~~~~~~~~
>     956 |                           : IWL_MAC_BEACON_CCK_V1;
>         |                             ~~~~~~~~~~~~~~~~~~~~~
>   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]
>    1120 |                                                0) > 10 ?
>         |                                                        ^
>    1121 |                         IWL_MAC_BEACON_FILS :
>         |                         ~~~~~~~~~~~~~~~~~~~
>    1122 |                         IWL_MAC_BEACON_FILS_V1;
>         |                         ~~~~~~~~~~~~~~~~~~~~~~
>
> Doing arithmetic between or returning two different types of enums could
> be a bug, so each of the instance of the warning needs to be evaluated.
> Unfortunately, as mentioned above, there are many instances of this
> warning in many different configurations, which can break the build when
> CONFIG_WERROR is enabled.
>
> To avoid introducing new instances of the warnings while cleaning up the
> disruption for the majority of users, disable these warnings for the
> default build while leaving them on for W=1 builds.
>
> Cc: stable@xxxxxxxxxxxxxxx
> Closes: https://github.com/ClangBuiltLinux/linux/issues/2002
> Link: https://github.com/llvm/llvm-project/commit/8c2ae42b3e1c6aa7c18f873edcebff7c0b45a37e
> Acked-by: Yonghong Song <yonghong.song@xxxxxxxxx>
> Signed-off-by: Nathan Chancellor <nathan@xxxxxxxxxx>
> ---
> Changes in v2:
> - Only disable the warning for the default build, leave it on for W=1 (Arnd)
> - Add Yonghong's ack, as the warning is still disabled for the default
>   build.
> - Link to v1: https://lore.kernel.org/r/20240305-disable-extra-clang-enum-warnings-v1-1-6a93ef3d35ff@xxxxxxxxxx


Applied to linux-kbuild.
Thanks.




-- 
Best Regards
Masahiro Yamada





[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux