staging: rtl8723bs: ieee80211: remove unused variable
Subsystems (2)
PATCH 1/6 staging: rtl8723bs: ieee80211: remove unused variable
sec_idx in rtw_get_sec_ie() is set to 0 and never changes value. Also, it is only used for debugging messages. Therefore the variable is removed and the debug messages are adjusted. Adjusting debug messages forced style changes. Taking the opportunity to adjust indentation of those sections of the code.
Removing this warning:
drivers/staging/rtl8723bs/core/rtw_ieee80211.c:657:15: warning: variable ‘sec_idx’ set but not used [-Wunused-but-set-variable]
--- .../staging/rtl8723bs/core/rtw_ieee80211.c | 43 +++++++++++-------- 1 file changed, 25 insertions(+), 18 deletions(-)
drivers/staging/rtl8723bs/core/rtw_ieee80211.c +25 -18
@@ -654,7 +654,7 @@ int rtw_get_wapi_ie(u8 *in_ie, uint in_len, u8 *wapi_ie, u16 *wapi_len)void rtw_get_sec_ie (u8 *in_ie,uint in_len,u8 *rsn_ie,u16 *rsn_len,u8 *wpa_ie,u16 *wpa_len) { -u8 authmode, sec_idx, i; +u8 authmode, i;u8 wpa_oui[4 ] = {0x0 ,0x50 ,0xf2 ,0x01 };uint cnt;
@@ -662,37 +662,44 @@ void rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie cnt = (_TIMESTAMP_ + _BEACON_ITERVAL_ + _CAPABILITY_); - sec_idx =0 ; -while (cnt < in_len) { authmode = in_ie[cnt];if ((authmode ==WLAN_EID_VENDOR_SPECIFIC ) && (!memcmp (&in_ie[cnt+2 ], &wpa_oui[0 ],4 ))) { -RT_TRACE (_module_rtl871x_mlme_c_, _drv_info_, ("\n rtw_get_wpa_ie: sec_idx =%d in_ie[cnt+1]+2 =%d\n" , sec_idx, in_ie[cnt+1 ]+2 )); +RT_TRACE (_module_rtl871x_mlme_c_, _drv_info_, + ("\n rtw_get_wpa_ie: in_ie[cnt+1]+2 =%d\n" , in_ie[cnt +1 ] +2 )); -if (wpa_ie) { +if (wpa_ie) {memcpy (wpa_ie, &in_ie[cnt], in_ie[cnt+1 ]+2 );for (i =0 ; i < (in_ie[cnt+1 ]+2 ); i = i+8 ) { -RT_TRACE (_module_rtl871x_mlme_c_, _drv_info_, ("\n %2x,%2x,%2x,%2x,%2x,%2x,%2x,%2x\n" , - wpa_ie[i], wpa_ie[i+1 ], wpa_ie[i+2 ], wpa_ie[i+3 ], wpa_ie[i+4 ], - wpa_ie[i+5 ], wpa_ie[i+6 ], wpa_ie[i+7 ])); - } +RT_TRACE (_module_rtl871x_mlme_c_, _drv_info_, + ("\n %2x,%2x,%2x,%2x,%2x,%2x,%2x,%2x\n" , + wpa_ie[i], wpa_ie[i +1 ], wpa_ie[i +2 ], + wpa_ie[i +3 ], wpa_ie[i +4 ], + wpa_ie[i +5 ], wpa_ie[i +6 ], + wpa_ie[i +7 ])); } + } - *wpa_len = in_ie[cnt+1 ]+2 ; - cnt += in_ie[cnt+1 ]+2 ;/* get next */ + *wpa_len = in_ie[cnt +1 ] +2 ; + cnt += in_ie[cnt +1 ] +2 ;/* get next */ }else {if (authmode ==WLAN_EID_RSN ) { -RT_TRACE (_module_rtl871x_mlme_c_, _drv_info_, ("\n get_rsn_ie: sec_idx =%d in_ie[cnt+1]+2 =%d\n" , sec_idx, in_ie[cnt+1 ]+2 )); +RT_TRACE (_module_rtl871x_mlme_c_, _drv_info_, + ("\n get_rsn_ie: in_ie[cnt+1]+2 =%d\n" , + in_ie[cnt +1 ] +2 ));if (rsn_ie) { -memcpy (rsn_ie, &in_ie[cnt], in_ie[cnt+1 ]+2 ); - -for (i =0 ; i < (in_ie[cnt+1 ]+2 ); i = i+8 ) { -RT_TRACE (_module_rtl871x_mlme_c_, _drv_info_, ("\n %2x,%2x,%2x,%2x,%2x,%2x,%2x,%2x\n" , - rsn_ie[i], rsn_ie[i+1 ], rsn_ie[i+2 ], rsn_ie[i+3 ], rsn_ie[i+4 ], - rsn_ie[i+5 ], rsn_ie[i+6 ], rsn_ie[i+7 ])); +memcpy (rsn_ie, &in_ie[cnt], in_ie[cnt +1 ] +2 ); + +for (i =0 ; i < (in_ie[cnt +1 ] +2 ); i = i +8 ) { +RT_TRACE (_module_rtl871x_mlme_c_, _drv_info_, + ("\n %2x,%2x,%2x,%2x,%2x,%2x,%2x,%2x\n" , + rsn_ie[i], rsn_ie[i +1 ], rsn_ie[i +2 ], + rsn_ie[i +3 ], rsn_ie[i +4 ], + rsn_ie[i +5 ], rsn_ie[i +6 ], + rsn_ie[i +7 ])); } }
Signature · 1 line
2.30.2
PATCH 2/6 staging: rtl8723bs: mlme: remove unused variables
The variable *pframe in rtw_build_wmm_ie_ht() and rtw_restructure_ht_ie() is set but never read. Both instances are getting removed.
Removing these warning:
drivers/staging/rtl8723bs/core/rtw_mlme.c:2560:6: warning: variable ‘pframe’ set but not used [-Wunused-but-set-variable] drivers/staging/rtl8723bs/core/rtw_mlme.c:2576:21: warning: variable ‘pframe’ set but not used [-Wunused-but-set-variable]
--- drivers/staging/rtl8723bs/core/rtw_mlme.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme.c +7 -7
@@ -2555,12 +2555,11 @@ void rtw_build_wmm_ie_ht(struct adapter *padapter, u8 *out_ie, uint *pout_len) {unsigned char WMM_IE [] = {0x00 ,0x50 ,0xf2 ,0x02 ,0x00 ,0x01 ,0x00 };int out_len; -u8 *pframe;if (padapter->mlmepriv.qospriv.qos_option ==0 ) { out_len = *pout_len; - pframe =rtw_set_ie (out_ie+out_len,WLAN_EID_VENDOR_SPECIFIC , - _WMM_IE_Length_,WMM_IE , pout_len); +rtw_set_ie (out_ie + out_len,WLAN_EID_VENDOR_SPECIFIC , + _WMM_IE_Length_,WMM_IE , pout_len); padapter->mlmepriv.qospriv.qos_option =1 ; }
@@ -2571,7 +2570,7 @@ unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_ {u32 ielen, out_len;enum ieee80211_max_ampdu_length_exp max_rx_ampdu_factor; -unsigned char *p, *pframe; +unsigned char *p;struct ieee80211_ht_cap ht_capie;u8 cbw40_enable =0 , stbc_rx_enable =0 , rf_type =0 , operation_bw =0 ;struct registry_priv *pregistrypriv = &padapter->registrypriv;
@@ -2696,8 +2695,8 @@ unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_else ht_capie.ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_DENSITY &0x00 ); - pframe =rtw_set_ie (out_ie+out_len,WLAN_EID_HT_CAPABILITY , -sizeof (struct ieee80211_ht_cap ), (unsigned char *)&ht_capie, pout_len); +rtw_set_ie (out_ie + out_len,WLAN_EID_HT_CAPABILITY , +sizeof (struct ieee80211_ht_cap ), (unsigned char *)&ht_capie, pout_len); phtpriv->ht_option = true;
@@ -2705,7 +2704,8 @@ unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_ p =rtw_get_ie (in_ie,WLAN_EID_HT_OPERATION , &ielen, in_len);if (p && (ielen ==sizeof (struct ieee80211_ht_addt_info ))) { out_len = *pout_len; - pframe =rtw_set_ie (out_ie+out_len,WLAN_EID_HT_OPERATION , ielen, p+2 , pout_len); +rtw_set_ie (out_ie + out_len,WLAN_EID_HT_OPERATION , + ielen, p +2 , pout_len); } }
Signature · 1 line
2.30.2
Greg KH
maintainerRe: [PATCH -next 2/6] staging: rtl8723bs: mlme: remove unused variables
Quoted 19 lines · Edmundo Carmona Antoranz
The variable *pframe in
rtw_build_wmm_ie_ht()andrtw_restructure_ht_ie()is set but never read. Both instances are getting removed.Removing these warning:
drivers/staging/rtl8723bs/core/rtw_mlme.c:2560:6: warning: variable ‘pframe’ set but not used [-Wunused-but-set-variable]drivers/staging/rtl8723bs/core/rtw_mlme.c:2576:21: warning: variable ‘pframe’ set but not used [-Wunused-but-set-variable]Signed-off-by Edmundo Carmona Antoranz <[email protected]>--- drivers/staging/rtl8723bs/core/rtw_mlme.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)drivers/staging/rtl8723bs/core/rtw_mlme.c +0
-0@@ -2555,12 +2555,11 @@ void rtw_build_wmm_ie_ht(struct adapter *padapter, u8 *out_ie, uint *pout_len) {
drivers/staging/rtl8723bs/core/rtw_mlme.c void rtw_build_wmm_ie_ht(struct adapter *padapter, u8 *out_ie, uint *pout_len) · line 2562
Quoted 10 lines
drivers/staging/rtl8723bs/core/rtw_mlme.c +2
-3unsigned char WMM_IE [] = {0x00 ,0x50 ,0xf2 ,0x02 ,0x00 ,0x01 ,0x00 };int out_len; -u8 *pframe;if (padapter->mlmepriv.qospriv.qos_option ==0 ) { out_len = *pout_len; - pframe =rtw_set_ie (out_ie+out_len,WLAN_EID_VENDOR_SPECIFIC , - _WMM_IE_Length_,WMM_IE , pout_len); +rtw_set_ie (out_ie + out_len,WLAN_EID_VENDOR_SPECIFIC , + _WMM_IE_Length_,WMM_IE , pout_len);
Why not check the error value?
thanks,
greg k-h
PATCH 3/6 staging: rtl8723bs: hal: remove unused variable in HalBtc8723b1Ant.c
In reply to Edmundo Carmona AntoranzVariable btRssiState in halbtc8723b1ant_ActionWifiConnectedBtAclBusy() is set but never read. Removing it.
Removing this warning:
drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.c:2093:5: warning: variable ‘btRssiState’ set but not used [-Wunused-but-set-variable]
--- drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.c +1 -3
@@ -2090,10 +2090,8 @@ static void halbtc8723b1ant_ActionWifiConnectedBtAclBusy( struct btc_coexist *pBtCoexist, u8 wifiStatus ) { -u8 btRssiState; -struct btc_bt_link_info *pBtLinkInfo = &pBtCoexist->btLinkInfo; - btRssiState =halbtc8723b1ant_BtRssiState (2 ,28 ,0 ); +halbtc8723b1ant_BtRssiState (2 ,28 ,0 );if ((pCoexSta->lowPriorityRx >=1000 ) && (pCoexSta->lowPriorityRx !=65535 )) pBtLinkInfo->bSlaveRole = true;
Signature · 1 line
2.30.2
PATCH 4/6 staging: rtl8723bs: sdio_ops: removing unused variable
In reply to Edmundo Carmona AntoranzInside sd_int_dpc(), variable report is set but it's never read. Getting rid of it.
Removing this warning:
drivers/staging/rtl8723bs/hal/sdio_ops.c:946:30: warning: variable ‘report’ set but not used [-Wunused-but-set-variable]
--- drivers/staging/rtl8723bs/hal/sdio_ops.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/rtl8723bs/hal/sdio_ops.c +1 -3
@@ -943,11 +943,9 @@ void sd_int_dpc(struct adapter *adapter) }if (hal->sdio_hisr &SDIO_HISR_CPWM1 ) { -struct reportpwrstate_parm report; -del_timer_sync (&(pwrctl->pwr_rpwm_timer)); - report.state =SdioLocalCmd52Read1Byte (adapter,SDIO_REG_HCPWM1_8723B ); +SdioLocalCmd52Read1Byte (adapter,SDIO_REG_HCPWM1_8723B );_set_workitem (&(pwrctl->cpwm_event)); }
Signature · 1 line
2.30.2
PATCH 5/6 staging: rtl8723bs: mark some variables as __maybe_unused
In reply to Edmundo Carmona AntoranzThe definition of a few macros used in the code to write debug messages could be empty depending on the way code is compiled. If this is the case, there are compiler warnings about variables not being used. This patch markes them to be __maybe_unused to avoid these warnings.
Removing these warnings:
drivers/staging/rtl8723bs/core/rtw_mlme.c:1282:12: warning: variable ‘retry’ set but not used [-Wunused-but-set-variable] drivers/staging/rtl8723bs/core/rtw_mlme_ext.c:1065:17: warning: variable ‘reassoc’ set but not used [-Wunused-but-set-variable] drivers/staging/rtl8723bs/core/rtw_mlme_ext.c:1799:30: warning: variable ‘reason_code’ set but not used [-Wunused-but-set-variable] drivers/staging/rtl8723bs/core/rtw_mlme_ext.c:5411:21: warning: variable ‘psta’ set but not used [-Wunused-but-set-variable] drivers/staging/rtl8723bs/core/rtw_mlme_ext.c:6317:15: warning: variable ‘evt_seq’ set but not used [-Wunused-but-set-variable] drivers/staging/rtl8723bs/core/rtw_recv.c:2501:6: warning: variable ‘num_signal_qual’ set but not used [-Wunused-but-set-variable] drivers/staging/rtl8723bs/core/rtw_wlan_util.c:1793:11: warning: variable ‘start_seq’ set but not used [-Wunused-but-set-variable] drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c:3719:32: warning: variable ‘ioted’ set but not used [-Wunused-but-set-variable] drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c:3719:20: warning: variable ‘masked’ set but not used [-Wunused-but-set-variable] drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c:3719:7: warning: variable ‘input_b’ set but not used [-Wunused-but-set-variable] drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c:4290:46: warning: variable ‘lowest_rate’ set but not used [-Wunused-but-set-variable] drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c:4290:34: warning: variable ‘hight_rate’ set but not used [-Wunused-but-set-variable] drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c:4290:21: warning: variable ‘curr_tx_sgi’ set but not used [-Wunused-but-set-variable] drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c:4290:7: warning: variable ‘curr_tx_rate’ set but not used [-Wunused-but-set-variable] drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c:4289:20: warning: variable ‘rate_mask2’ set but not used [-Wunused-but-set-variable] drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c:4289:8: warning: variable ‘rate_mask1’ set but not used [-Wunused-but-set-variable] drivers/staging/rtl8723bs/hal/sdio_ops.c:170:6: warning: variable ‘err’ set but not used [-Wunused-but-set-variable] drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c:2924:7: warning: variable ‘ack’ set but not used [-Wunused-but-set-variable] drivers/staging/rtl8723bs/os_dep/ioctl_linux.c:1199:6: warning: variable ‘reason’ set but not used [-Wunused-but-set-variable]
--- drivers/staging/rtl8723bs/core/rtw_mlme.c | 2 +- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 11 +++++++---- drivers/staging/rtl8723bs/core/rtw_recv.c | 2 +- drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 3 ++- drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c | 7 ++++--- drivers/staging/rtl8723bs/hal/sdio_ops.c | 2 +- drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 2 +- drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 2 +- 8 files changed, 18 insertions(+), 13 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme.c +1 -1
@@ -1277,7 +1277,7 @@ static void rtw_joinbss_update_network(struct adapter *padapter, struct wlan_net/* define REJOIN */ void rtw_joinbss_event_prehandle (struct adapter *adapter,u8 *pbuf) { -static u8 retry; +static u8 __maybe_unused retry;struct sta_info *ptarget_sta =NULL , *pcur_sta =NULL ;struct sta_priv *pstapriv = &adapter->stapriv;struct mlme_priv *pmlmepriv = &(adapter->mlmepriv);
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +7 -4
@@ -1062,7 +1062,8 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)u16 capab_info;struct rtw_ieee802_11_elems elems;struct sta_info *pstat; -unsigned char reassoc, *p, *pos, *wpa_ie; +unsigned char *p, *pos, *wpa_ie; +unsigned char __maybe_unused reassoc;unsigned char WMM_IE [] = {0x00 ,0x50 ,0xf2 ,0x02 ,0x00 ,0x01 };int i, ie_len, wpa_ie_len, left;unsigned char supportRate[16 ];
@@ -1796,7 +1797,8 @@ unsigned int OnAction_back(struct adapter *padapter, union recv_frame *precv_frastruct recv_reorder_ctrl *preorder_ctrl;unsigned char *frame_body;unsigned char category, action; -unsigned short tid, status, reason_code =0 ; +unsigned short tid, status; +unsigned short __maybe_unused reason_code =0 ;struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);u8 *pframe = precv_frame->u.hdr.rx_data;
@@ -5408,7 +5410,7 @@ void _linked_info_dump(struct adapter *padapter) }else if ((pmlmeinfo->state&0x03 ) == _HW_STATE_AP_) {struct list_head *phead, *plist; -struct sta_info *psta =NULL ; +struct sta_info __maybe_unused *psta =NULL ;struct sta_priv *pstapriv = &padapter->stapriv;spin_lock_bh (&pstapriv->asoc_list_lock);
@@ -6314,7 +6316,8 @@ u8 set_tx_beacon_cmd(struct adapter *padapter)u8 mlme_evt_hdl (struct adapter *padapter,unsigned char *pbuf) { -u8 evt_code, evt_seq; +u8 evt_code; +u8 __maybe_unused evt_seq;u16 evt_sz;uint *peventbuf;void (*event_callback)(struct adapter *dev,u8 *pbuf);
drivers/staging/rtl8723bs/core/rtw_recv.c +1 -1
@@ -2471,7 +2471,7 @@ static void rtw_signal_stat_timer_hdl(struct timer_list *t)u8 avg_signal_strength =0 ;u8 avg_signal_qual =0 ;u32 num_signal_strength =0 ; -u32 num_signal_qual =0 ; +u32 __maybe_unused num_signal_qual =0 ;u8 _alpha =5 ;/* this value is based on converging_constant = 5000 and sampling_interval = 1000 */ if (adapter->recvpriv.is_signal_dbg) {
drivers/staging/rtl8723bs/core/rtw_wlan_util.c +2 -1
@@ -1787,7 +1787,8 @@ int update_sta_support_rate(struct adapter *padapter, u8 *pvar_ie, uint var_ie_lvoid process_addba_req (struct adapter *padapter,u8 *paddba_req,u8 *addr) {struct sta_info *psta; -u16 tid, start_seq, param; +u16 tid, param; +u16 __maybe_unused start_seq;struct recv_reorder_ctrl *preorder_ctrl;struct sta_priv *pstapriv = &padapter->stapriv;struct ADDBA_request *preq = (struct ADDBA_request *)paddba_req;
drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +4 -3
@@ -3716,7 +3716,8 @@ void SetHwReg8723B(struct adapter *padapter, u8 variable, u8 *val)case HW_VAR_BASIC_RATE : {struct mlme_ext_info *mlmext_info = &padapter->mlmeextpriv.mlmext_info; -u16 input_b =0 , masked =0 , ioted =0 , BrateCfg =0 ; +u16 __maybe_unused input_b =0 , masked =0 , ioted =0 ; +u16 BrateCfg =0 ;u16 rrsr_2g_force_mask = (RRSR_11M |RRSR_5_5M |RRSR_1M );u16 rrsr_2g_allow_mask = (RRSR_24M |RRSR_12M |RRSR_6M |RRSR_CCK_RATES );
@@ -4286,8 +4287,8 @@ u8 GetHalDefVar8723B(struct adapter *padapter, enum hal_def_variable variable, vu8 mac_id = *(u8 *)pval;u32 cmd;u32 ra_info1, ra_info2; -u32 rate_mask1, rate_mask2; -u8 curr_tx_rate, curr_tx_sgi, hight_rate, lowest_rate; +u32 __maybe_unused rate_mask1, rate_mask2; +u8 __maybe_unused curr_tx_rate, curr_tx_sgi, hight_rate, lowest_rate;DBG_8192C ("============ RA status check Mac_id:%d ===================\n" , mac_id);
drivers/staging/rtl8723bs/hal/sdio_ops.c +1 -1
@@ -167,7 +167,7 @@ static u32 sdio_read32(struct intf_hdl *intfhdl, u32 addr)u32 ftaddr;u8 shift;u32 val; -s32 err; +s32 __maybe_unused err;__le32 le_tmp; adapter = intfhdl->padapter;
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +1 -1
@@ -2919,7 +2919,7 @@ static int _cfg80211_rtw_mgmt_tx(struct adapter *padapter, u8 tx_ch, const u8 *bstruct pkt_attrib *pattrib;unsigned char *pframe;int ret = _FAIL; -bool ack = true; +bool __maybe_unused ack = true;struct ieee80211_hdr *pwlanhdr;struct xmit_priv *pxmitpriv = &(padapter->xmitpriv);struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +1 -1
@@ -1196,7 +1196,7 @@ static int rtw_wx_set_mlme(struct net_device *dev, union iwreq_data *wrqu, char *extra) { int ret = 0; -u16 reason; +u16 __maybe_unused reason;struct adapter *padapter =rtw_netdev_priv (dev);struct iw_mlme *mlme = (struct iw_mlme *)extra;
Signature · 1 line
2.30.2
Re: [PATCH -next 5/6] staging: rtl8723bs: mark some variables as __maybe_unused
This is just papering over badness. Leave the warnings as is so someone will notice it and fix it properly in the future.
regards,
dan carpenter
Re: [PATCH -next 5/6] staging: rtl8723bs: mark some variables as __maybe_unused
Quoted 4 lines · Dan Carpenter
This is just papering over badness. Leave the warnings as is so someone will notice it and fix it properly in the future.
Interesting.... I wonder what the right way to handle this would be then. Is it a more appropriate solution defining the debug macros _only_ if we are debugging and then also use #ifs in code to define the variables and handle them?
So, currently, in rtw_debug.h, we have this (lines ~134-140):
#define RT_TRACE(_Comp, _Level, Fmt) do {} while (0) #define RT_PRINT_DATA(_Comp, _Level, _TitleString, _HexData, _HexDataLen) do {} while (0)
#define DBG_871X(x, ...) do {} while (0)
#define MSG_8192C(x, ...) do {} while (0)
#define DBG_8192C(x, ...) do {} while (0)
#define DBG_871X_LEVEL(x, ...) do {} while (0)
And then, a bit further down the road in the same file:
#ifdef DEBUG
#if defined(_dbgdump)
#undef DBG_871X
#define DBG_871X(...) do {\
_dbgdump(DRIVER_PREFIX __VA_ARGS__);\
} while (0)
#undef MSG_8192C
#define MSG_8192C(...) do {\
_dbgdump(DRIVER_PREFIX __VA_ARGS__);\
} while (0)
#undef DBG_8192C
#define DBG_8192C(...) do {\
_dbgdump(DRIVER_PREFIX __VA_ARGS__);\
} while (0)#endif /* defined(_dbgdump) */
#endif /* DEBUG */
If we remove the definition of the macros that were around line 134, we need to make sure that those macros are not used in code if the same conditions are not met... so, it might mean that we control if we define the variables we are using... one of the examples from this patch:
unsigned char *p, *pos, *wpa_ie;
#ifdef DEBUG && defined(_dbgdump)
unsigned char * reassoc;
#endif
unsigned char WMM_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01};
.
.
.
if (frame_type == WIFI_ASSOCREQ) {
#ifdef DEBUG && defined(_dbgdump)
reassoc = 0;
#endif
ie_offset = _ASOCREQ_IE_OFFSET_;
} else { /* WIFI_REASSOCREQ */
#ifdef DEBUG && defined(_dbgdump)
reassoc = 1;
#endif
ie_offset = _REASOCREQ_IE_OFFSET_;
}
if (pkt_len < sizeof(struct ieee80211_hdr_3addr) + ie_offset) {
#ifdef DEBUG && defined(_dbgdump)
DBG_871X("handle_assoc(reassoc =%d) - too short payload (len =%lu)"
"\n", reassoc, (unsigned long)pkt_len);
#endif
return _FAIL;
}Quoted 3 lines
regards,
dan carpenter
Re: [PATCH -next 5/6] staging: rtl8723bs: mark some variables as __maybe_unused
Quoted 5 lines · Edmundo Carmona Antoranz
Quoted 4 lines · Dan Carpenter
This is just papering over badness. Leave the warnings as is so someone will notice it and fix it properly in the future.
Take a look at the first example:
1277 /* define REJOIN */
^^^^^^^^^^^^^
This is developer code which can't be turned on through the Kconfig. Automatically that means we are allowed to delete all the #ifdef REJOIN code.
1278 void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf)
1279 {
1280 static u8 retry;
^^^^^^^^^^^^^^^
1397 } else {/* if join_res < 0 (join fails), then try again */
1398
1399 #ifdef REJOIN
1400 res = _FAIL;
1401 if (retry < 2) {This function is now only allowed to be called twice. What the heck sort of function is that where we can only call it twice??? Who calls this anyway? Something to investigate.
1402 res = rtw_select_and_join_from_scanned_queue(pmlmepriv);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^Here we are setting "res".
1403 RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("rtw_select_and_join_from_scanned_queue again! res:%d\n", res));
1404 }
1405
1406 if (res == _SUCCESS) {
1407 /* extend time of assoc_timer */
1408 _set_timer(&pmlmepriv->assoc_timer, MAX_JOIN_TIMEOUT);
1409 retry++;So, okay, we're only allowed to succeed twice. We can fail as many times as we want. Weird.
1410 } else if (res == 2) {/* there is no need to wait for join */
What does 1 is _SUCCESS, 0 is failure, but what is 2? It turns out that rtw_select_and_join_from_scanned_queue() never returns 2...
1411 _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
1412 rtw_indicate_connect(adapter);
1413 } else {
1414 RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Set Assoc_Timer = 1; can't find match ssid in scanned_q\n"));
1415 #endif
1416
1417 _set_timer(&pmlmepriv->assoc_timer, 1);
1418 /* rtw_free_assoc_resources(adapter, 1); */
1419 _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
1420
1421 #ifdef REJOIN
1422 retry = 0;
1423 }
1424 #endif
1425 }
1426
1427 ignore_joinbss_callback:
1428
1429 spin_unlock_bh(&pmlmepriv->lock);
1430 }So a lot of this is nonsensical dead code, and the "unused variable" was a useful clue about that. Probably all these are nonsensical in their own way so there isn't going to be one answer. Look carefully at each warning and then think about how to re-write it completely.
regards,
dan carpenter
PATCH 6/6 staging: rtl8723bs: sta_mgt: return _FAIL if there is an error
In reply to Edmundo Carmona AntoranzIf there is an error when calling rtw_init_bcmc_stainfo() inside rtw_init_bcmc_stainfo(), variable res is set to _FAIL. However, when returning, _SUCCESS is always returned regardless. Just in case, all existing calls do not consider the result of the function.
Compile-tested as I don't have the hardware.
Removing this warning:
drivers/staging/rtl8723bs/core/rtw_sta_mgt.c:536:6: warning: variable ‘res’ set but not used [-Wunused-but-set-variable]
--- drivers/staging/rtl8723bs/core/rtw_sta_mgt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8723bs/core/rtw_sta_mgt.c +1 -1
@@ -551,7 +551,7 @@ u32 rtw_init_bcmc_stainfo(struct adapter *padapter) psta->mac_id =1 ; exit: -return _SUCCESS; +return res; }struct sta_info *rtw_get_bcmc_stainfo (struct adapter *padapter)
Signature · 1 line
2.30.2
Re: [PATCH -next 6/6] staging: rtl8723bs: sta_mgt: return _FAIL if there is an error
Quoted 3 lines · Edmundo Carmona Antoranz
If there is an error when calling
rtw_init_bcmc_stainfo()insidertw_init_bcmc_stainfo(), variable res is set to_FAIL. However, when
I must have been half-asleep when I was writing that. :-D Sorry. I don't think it's that bad that it should be taken back, though.
Re: [PATCH -next 6/6] staging: rtl8723bs: sta_mgt: return _FAIL if there is an error
In reply to Edmundo Carmona AntoranzQuoted 4 lines · Edmundo Carmona Antoranz
If there is an error when calling
rtw_init_bcmc_stainfo()insidertw_init_bcmc_stainfo(), variable res is set to_FAIL. However, when returning,_SUCCESSis always returned regardless. Just in case, all existing calls do not consider the result of the function.
This more papering over badness. Lets leave it as-is until someone can fix the callers. Static checkers are useful things but if we silence the warnings without fixing the bugs then we are basically going to great effort to write a checker and even more effort to disable the checker.
regards,
dan carpenter
Quoted 5 lines · Edmundo Carmona Antoranz
sec_idxinrtw_get_sec_ie()is set to 0 and never changes value. Also, it is only used for debugging messages. Therefore the variable is removed and the debug messages are adjusted. Adjusting debug messages forced style changes. Taking the opportunity to adjust indentation of those sections of the code.
The re-indents are not related to the other change so you're going to have to split this up into two different patches.
Generally you're making a whitespace change on the same line as the code you are changing then that's fine. But sometimes re-indenting it makes the change harder to spot (review). I would say that this code is easier to review without any indenting changes:
ONE:
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("\n rtw_get_wpa_ie: sec_idx =%d in_ie[cnt+1]+2 =%d\n", sec_idx, in_ie[cnt+1]+2));
+ RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("\n rtw_get_wpa_ie: in_ie[cnt+1]+2 =%d\n", in_ie[cnt+1]+2));
TWO:
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("\n rtw_get_wpa_ie: sec_idx =%d in_ie[cnt+1]+2 =%d\n", sec_idx, in_ie[cnt+1]+2));
+ RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
+ ("\n rtw_get_wpa_ie: in_ie[cnt+1]+2 =%d\n", in_ie[cnt + 1] + 2));
drivers/staging/rtl8723bs/core/rtw_ieee80211.c void rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie · line 681
Quoted 13 lines
drivers/staging/rtl8723bs/core/rtw_ieee80211.c +6
-4memcpy (wpa_ie, &in_ie[cnt], in_ie[cnt+1 ]+2 );for (i =0 ; i < (in_ie[cnt+1 ]+2 ); i = i+8 ) { -RT_TRACE (_module_rtl871x_mlme_c_, _drv_info_, ("\n %2x,%2x,%2x,%2x,%2x,%2x,%2x,%2x\n" , - wpa_ie[i], wpa_ie[i+1 ], wpa_ie[i+2 ], wpa_ie[i+3 ], wpa_ie[i+4 ], - wpa_ie[i+5 ], wpa_ie[i+6 ], wpa_ie[i+7 ])); - } +RT_TRACE (_module_rtl871x_mlme_c_, _drv_info_, + ("\n %2x,%2x,%2x,%2x,%2x,%2x,%2x,%2x\n" , + wpa_ie[i], wpa_ie[i +1 ], wpa_ie[i +2 ], + wpa_ie[i +3 ], wpa_ie[i +4 ], + wpa_ie[i +5 ], wpa_ie[i +6 ], + wpa_ie[i +7 ]));
In this case, the curly braces were fine in the original. Multi-line indented normally get curly braces for readability.
drivers/staging/rtl8723bs/core/rtw_ieee80211.c void rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie · line 683
Quoted 3 lines
drivers/staging/rtl8723bs/core/rtw_ieee80211.c +1
-0} + }
regards,
dan carpenter
Greg KH
maintainerQuoted 31 lines · Edmundo Carmona Antoranz
sec_idxinrtw_get_sec_ie()is set to 0 and never changes value. Also, it is only used for debugging messages. Therefore the variable is removed and the debug messages are adjusted. Adjusting debug messages forced style changes. Taking the opportunity to adjust indentation of those sections of the code.Removing this warning:
drivers/staging/rtl8723bs/core/rtw_ieee80211.c:657:15: warning: variable ‘sec_idx’ set but not used [-Wunused-but-set-variable]Signed-off-by Edmundo Carmona Antoranz <[email protected]>--- .../staging/rtl8723bs/core/rtw_ieee80211.c | 43 +++++++++++-------- 1 file changed, 25 insertions(+), 18 deletions(-)drivers/staging/rtl8723bs/core/rtw_ieee80211.c +1
-1@@ -654,7 +654,7 @@ int rtw_get_wapi_ie(u8 *in_ie, uint in_len, u8 *wapi_ie, u16 *wapi_len)void rtw_get_sec_ie (u8 *in_ie,uint in_len,u8 *rsn_ie,u16 *rsn_len,u8 *wpa_ie,u16 *wpa_len) { -u8 authmode, sec_idx, i; +u8 authmode, i;u8 wpa_oui[4 ] = {0x0 ,0x50 ,0xf2 ,0x01 };uint cnt;@@ -662,37 +662,44 @@ void rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie cnt = (_TIMESTAMP_ + _BEACON_ITERVAL_ + _CAPABILITY_);
drivers/staging/rtl8723bs/core/rtw_ieee80211.c void rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie · line 670
Quoted 10 lines
drivers/staging/rtl8723bs/core/rtw_ieee80211.c +2
-3- sec_idx =0 ; -while (cnt < in_len) { authmode = in_ie[cnt];if ((authmode ==WLAN_EID_VENDOR_SPECIFIC ) && (!memcmp (&in_ie[cnt+2 ], &wpa_oui[0 ],4 ))) { -RT_TRACE (_module_rtl871x_mlme_c_, _drv_info_, ("\n rtw_get_wpa_ie: sec_idx =%d in_ie[cnt+1]+2 =%d\n" , sec_idx, in_ie[cnt+1 ]+2 )); +RT_TRACE (_module_rtl871x_mlme_c_, _drv_info_, + ("\n rtw_get_wpa_ie: in_ie[cnt+1]+2 =%d\n" , in_ie[cnt +1 ] +2 ));
These "RT_TRACE" things need to all be removed or use the real in-kernel api instead. Please do not hide the problems with them by trying to clean them up.
thanks,
greg k-h