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]

 



From: Nathan Chancellor
> Sent: 05 March 2024 22:13
...
>   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.

I'm not sure what is being done to avoid this warning.
(Apart from not using enum to define related integer constants.)
Until the compilers get even more clever^Wstupid perhaps the
simplest way is to just add '+ 0' to one of the enum values.

In code terms it is much safer than any cast.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)




[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