Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751843AbdHaPZf (ORCPT ); Thu, 31 Aug 2017 11:25:35 -0400 Received: from mail-oi0-f67.google.com ([209.85.218.67]:38806 "EHLO mail-oi0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751040AbdHaPZc (ORCPT ); Thu, 31 Aug 2017 11:25:32 -0400 X-Google-Smtp-Source: ADKCNb4uaGfnM9zczUB1k+TNhQxqyasWKGL4NMaEWHeZu8Y+DaBWpPKJyQI9+Pl2KVIutjBEs7V6JQ== Subject: Re: [PATCH] rtlwifi: refactor code in halbtcoutsrc module To: "Gustavo A. R. Silva" , Chaoming Li , Kalle Valo Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <20170830164602.GA16413@embeddedgus> From: Larry Finger Message-ID: <08aeadde-8a44-c49f-bc64-5b91226d4cec@lwfinger.net> Date: Thu, 31 Aug 2017 10:25:30 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20170830164602.GA16413@embeddedgus> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2390 Lines: 61 On 08/30/2017 11:46 AM, Gustavo A. R. Silva wrote: > 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 > Signed-off-by: Gustavo A. R. Silva > --- > 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. 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 > > .../net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c | 13 +------------ > 1 file changed, 1 insertion(+), 12 deletions(-) > > diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c > index c1eacd8..2a47b97 100644 > --- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c > +++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c > @@ -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; >