Re: drivers/staging/rtlwifi/base.c:920:7-9: WARNING: possible condition with no effect (if == else)

From: Larry Finger
Date: Fri Oct 13 2017 - 14:11:27 EST


Julia,

On 10/13/2017 08:55 AM, Julia Lawall wrote:
It seems that the then and else branches of the conditions on lines 920
and 932 are the same.

I think line 923 should be using RTL_RC_VHT_RATE_2SS_MCS8 rather than RTL_RC_VHT_RATE_2SS_MCS9, but I have sent an inquiry to my contact at Realtek to check.

Thanks,

Larry

On Fri, 13 Oct 2017, kbuild test robot wrote:

CC: kbuild-all@xxxxxx
CC: linux-kernel@xxxxxxxxxxxxxxx
TO: Larry Finger <Larry.Finger@xxxxxxxxxxxx>
CC: "Greg Kroah-Hartman" <gregkh@xxxxxxxxxxxxxxxxxxx>

tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 3d7882769b5dc929690f96e0c318c29b97f51018
commit: 5b5ab4cb5cda824ef59e0511ac5d585f35f1a1a6 staging: r8822be: Add Makefiles and Kconfig for new driver
date: 8 weeks ago
:::::: branch date: 12 hours ago
:::::: commit date: 8 weeks ago

drivers/staging/rtlwifi/base.c:920:7-9: WARNING: possible condition with no effect (if == else)
drivers/staging/rtlwifi/base.c:932:7-9: WARNING: possible condition with no effect (if == else)

# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5b5ab4cb5cda824ef59e0511ac5d585f35f1a1a6
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git remote update linus
git checkout 5b5ab4cb5cda824ef59e0511ac5d585f35f1a1a6
vim +920 drivers/staging/rtlwifi/base.c

56bde846 Ping-Ke Shih 2017-08-17 905
56bde846 Ping-Ke Shih 2017-08-17 906 static u8 _rtl_get_vht_highest_n_rate(struct ieee80211_hw *hw,
56bde846 Ping-Ke Shih 2017-08-17 907 struct ieee80211_sta *sta)
56bde846 Ping-Ke Shih 2017-08-17 908 {
56bde846 Ping-Ke Shih 2017-08-17 909 struct rtl_priv *rtlpriv = rtl_priv(hw);
56bde846 Ping-Ke Shih 2017-08-17 910 struct rtl_phy *rtlphy = &rtlpriv->phy;
56bde846 Ping-Ke Shih 2017-08-17 911 u8 hw_rate;
56bde846 Ping-Ke Shih 2017-08-17 912 u16 tx_mcs_map = le16_to_cpu(sta->vht_cap.vht_mcs.tx_mcs_map);
56bde846 Ping-Ke Shih 2017-08-17 913
56bde846 Ping-Ke Shih 2017-08-17 914 if ((get_rf_type(rtlphy) == RF_2T2R) &&
56bde846 Ping-Ke Shih 2017-08-17 915 (tx_mcs_map & 0x000c) != 0x000c) {
56bde846 Ping-Ke Shih 2017-08-17 916 if ((tx_mcs_map & 0x000c) >> 2 ==
56bde846 Ping-Ke Shih 2017-08-17 917 IEEE80211_VHT_MCS_SUPPORT_0_7)
56bde846 Ping-Ke Shih 2017-08-17 918 hw_rate =
56bde846 Ping-Ke Shih 2017-08-17 919 rtlpriv->cfg->maps[RTL_RC_VHT_RATE_2SS_MCS7];
56bde846 Ping-Ke Shih 2017-08-17 @920 else if ((tx_mcs_map & 0x000c) >> 2 ==
56bde846 Ping-Ke Shih 2017-08-17 921 IEEE80211_VHT_MCS_SUPPORT_0_8)
56bde846 Ping-Ke Shih 2017-08-17 922 hw_rate =
56bde846 Ping-Ke Shih 2017-08-17 923 rtlpriv->cfg->maps[RTL_RC_VHT_RATE_2SS_MCS9];
56bde846 Ping-Ke Shih 2017-08-17 924 else
56bde846 Ping-Ke Shih 2017-08-17 925 hw_rate =
56bde846 Ping-Ke Shih 2017-08-17 926 rtlpriv->cfg->maps[RTL_RC_VHT_RATE_2SS_MCS9];
56bde846 Ping-Ke Shih 2017-08-17 927 } else {
56bde846 Ping-Ke Shih 2017-08-17 928 if ((tx_mcs_map & 0x0003) ==
56bde846 Ping-Ke Shih 2017-08-17 929 IEEE80211_VHT_MCS_SUPPORT_0_7)
56bde846 Ping-Ke Shih 2017-08-17 930 hw_rate =
56bde846 Ping-Ke Shih 2017-08-17 931 rtlpriv->cfg->maps[RTL_RC_VHT_RATE_1SS_MCS7];
56bde846 Ping-Ke Shih 2017-08-17 932 else if ((tx_mcs_map & 0x0003) ==
56bde846 Ping-Ke Shih 2017-08-17 933 IEEE80211_VHT_MCS_SUPPORT_0_8)
56bde846 Ping-Ke Shih 2017-08-17 934 hw_rate =
56bde846 Ping-Ke Shih 2017-08-17 935 rtlpriv->cfg->maps[RTL_RC_VHT_RATE_1SS_MCS9];
56bde846 Ping-Ke Shih 2017-08-17 936 else
56bde846 Ping-Ke Shih 2017-08-17 937 hw_rate =
56bde846 Ping-Ke Shih 2017-08-17 938 rtlpriv->cfg->maps[RTL_RC_VHT_RATE_1SS_MCS9];
56bde846 Ping-Ke Shih 2017-08-17 939 }
56bde846 Ping-Ke Shih 2017-08-17 940
56bde846 Ping-Ke Shih 2017-08-17 941 return hw_rate;
56bde846 Ping-Ke Shih 2017-08-17 942 }
56bde846 Ping-Ke Shih 2017-08-17 943

:::::: The code at line 920 was first introduced by commit
:::::: 56bde846304ea05d5f8c8de0e3a42627a7a92be6 staging: r8822be: Add existing rtlwifi and rtl_pci parts for new driver

:::::: TO: Ping-Ke Shih <pkshih@xxxxxxxxxxx>
:::::: CC: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation