Skip to contentSkip to conversation

staging: fix warning of -Wunused-but-set-variable reported by clang

PATCH In review Ping-Ke Shih 2 participants 6 messages Sep 13, 2024 Staging

lore
Share & tools
lore
#0 lore raw

v2 cover staging: fix warning of -Wunused-but-set-variable reported by clang

The build of wireless-next pull-request using clang report warnings [1]. Fix them accordingly.

[1] https://lore.kernel.org/linux-wireless/172609384625.1065358.6518424528532813444.git-patchwork-notify@kernel.org/T/#m405a10ad637bfc5f337127bab81336d8569e49cd

v2:
- rebase to top of staging tree to resolve conflict of patch 2/4.
- no logic change.

Ping-Ke Shih (4):
staging: rtl8712: remove unused drvinfo_sz from
update_recvframe_attrib
staging: rtl8723bs: remove unused efuseValue from efuse_OneByteWrite()
staging: rtl8723bs: remove unused cnt from recv_func()
staging: rtl8723bs: remove unused 'poll_cnt' from rtw_set_rpwm()

 drivers/staging/rtl8712/rtl8712_recv.c       | 4 ----
 drivers/staging/rtl8723bs/core/rtw_efuse.c   | 9 ---------
 drivers/staging/rtl8723bs/core/rtw_pwrctrl.c | 2 --
 drivers/staging/rtl8723bs/core/rtw_recv.c    | 5 +----
 4 files changed, 1 insertion(+), 19 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 1/4 staging: rtl8712: remove unused drvinfo_sz from update_recvframe_attrib

The drvinfo_sz is a size of hardware generated data putting in front of real RX data. The functions r8712_rxcmd_event_hdl() and recvbuf2recvframe() have its own parsing code to get drvinfo_sz to access real RX data, so removing this unused drvinfo_sz is safe.

Otherwise, clang report:

rtl8712_recv.c:139:6: warning:
variable 'drvinfo_sz' set but not used [-Wunused-but-set-variable]
139 | u16 drvinfo_sz;
| ^

---
 drivers/staging/rtl8712/rtl8712_recv.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/staging/rtl8712/rtl8712_recv.c +0 -4
index 1fabc5137a4c..ab344d676bb9 100644
@@ -136,10 +136,6 @@ void r8712_free_recvframe(union recv_frame *precvframe,
 static void update_recvframe_attrib_from_recvstat(struct rx_pkt_attrib *pattrib,
 						  struct recv_stat *prxstat)
 {
-	u16 drvinfo_sz;
-
-	drvinfo_sz = (le32_to_cpu(prxstat->rxdw0) & 0x000f0000) >> 16;
-	drvinfo_sz <<= 3;
 	/*TODO:
 	 * Offset 0
 	 */
Signature · 1 line
2.25.1
#2 lore raw

PATCH v2 2/4 staging: rtl8723bs: remove unused efuseValue from efuse_OneByteWrite()

In reply to Ping-Ke Shih

The efuseValue is to store value from register EFUSE_CTRL, and set control bits including address and write bit. This is no need for RTL8723BS, so the consumer has been removed. Thus, remove these unused codes are safe.

Otherwiese, clang warns:

rtw_efuse.c:285:6: warning:
variable 'efuseValue' set but not used [-Wunused-but-set-variable]
285 | u32 efuseValue;
| ^

---
 drivers/staging/rtl8723bs/core/rtw_efuse.c | 9 ---------
 1 file changed, 9 deletions(-)
drivers/staging/rtl8723bs/core/rtw_efuse.c +0 -9
index 6419638c6e20..8b671f8a7965 100644
@@ -281,22 +281,13 @@ u8 efuse_OneByteWrite(struct adapter *padapter, u16 addr, u8 data, bool bPseudoT
 {
 	u8 tmpidx = 0;
 	u8 bResult = false;
-	u32 efuseValue;
 
 	if (bPseudoTest)
 		return Efuse_Write1ByteToFakeContent(addr, data);
 
-
 	/*  -----------------e-fuse reg ctrl --------------------------------- */
 	/* address */
 
-
-	efuseValue = rtw_read32(padapter, EFUSE_CTRL);
-	efuseValue |= (BIT21 | BIT31);
-	efuseValue &= ~(0x3FFFF);
-	efuseValue |= ((addr << 8 | data) & 0x3FFFF);
-
-
 	/*  <20130227, Kordan> 8192E MP chip A-cut had better not set 0x34[11] until B-Cut. */
 
 	/*  <20130121, Kordan> For SMIC EFUSE specificatoin. */
Signature · 1 line
2.25.1
#3 lore raw

PATCH v2 3/4 staging: rtl8723bs: remove unused cnt from recv_func()

In reply to Ping-Ke Shih

The 'cnt' is used to show how many pending frames are processed, and the debug code has been removed, so removing 'cnt' is safe.

Otherwise, clang warns:

core/rtw_recv.c:2030:7: warning:
variable 'cnt' set but not used [-Wunused-but-set-variable]
2030 | int cnt = 0;
| ^

---
 drivers/staging/rtl8723bs/core/rtw_recv.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/staging/rtl8723bs/core/rtw_recv.c +1 -4
index 7a95e15e641f..b30f026789b6 100644
@@ -2026,12 +2026,9 @@ static int recv_func(struct adapter *padapter, union recv_frame *rframe)
 	/* check if need to handle uc_swdec_pending_queue*/
 	if (check_fwstate(mlmepriv, WIFI_STATION_STATE) && psecuritypriv->busetkipkey) {
 		union recv_frame *pending_frame;
-		int cnt = 0;
 
-		while ((pending_frame = rtw_alloc_recvframe(&padapter->recvpriv.uc_swdec_pending_queue))) {
-			cnt++;
+		while ((pending_frame = rtw_alloc_recvframe(&padapter->recvpriv.uc_swdec_pending_queue)))
 			recv_func_posthandle(padapter, pending_frame);
-		}
 	}
 
 	ret = recv_func_prehandle(padapter, rframe);
Signature · 1 line
2.25.1
#4 lore raw

PATCH v2 4/4 staging: rtl8723bs: remove unused 'poll_cnt' from rtw_set_rpwm()

In reply to Ping-Ke Shih

The 'poll_cnt' is used to assist in polling hardware state. Current code uses jiffies to determine timeout, so removing this value is safe.

Otherwise, clang warns:

core/rtw_pwrctrl.c:288:6: warning:
variable 'poll_cnt' set but not used [-Wunused-but-set-variable]
288 | u8 poll_cnt = 0;
| ^

---
 drivers/staging/rtl8723bs/core/rtw_pwrctrl.c | 2 --
 1 file changed, 2 deletions(-)
drivers/staging/rtl8723bs/core/rtw_pwrctrl.c +0 -2
index a95092129748..dbfcbac3d855 100644
@@ -284,14 +284,12 @@ void rtw_set_rpwm(struct adapter *padapter, u8 pslv)
 	if (rpwm & PS_ACK) {
 		unsigned long start_time;
 		u8 cpwm_now;
-		u8 poll_cnt = 0;
 
 		start_time = jiffies;
 
 		/*  polling cpwm */
 		do {
 			mdelay(1);
-			poll_cnt++;
 			rtw_hal_get_hwreg(padapter, HW_VAR_CPWM, &cpwm_now);
 			if ((cpwm_orig ^ cpwm_now) & 0x80) {
 				pwrpriv->cpwm = PS_STATE_S4;
Signature · 1 line
2.25.1
Tested-by on the v2 series
#5 lore raw
In reply to Ping-Ke Shih
Quoted 16 lines · Ping-Ke Shih

The build of wireless-next pull-request using clang report warnings [1]. Fix them accordingly.

[1] https://lore.kernel.org/linux-wireless/172609384625.1065358.6518424528532813444.git-patchwork-notify@kernel.org/T/#m405a10ad637bfc5f337127bab81336d8569e49cd

v2:
- rebase to top of staging tree to resolve conflict of patch 2/4.
- no logic change.

Ping-Ke Shih (4):
staging: rtl8712: remove unused drvinfo_sz from
update_recvframe_attrib
staging: rtl8723bs: remove unused efuseValue from efuse_OneByteWrite()
staging: rtl8723bs: remove unused cnt from recv_func()
staging: rtl8723bs: remove unused 'poll_cnt' from rtw_set_rpwm()

Quoted 6 lines
  drivers/staging/rtl8712/rtl8712_recv.c       | 4 ----
  drivers/staging/rtl8723bs/core/rtw_efuse.c   | 9 ---------
  drivers/staging/rtl8723bs/core/rtw_pwrctrl.c | 2 --
  drivers/staging/rtl8723bs/core/rtw_recv.c    | 5 +----
  4 files changed, 1 insertion(+), 19 deletions(-)