Skip to contentSkip to conversation

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

DISCUSSION Julia Lawall 2 participants 3 messages Oct 13, 2017 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 201710132012.kptCgENA%[email protected]

#1 lore raw

It seems that the then and else branches of the conditions on lines 920 and 932 are the same.

julia

Quoted 71 lines · kbuild test robot

CC: [email protected]
CC: [email protected]
TO: Larry Finger <[email protected]>
CC: "Greg Kroah-Hartman" <[email protected]>

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

Quoted 1 line
Quoted 1 line

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 <[email protected]> :::::: CC: Greg Kroah-Hartman <[email protected]>

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

#2 lore raw

Julia,

Quoted 2 lines · Julia Lawall

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

Quoted 74 lines · kbuild test robot
Quoted 72 lines

CC: [email protected]
CC: [email protected]
TO: Larry Finger <[email protected]>
CC: "Greg Kroah-Hartman" <[email protected]>

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

Quoted 1 line
Quoted 1 line

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 <[email protected]> :::::: CC: Greg Kroah-Hartman <[email protected]>

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

#3 lore raw
Quoted 9 lines · Larry Finger

Julia,

Quoted 2 lines · Julia Lawall

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.

OK, thanks. The realtek code has a surprisingly large number of these kinds of problems, for example, the following from (drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c):

		if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
		    (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
			btc8723b2ant_sw_mechanism(btcoexist, true, false,
						  false, false);
		} else {
			btc8723b2ant_sw_mechanism(btcoexist, true, false,
						  false, false);
		}

I wondered if the code is generated, and the generator has a policy of just doing the last "then" branch if all of the known tests fail.

I could send a complete list of such issues, if they are of interest.

julia

Quoted 111 lines

Thanks,

Larry

Quoted 104 lines · kbuild test robot
Quoted 102 lines

CC: [email protected]
CC: [email protected]
TO: Larry Finger <[email protected]>
CC: "Greg Kroah-Hartman" <[email protected]>

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

Quoted 2 lines
Quoted 2 lines

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 <[email protected]> :::::: CC: Greg Kroah-Hartman <[email protected]>

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