Skip to contentSkip to conversation

staging: rtl8723bs: os_dep: remove multiple return

PATCH In review Saurav Girepunje 2 participants 4 messages Apr 18, 2021 – Apr 27, 2021 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: rtl8723bs: os_dep: remove multiple return

on sdio_intf.c rtw_sdio_suspend call we have multiple return which can replace by goto exit. As in all the places return value is 0.

---
 drivers/staging/rtl8723bs/os_dep/sdio_intf.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/staging/rtl8723bs/os_dep/sdio_intf.c +6 -3
index a9a9631dd23c..3e566cf97f6e 100644
@@ -445,14 +445,17 @@ static int rtw_sdio_suspend(struct device *dev)
 	struct debug_priv *pdbgpriv = &psdpriv->drv_dbg;
 
 	if (padapter->bDriverStopped)
-		return 0;
+		goto exit;
 
 	if (pwrpriv->bInSuspend) {
 		pdbgpriv->dbg_suspend_error_cnt++;
-		return 0;
+		goto exit;
 	}
 
-	return rtw_suspend_common(padapter);
+	rtw_suspend_common(padapter);
+exit:
+
+	return 0;
 }
 
 static int rtw_resume_process(struct adapter *padapter)
Signature · 1 line
2.25.1
#1 lore raw
Quoted 4 lines · Saurav Girepunje

on sdio_intf.c rtw_sdio_suspend call we have multiple return which can replace by goto exit. As in all the places return value is 0.

Why?

Do nothing gotos just make the code harder to read and introduce forgot to set the error code bugs.

regards,
dan carpenter

#2 lore raw
In reply to Saurav Girepunje
Quoted 18 lines · Saurav Girepunje

on sdio_intf.c rtw_sdio_suspend call we have multiple return which can replace by goto exit. As in all the places return value is 0.

---
 drivers/staging/rtl8723bs/os_dep/sdio_intf.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/staging/rtl8723bs/os_dep/sdio_intf.c +0 -1
index a9a9631dd23c..3e566cf97f6e 100644
@@ -445,14 +445,17 @@ static int rtw_sdio_suspend(struct device *dev)
 	struct debug_priv *pdbgpriv = &psdpriv->drv_dbg;
 
 	if (padapter->bDriverStopped)
-		return 0;

drivers/staging/rtl8723bs/os_dep/sdio_intf.c static int rtw_sdio_suspend(struct device *dev) · line 455

Quoted 10 lines
drivers/staging/rtl8723bs/os_dep/sdio_intf.c +3 -2
+		goto exit;
 
 	if (pwrpriv->bInSuspend) {
 		pdbgpriv->dbg_suspend_error_cnt++;
-		return 0;
+		goto exit;
 	}
 
-	return rtw_suspend_common(padapter);
+	rtw_suspend_common(padapter);

Also it's weird that your previous patch made rtw_suspend_common() return zero unconditionally. But now we're modifying the only caller to not check the return. Just make rtw_suspend_common() void and change this to:

	rtw_suspend_common(padapter);

	return 0;

regards,
dan carpenter

#3 lore raw
Quoted 35 lines · Dan Carpenter
Quoted 18 lines · Saurav Girepunje

on sdio_intf.c rtw_sdio_suspend call we have multiple return which can replace by goto exit. As in all the places return value is 0.

---
 drivers/staging/rtl8723bs/os_dep/sdio_intf.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/staging/rtl8723bs/os_dep/sdio_intf.c +0 -1
index a9a9631dd23c..3e566cf97f6e 100644
@@ -445,14 +445,17 @@ static int rtw_sdio_suspend(struct device *dev)
 	struct debug_priv *pdbgpriv = &psdpriv->drv_dbg;
 
 	if (padapter->bDriverStopped)
-		return 0;

drivers/staging/rtl8723bs/os_dep/sdio_intf.c static int rtw_sdio_suspend(struct device *dev) · line 455

Quoted 10 lines
drivers/staging/rtl8723bs/os_dep/sdio_intf.c +3 -2
+		goto exit;
 
 	if (pwrpriv->bInSuspend) {
 		pdbgpriv->dbg_suspend_error_cnt++;
-		return 0;
+		goto exit;
 	}
 
-	return rtw_suspend_common(padapter);
+	rtw_suspend_common(padapter);

Also it's weird that your previous patch made rtw_suspend_common() return zero unconditionally. But now we're modifying the only caller to not check the return. Just make rtw_suspend_common() void and change this to:

Quoted 7 lines
	rtw_suspend_common(padapter);

	return 0;

regards,
dan carpenter

Sure, rtw_suspend_common always return 0. It should be void. I will merge and resend the patch.