wifi: rtw89: fix -Wenum-compare-conditional warnings
authorArnd Bergmann <arnd@arndb.de>
Fri, 18 Oct 2024 15:23:07 +0000 (15:23 +0000)
committerPing-Ke Shih <pkshih@realtek.com>
Fri, 25 Oct 2024 02:19:16 +0000 (10:19 +0800)
commitc67d7c7f4151fe863c89e4fb6a3665a4f1e58b28
treec872dfa15df1e63d1373164e43051f7cec615812
parent142c062d58145c8826640d024e1dbe7c8c9a2b00
wifi: rtw89: fix -Wenum-compare-conditional warnings

This is one of three drivers that trigger -Wenum-compare-conditional warnings
with clang:

drivers/net/wireless/realtek/rtw89/core.c:1806:14: error: conditional expression between different enumeration types ('enum nl80211_eht_gi' and 'enum nl80211_he_gi') [-Werror,-Wenum-compare-conditional]
 1806 |                 return eht ? NL80211_RATE_INFO_EHT_GI_0_8 :
      |                            ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1807 |                              NL80211_RATE_INFO_HE_GI_0_8;
      |                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/wireless/realtek/rtw89/core.c:1810:14: error: conditional expression between different enumeration types ('enum nl80211_eht_gi' and 'enum nl80211_he_gi') [-Werror,-Wenum-compare-conditional]
 1810 |                 return eht ? NL80211_RATE_INFO_EHT_GI_1_6 :
      |                            ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1811 |                              NL80211_RATE_INFO_HE_GI_1_6;
      |                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/wireless/realtek/rtw89/core.c:1813:14: error: conditional expression between different enumeration types ('enum nl80211_eht_gi' and 'enum nl80211_he_gi') [-Werror,-Wenum-compare-conditional]
 1813 |                 return eht ? NL80211_RATE_INFO_EHT_GI_3_2 :
      |                            ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1814 |                              NL80211_RATE_INFO_HE_GI_3_2;
      |                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/wireless/realtek/rtw89/core.c:1818:15: error: conditional expression between different enumeration types ('enum nl80211_eht_gi' and 'enum nl80211_he_gi') [-Werror,-Wenum-compare-conditional]
 1818 |                         return eht ? NL80211_RATE_INFO_EHT_GI_3_2 :
      |                                    ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1819 |                                      NL80211_RATE_INFO_HE_GI_3_2;
      |                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~

In this case, all four warnings can be easily avoided by splitting the
function into two separate ones, in a way that helps readability as well,
at the expense of a few extra source lines.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20241018152311.4023979-1-arnd@kernel.org
drivers/net/wireless/realtek/rtw89/core.c