rtlwifi: refactor code in halbtcoutsrc module
PATCH 1/1 rtlwifi: refactor code in halbtcoutsrc module
Function halbtc_get_wifi_rssi always returns rtlpriv->dm.undec_sm_pwdb. So this function can be removed and the value of rtlpriv->dm.undec_sm_pwdb assigned to *s32_tmp directly.
This issue was first reported by Coverity as "identical code for different branches" in function halbtc_get_wifi_rssi.
Addresses-Coverity-ID: 1226793
---
This code was reported by Coverity and it was tested by compilation only. Chances are this may be a copy/paste error in function halbtc_get_wifi_rssi. Please, verify.
Also, notice this code has been there since 2014.
.../net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)
drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c +1 -12
@@ -373,17 +373,6 @@ u32 halbtc_get_wifi_link_status(struct btc_coexist *btcoexist)return ret_val; } -static s32 halbtc_get_wifi_rssi (struct rtl_priv *rtlpriv) -{ -int undec_sm_pwdb =0 ; - -if (rtlpriv->mac80211.link_state >=MAC80211_LINKED ) - undec_sm_pwdb = rtlpriv->dm.undec_sm_pwdb; -else /* associated entry pwdb */ - undec_sm_pwdb = rtlpriv->dm.undec_sm_pwdb; -return undec_sm_pwdb; -} -static bool halbtc_get (void *void_btcoexist,u8 get_type,void *out_buf) {struct btc_coexist *btcoexist = (struct btc_coexist *)void_btcoexist;
@@ -479,7 +468,7 @@ static bool halbtc_get(void *void_btcoexist, u8 get_type, void *out_buf) *bool_tmp = false;break ;case BTC_GET_S4_WIFI_RSSI : - *s32_tmp =halbtc_get_wifi_rssi (rtlpriv); + *s32_tmp = rtlpriv->dm.undec_sm_pwdb;break ;case BTC_GET_S4_HS_RSSI : *s32_tmp =0 ;
Signature · 1 line
2.5.0
Quoted 7 lines · Gustavo A. R. Silva
Function
halbtc_get_wifi_rssialways returnsrtlpriv->dm.undec_sm_pwdb. So this function can be removed and the value ofrtlpriv->dm.undec_sm_pwdbassigned to*s32_tmpdirectly.This issue was first reported by Coverity as "identical code for different branches" in function
halbtc_get_wifi_rssi.
Quoted 7 lines
Addresses-Coverity-ID: 1226793
Signed-off-by Gustavo A. R. Silva <[email protected]>---
This code was reported by Coverity and it was tested by compilation only. Chances are this may be a copy/paste error in functionhalbtc_get_wifi_rssi. Please, verify.
Also, notice this code has been there since 2014.
The value of *s32_tmp is not dependent on the link state, thus this patch is correct, but I request that it be changed. Future developments will modify halbtc_get_wifi_rssi() making it more complicated and not as easily inlined as this patch. In short, if you remove it here, we will have to add it later.
Thanks,
Larrt
Quoted 36 lines
.../net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c +1
-12@@ -373,17 +373,6 @@ u32 halbtc_get_wifi_link_status(struct btc_coexist *btcoexist)return ret_val; } -static s32 halbtc_get_wifi_rssi (struct rtl_priv *rtlpriv) -{ -int undec_sm_pwdb =0 ; - -if (rtlpriv->mac80211.link_state >=MAC80211_LINKED ) - undec_sm_pwdb = rtlpriv->dm.undec_sm_pwdb; -else /* associated entry pwdb */ - undec_sm_pwdb = rtlpriv->dm.undec_sm_pwdb; -return undec_sm_pwdb; -} -static bool halbtc_get (void *void_btcoexist,u8 get_type,void *out_buf) {struct btc_coexist *btcoexist = (struct btc_coexist *)void_btcoexist;@@ -479,7 +468,7 @@ static bool halbtc_get(void *void_btcoexist, u8 get_type, void *out_buf) *bool_tmp = false;break ;case BTC_GET_S4_WIFI_RSSI : - *s32_tmp =halbtc_get_wifi_rssi (rtlpriv); + *s32_tmp = rtlpriv->dm.undec_sm_pwdb;break ;case BTC_GET_S4_HS_RSSI : *s32_tmp =0 ;