GCC reports the following warning with W=1: drivers/staging/rtl8723bs/core/rtw_mlme_ext.c:6003:15: warning: variable ‘evt_seq’ set but not used [-Wunused-but-set-variable] 6030 | u8 evt_code, evt_seq; | ^~~~~~~ The local variable ‘evt_seq’ is referenced only when the macro CHECK_EVENT_SEQ is defined, move its definition and assignment into the control scope of macro CHECK_EVENT_SEQ, to fix the warning. By the way, clear local coding style warnings and delete several redundant blank lines. Fixes: 554c0a3abf21 ("staging: Add rtl8723bs sdio wifi driver") Reported-by: Hulk Robot <hulkci@xxxxxxxxxx> Signed-off-by: Zhen Lei <thunder.leizhen@xxxxxxxxxx> --- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index acf5578863e17d7..8b7194ccacac0ee 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -5979,7 +5979,7 @@ 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; u16 evt_sz; uint *peventbuf; void (*event_callback)(struct adapter *dev, u8 *pbuf); @@ -5989,19 +5989,23 @@ u8 mlme_evt_hdl(struct adapter *padapter, unsigned char *pbuf) goto _abort_event_; peventbuf = (uint *)pbuf; - evt_sz = (u16)(*peventbuf&0xffff); - evt_seq = (u8)((*peventbuf>>24)&0x7f); - evt_code = (u8)((*peventbuf>>16)&0xff); + evt_sz = (u16)(*peventbuf & 0xffff); + evt_code = (u8)((*peventbuf >> 16) & 0xff); +#ifdef CHECK_EVENT_SEQ +{ + u8 evt_seq; + + evt_seq = (u8)((*peventbuf >> 24) & 0x7f); - #ifdef CHECK_EVENT_SEQ /* checking event sequence... */ if (evt_seq != (atomic_read(&pevt_priv->event_seq) & 0x7f)) { - pevt_priv->event_seq = (evt_seq+1)&0x7f; + pevt_priv->event_seq = (evt_seq + 1) & 0x7f; goto _abort_event_; } - #endif +} +#endif /* checking if event code is valid */ if (evt_code >= MAX_C2HEVT) @@ -6023,12 +6027,8 @@ u8 mlme_evt_hdl(struct adapter *padapter, unsigned char *pbuf) pevt_priv->evt_done_cnt++; } - _abort_event_: - - return H2C_SUCCESS; - } u8 h2c_msg_hdl(struct adapter *padapter, unsigned char *pbuf) -- 2.26.0.106.g9fadedd