remove unused code and simplify if-else blocks
cover remove unused code and simplify if-else blocks
This series of patches removes dead code hidden behind unused ifdefs and simplifies if-else blocks to improve readability.
Andrei Khomenkov (9):
staging: rtl8723bs: remove unused DBG_FIXED_CHAN code
staging: rtl8723bs: remove unused DBG_RX_DUMP_EAP code
staging: rtl8723bs: remove unused CONSISTENT_PN_ORDER code
staging: rtl8723bs: remove unused DBG_CH_SWITCH code
staging: rtl8723bs: remove unused REMOVE_PACK code
staging: rtl8723bs: remove unused RTW_DVOBJ_CHIP_HW_TYPE code
staging: rtl8723bs: remove unused RTW_MLME_EXT_C_ code
staging: rtl8723bs: remove commented out code in rtw_mlme_ext.c
staging: rtl8723bs: simplify if-else blocks in rtw_mlme_ext.c
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 28 ++++--------------- drivers/staging/rtl8723bs/core/rtw_recv.c | 11 -------- drivers/staging/rtl8723bs/core/rtw_security.c | 10 ------- .../staging/rtl8723bs/core/rtw_wlan_util.c | 26 ----------------- drivers/staging/rtl8723bs/hal/odm.h | 4 --- drivers/staging/rtl8723bs/include/drv_types.h | 3 -- .../staging/rtl8723bs/include/rtw_mlme_ext.h | 9 ------ 7 files changed, 5 insertions(+), 86 deletions(-)
Signature · 1 line
2.47.3
PATCH 1/9 staging: rtl8723bs: remove unused DBG_FIXED_CHAN code
Remove the DBG_FIXED_CHAN code since it is not used as the macro is not defined anywhere.
--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 14 -------------- drivers/staging/rtl8723bs/include/rtw_mlme_ext.h | 4 ---- 2 files changed, 18 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +0 -14
@@ -398,10 +398,6 @@ void init_mlme_ext_priv(struct adapter *padapter) pmlmeext->chan_scan_time =SURVEY_TO ; pmlmeext->mlmeext_init = true; pmlmeext->active_keep_alive_check = true; - -#ifdef DBG_FIXED_CHAN - pmlmeext->fixed_chan =0xFF ; -#endif }void free_mlme_ext_priv (struct mlme_ext_priv *pmlmeext)
@@ -3750,18 +3746,8 @@ void site_survey(struct adapter *padapter)/* val8 |= 0x0f; */ /* rtw_hal_set_hwreg(padapter, HW_VAR_TXPAUSE, (u8 *)(&val8)); */ if (pmlmeext->sitesurvey_res.channel_idx ==0 ) { -#ifdef DBG_FIXED_CHAN -if (pmlmeext->fixed_chan !=0xff ) -set_channel_bwmode (padapter, pmlmeext->fixed_chan,HAL_PRIME_CHNL_OFFSET_DONT_CARE ,CHANNEL_WIDTH_20 ); - else -#endif set_channel_bwmode (padapter, survey_channel,HAL_PRIME_CHNL_OFFSET_DONT_CARE ,CHANNEL_WIDTH_20 ); }else { -#ifdef DBG_FIXED_CHAN -if (pmlmeext->fixed_chan !=0xff ) -r8723bs_select_channel (padapter, pmlmeext->fixed_chan); - else -#endif r8723bs_select_channel (padapter, survey_channel); }
drivers/staging/rtl8723bs/include/rtw_mlme_ext.h +0 -4
@@ -416,10 +416,6 @@ struct mlme_ext_priv {u16 action_public_rxseq;u8 active_keep_alive_check; -#ifdef DBG_FIXED_CHAN -u8 fixed_chan; -#endif - };void init_mlme_default_rate_set (struct adapter *padapter);
Signature · 1 line
2.47.3
PATCH 2/9 staging: rtl8723bs: remove unused DBG_RX_DUMP_EAP code
In reply to Andrei KhomenkovRemove the DBG_RX_DUMP_EAP code since it is not used as the macro is not defined anywhere.
--- drivers/staging/rtl8723bs/core/rtw_recv.c | 11 ----------- 1 file changed, 11 deletions(-)
drivers/staging/rtl8723bs/core/rtw_recv.c +0 -11
@@ -1515,17 +1515,6 @@ static signed int validate_recv_frame(struct adapter *adapter, union recv_framestruct recv_priv *precvpriv = &adapter->recvpriv; precvpriv->rx_drop++; - }else if (retval == _SUCCESS) { -#ifdef DBG_RX_DUMP_EAP -u8 bDumpRxPkt; -u16 eth_type; - -/* dump eapol */ -rtw_hal_get_def_var (adapter,HAL_DEF_DBG_DUMP_RXPKT , &(bDumpRxPkt)); -/* get ether_type */ -memcpy (ð_type, ptr + pattrib->hdrlen + pattrib->iv_len +LLC_HEADER_LENGTH ,2 ); - eth_type =ntohs ((unsigned short ) eth_type); -#endif }break ;default :
Signature · 1 line
2.47.3
PATCH 3/9 staging: rtl8723bs: remove unused CONSISTENT_PN_ORDER code
In reply to Andrei KhomenkovRemove the CONSISTENT_PN_ORDER code since it is not used as the macro is not defined anywhere.
--- drivers/staging/rtl8723bs/core/rtw_security.c | 10 ---------- 1 file changed, 10 deletions(-)
drivers/staging/rtl8723bs/core/rtw_security.c +0 -10
@@ -649,13 +649,8 @@ static void construct_mic_iv(u8 *mic_iv,for (i =2 ; i <8 ; i++) mic_iv[i] = mpdu[i +8 ];/* mic_iv[2:7] = A2[0:5] = mpdu[10:15] */ -#ifdef CONSISTENT_PN_ORDER -for (i =8 ; i <14 ; i++) - mic_iv[i] = pn_vector[i -8 ];/* mic_iv[8:13] = PN[0:5] */ -#else for (i =8 ; i <14 ; i++) mic_iv[i] = pn_vector[13 - i];/* mic_iv[8:13] = PN[5:0] */ -#endif mic_iv[14 ] = (unsigned char )(payload_length /256 ); mic_iv[15 ] = (unsigned char )(payload_length %256 ); }
@@ -772,13 +767,8 @@ static void construct_ctr_preload(u8 *ctr_preload,for (i =2 ; i <8 ; i++) ctr_preload[i] = mpdu[i +8 ];/* ctr_preload[2:7] = A2[0:5] = mpdu[10:15] */ -#ifdef CONSISTENT_PN_ORDER -for (i =8 ; i <14 ; i++) - ctr_preload[i] = pn_vector[i -8 ];/* ctr_preload[8:13] = PN[0:5] */ -#else for (i =8 ; i <14 ; i++) ctr_preload[i] = pn_vector[13 - i];/* ctr_preload[8:13] = PN[5:0] */ -#endif ctr_preload[14 ] = (unsigned char )(c /256 );/* Ctr */ ctr_preload[15 ] = (unsigned char )(c %256 ); }
Signature · 1 line
2.47.3
PATCH 4/9 staging: rtl8723bs: remove unused DBG_CH_SWITCH code
In reply to Andrei KhomenkovRemove the DBG_CH_SWITCH code since it is not used as the macro is not defined anywhere.
--- .../staging/rtl8723bs/core/rtw_wlan_util.c | 26 ------------------- 1 file changed, 26 deletions(-)
drivers/staging/rtl8723bs/core/rtw_wlan_util.c +0 -26
@@ -254,36 +254,10 @@ inline u8 rtw_get_oper_ch(struct adapter *adapter)inline void rtw_set_oper_ch (struct adapter *adapter,u8 ch) { -#ifdef DBG_CH_SWITCH -const int len =128 ; -char msg[128 ] = {0 }; -int cnt =0 ; -int i =0 ; -#endif /* DBG_CH_SWITCH */ struct dvobj_priv *dvobj =adapter_to_dvobj (adapter);if (dvobj->oper_channel != ch) { dvobj->on_oper_ch_time = jiffies; - -#ifdef DBG_CH_SWITCH - cnt +=scnprintf (msg + cnt, len - cnt,"switch to ch %3u" , ch); - -for (i =0 ; i < dvobj->iface_nums; i++) { -struct adapter *iface = dvobj->padapters[i]; - - cnt +=scnprintf (msg + cnt, len - cnt," [%s:" ,ADPT_ARG (iface)); -if (iface->mlmeextpriv.cur_channel == ch) - cnt +=scnprintf (msg + cnt, len - cnt,"C" ); -else - cnt +=scnprintf (msg + cnt, len - cnt,"_" ); -if (iface->wdinfo.listen_channel == ch && !rtw_p2p_chk_state (&iface->wdinfo,P2P_STATE_NONE )) - cnt +=scnprintf (msg + cnt, len - cnt,"L" ); -else - cnt +=scnprintf (msg + cnt, len - cnt,"_" ); - cnt +=scnprintf (msg + cnt, len - cnt,"]" ); - } - -#endif /* DBG_CH_SWITCH */ } dvobj->oper_channel = ch;
Signature · 1 line
2.47.3
PATCH 5/9 staging: rtl8723bs: remove unused REMOVE_PACK code
In reply to Andrei KhomenkovRemove the REMOVE_PACK code since it is not used as the macro is not defined anywhere.
--- drivers/staging/rtl8723bs/hal/odm.h | 4 ---- 1 file changed, 4 deletions(-)
drivers/staging/rtl8723bs/hal/odm.h +0 -4
@@ -975,10 +975,6 @@ enum ODM_FW_Config_Type { CONFIG_FW_BT, }; -#ifdef REMOVE_PACK -#pragma pack() -#endif -/* include "odm_function.h" */ /* 3 =========================================================== */
Signature · 1 line
2.47.3
PATCH 6/9 staging: rtl8723bs: remove unused RTW_DVOBJ_CHIP_HW_TYPE code
In reply to Andrei KhomenkovRemove the RTW_DVOBJ_CHIP_HW_TYPE code since it is not used as the macro is not defined anywhere.
--- drivers/staging/rtl8723bs/include/drv_types.h | 3 --- 1 file changed, 3 deletions(-)
drivers/staging/rtl8723bs/include/drv_types.h +0 -3
@@ -258,9 +258,6 @@ static inline struct dvobj_priv *pwrctl_to_dvobj(struct pwrctrl_priv *pwrctl_pristatic inline struct device *dvobj_to_dev (struct dvobj_priv *dvobj) {/* todo: get interface type from dvobj and the return the dev accordingly */ -#ifdef RTW_DVOBJ_CHIP_HW_TYPE -#endif -return &dvobj->intf_data.func->dev; }
Signature · 1 line
2.47.3
PATCH 7/9 staging: rtl8723bs: remove unused RTW_MLME_EXT_C_ code
In reply to Andrei KhomenkovRemove the RTW_MLME_EXT_C_ code since it is not used as the macro is not defined anywhere.
--- drivers/staging/rtl8723bs/include/rtw_mlme_ext.h | 5 ----- 1 file changed, 5 deletions(-)
drivers/staging/rtl8723bs/include/rtw_mlme_ext.h +0 -5
@@ -705,9 +705,4 @@ enum {MAX_C2HEVT }; - -#ifdef _RTW_MLME_EXT_C_ - -#endif /* _RTL8192C_CMD_C_ */ -#endif
Signature · 1 line
2.47.3
PATCH 8/9 staging: rtl8723bs: remove commented out code in rtw_mlme_ext.c
In reply to Andrei KhomenkovRemove commented out code in the site_survey function as it is not used.
--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +0 -4
@@ -3741,10 +3741,6 @@ void site_survey(struct adapter *padapter) }if (survey_channel !=0 ) { -/* PAUSE 4-AC Queue when site_survey */ -/* rtw_hal_get_hwreg(padapter, HW_VAR_TXPAUSE, (u8 *)(&val8)); */ -/* val8 |= 0x0f; */ -/* rtw_hal_set_hwreg(padapter, HW_VAR_TXPAUSE, (u8 *)(&val8)); */ if (pmlmeext->sitesurvey_res.channel_idx ==0 ) {set_channel_bwmode (padapter, survey_channel,HAL_PRIME_CHNL_OFFSET_DONT_CARE ,CHANNEL_WIDTH_20 ); }else {
Signature · 1 line
2.47.3
Re: [PATCH 8/9] staging: rtl8723bs: remove commented out code in rtw_mlme_ext.c
Quoted 1 line · Andrei Khomenkov
Remove commented out code in the
site_surveyfunction as it is not used.
^^^^^^^^^^^
It is better to indicate function names with brackets: site_survey().
Quoted 24 lines
Signed-off-by Andrei Khomenkov <[email protected]>--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 4 ---- 1 file changed, 4 deletions(-)drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +0
-4@@ -3741,10 +3741,6 @@ void site_survey(struct adapter *padapter) }if (survey_channel !=0 ) { -/* PAUSE 4-AC Queue when site_survey */ -/* rtw_hal_get_hwreg(padapter, HW_VAR_TXPAUSE, (u8 *)(&val8)); */ -/* val8 |= 0x0f; */ -/* rtw_hal_set_hwreg(padapter, HW_VAR_TXPAUSE, (u8 *)(&val8)); */ if (pmlmeext->sitesurvey_res.channel_idx ==0 ) {set_channel_bwmode (padapter, survey_channel,HAL_PRIME_CHNL_OFFSET_DONT_CARE ,CHANNEL_WIDTH_20 ); }else {Signature · 1 line
2.47.3
Re: [PATCH 8/9] staging: rtl8723bs: remove commented out code in rtw_mlme_ext.c
Quoted 5 lines · Nikolay Kulikov
Quoted 1 line · Andrei Khomenkov
Remove commented out code in the
site_surveyfunction as it is not used.^^^^^^^^^^^It is better to indicate function names with brackets:
site_survey().
I feel like we can go mad with these sorts of review comments. I spent five minute reviewing all these patches and now I have to review them all again because of this really minor thing?
My trick for minor review comments, is that I try to find a real bug and I tie the minor thing to a major comment. "Sorry, you forgot to add clean up on error and also you forgot a comma in your commit message".
There a lot of minor stuff that I end up ignoring...
regards,
dan carpenter
Re: [PATCH 8/9] staging: rtl8723bs: remove commented out code in rtw_mlme_ext.c
Quoted 11 lines · Dan Carpenter
Quoted 5 lines · Nikolay Kulikov
Quoted 1 line · Andrei Khomenkov
Remove commented out code in the
site_surveyfunction as it is not used.^^^^^^^^^^^It is better to indicate function names with brackets:
site_survey().I feel like we can go mad with these sorts of review comments. I spent five minute reviewing all these patches and now I have to review them all again because of this really minor thing?
Quoted 6 lines
My trick for minor review comments, is that I try to find a real bug and I tie the minor thing to a major comment. "Sorry, you forgot to add clean up on error and also you forgot a comma in your commit message".
There a lot of minor stuff that I end up ignoring...
This is a really good trick, I will take note.
Thanks,
Nikolay
PATCH 9/9 staging: rtl8723bs: simplify if-else blocks in rtw_mlme_ext.c
In reply to Andrei KhomenkovFix indentation, remove unnecessary braces, and wrap long lines in if-else blocks inside the site_survey function.
--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +5 -5
@@ -3741,11 +3741,11 @@ void site_survey(struct adapter *padapter) }if (survey_channel !=0 ) { -if (pmlmeext->sitesurvey_res.channel_idx ==0 ) { -set_channel_bwmode (padapter, survey_channel,HAL_PRIME_CHNL_OFFSET_DONT_CARE ,CHANNEL_WIDTH_20 ); - }else { -r8723bs_select_channel (padapter, survey_channel); - } +if (pmlmeext->sitesurvey_res.channel_idx ==0 ) +set_channel_bwmode (padapter, survey_channel, +HAL_PRIME_CHNL_OFFSET_DONT_CARE ,CHANNEL_WIDTH_20 ); +else +r8723bs_select_channel (padapter, survey_channel);if (ScanType ==SCAN_ACTIVE ) {/* obey the channel plan setting... */ {
Signature · 1 line
2.47.3
Re: [PATCH 9/9] staging: rtl8723bs: simplify if-else blocks in rtw_mlme_ext.c
Quoted 2 lines · Andrei Khomenkov
Fix indentation, remove unnecessary braces, and wrap long lines in if-else blocks inside the
site_surveyfunction.
^^^^^^^^^^^
Again, better with brackets: site_survey().
Thanks,
Nikolay
Quoted 30 lines
Signed-off-by Andrei Khomenkov <[email protected]>--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +5
-5@@ -3741,11 +3741,11 @@ void site_survey(struct adapter *padapter) }if (survey_channel !=0 ) { -if (pmlmeext->sitesurvey_res.channel_idx ==0 ) { -set_channel_bwmode (padapter, survey_channel,HAL_PRIME_CHNL_OFFSET_DONT_CARE ,CHANNEL_WIDTH_20 ); - }else { -r8723bs_select_channel (padapter, survey_channel); - } +if (pmlmeext->sitesurvey_res.channel_idx ==0 ) +set_channel_bwmode (padapter, survey_channel, +HAL_PRIME_CHNL_OFFSET_DONT_CARE ,CHANNEL_WIDTH_20 ); +else +r8723bs_select_channel (padapter, survey_channel);if (ScanType ==SCAN_ACTIVE ) {/* obey the channel plan setting... */ {Signature · 1 line
2.47.3