Skip to contentSkip to conversation

staging: rtl8723bs: Simplify error handling

PATCH In review Bera Yüzlü 2 participants 4 messages Mar 12 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: rtl8723bs: Simplify error handling

Remove unnecessary ret variable and goto exit pattern. The function now returns immediately when an error occurs.

---
 drivers/staging/rtl8723bs/os_dep/os_intfs.c | 30 +++++++--------------
 1 file changed, 10 insertions(+), 20 deletions(-)
drivers/staging/rtl8723bs/os_dep/os_intfs.c +10 -20
index 7ba689f2d..fe910cc68 100644
@@ -1124,36 +1124,27 @@ static int rtw_resume_process_normal(struct adapter *padapter)
 	struct pwrctrl_priv *pwrpriv;
 	struct mlme_priv *pmlmepriv;
 
-	int ret = _SUCCESS;
-
-	if (!padapter) {
-		ret = -1;
-		goto exit;
-	}
+	if (!padapter)
+		return -1;
 
 	pnetdev = padapter->pnetdev;
 	pwrpriv = adapter_to_pwrctl(padapter);
 	pmlmepriv = &padapter->mlmepriv;
 	/*  interface init */
 	/* if (sdio_init(adapter_to_dvobj(padapter)) != _SUCCESS) */
-	if ((padapter->intf_init) && (padapter->intf_init(adapter_to_dvobj(padapter)) != _SUCCESS)) {
-		ret = -1;
-		goto exit;
-	}
+	if ((padapter->intf_init) && (padapter->intf_init(adapter_to_dvobj(padapter)) != _SUCCESS))
+		return -1;
+
 	rtw_hal_disable_interrupt(padapter);
 	/* if (sdio_alloc_irq(adapter_to_dvobj(padapter)) != _SUCCESS) */
-	if ((padapter->intf_alloc_irq) && (padapter->intf_alloc_irq(adapter_to_dvobj(padapter)) != _SUCCESS)) {
-		ret = -1;
-		goto exit;
-	}
+	if ((padapter->intf_alloc_irq) && (padapter->intf_alloc_irq(adapter_to_dvobj(padapter)) != _SUCCESS))
+		return -1;
 
 	rtw_reset_drv_sw(padapter);
 	pwrpriv->bkeepfwalive = false;
 
-	if (pm_netdev_open(pnetdev, true) != 0) {
-		ret = -1;
-		goto exit;
-	}
+	if (pm_netdev_open(pnetdev, true) != 0)
+		return -1;
 
 	netif_device_attach(pnetdev);
 	netif_carrier_on(pnetdev);
@@ -1168,8 +1159,7 @@ static int rtw_resume_process_normal(struct adapter *padapter)
 		rtw_ap_restore_network(padapter);
 	}
 
-exit:
-	return ret;
+	return _SUCCESS;
 }
 
 int rtw_resume_common(struct adapter *padapter)
Signature · 1 line
2.43.0
maintainer
#1 lore raw
Quoted 26 lines · Bera Yüzlü

Remove unnecessary ret variable and goto exit pattern. The function now returns immediately when an error occurs.

---
 drivers/staging/rtl8723bs/os_dep/os_intfs.c | 30 +++++++--------------
 1 file changed, 10 insertions(+), 20 deletions(-)
drivers/staging/rtl8723bs/os_dep/os_intfs.c +2 -6
index 7ba689f2d..fe910cc68 100644
@@ -1124,36 +1124,27 @@ static int rtw_resume_process_normal(struct adapter *padapter)
 	struct pwrctrl_priv *pwrpriv;
 	struct mlme_priv *pmlmepriv;
 
-	int ret = _SUCCESS;
-
-	if (!padapter) {
-		ret = -1;
-		goto exit;
-	}
+	if (!padapter)
+		return -1;
 
 	pnetdev = padapter->pnetdev;

drivers/staging/rtl8723bs/os_dep/os_intfs.c static int rtw_resume_process_normal(struct adapter *padapter) · line 1136

Quoted 10 lines
drivers/staging/rtl8723bs/os_dep/os_intfs.c +2 -4
 	pwrpriv = adapter_to_pwrctl(padapter);
 	pmlmepriv = &padapter->mlmepriv;
 	/*  interface init */
 	/* if (sdio_init(adapter_to_dvobj(padapter)) != _SUCCESS) */
-	if ((padapter->intf_init) && (padapter->intf_init(adapter_to_dvobj(padapter)) != _SUCCESS)) {
-		ret = -1;
-		goto exit;
-	}
+	if ((padapter->intf_init) && (padapter->intf_init(adapter_to_dvobj(padapter)) != _SUCCESS))
+		return -1;

I understand the goal here, but are you sure that just exiting like this in all of these places is actually correct? Nothing needs to be "unwound"?

Quoted 9 lines
drivers/staging/rtl8723bs/os_dep/os_intfs.c +3 -4
+
 	rtw_hal_disable_interrupt(padapter);
 	/* if (sdio_alloc_irq(adapter_to_dvobj(padapter)) != _SUCCESS) */
-	if ((padapter->intf_alloc_irq) && (padapter->intf_alloc_irq(adapter_to_dvobj(padapter)) != _SUCCESS)) {
-		ret = -1;
-		goto exit;
-	}
+	if ((padapter->intf_alloc_irq) && (padapter->intf_alloc_irq(adapter_to_dvobj(padapter)) != _SUCCESS))
+		return -1;

drivers/staging/rtl8723bs/os_dep/os_intfs.c static int rtw_resume_process_normal(struct adapter *padapter) · line 1147

Quoted 10 lines
drivers/staging/rtl8723bs/os_dep/os_intfs.c +2 -4
 
 	rtw_reset_drv_sw(padapter);
 	pwrpriv->bkeepfwalive = false;
 
-	if (pm_netdev_open(pnetdev, true) != 0) {
-		ret = -1;
-		goto exit;
-	}
+	if (pm_netdev_open(pnetdev, true) != 0)
+		return -1;

Like here, the irq is allocated, but an error happened, so what happened to that irq?

thanks,

greg k-h

#2 lore raw

Ok, i will try to fix it in v2. Is it better to use a different subject like 'Improve error handling' rather than 'Simplify'?

Thanks,
Bera

maintainer
#3 lore raw
Quoted 2 lines · Bera Yüzlü

Ok, i will try to fix it in v2. Is it better to use a different subject like 'Improve error handling' rather than 'Simplify'?

I have no context here, sorry :(

Remember, some of us get 1000+ emails a day to handle.

If you really are improving the error handling, great, that's an improvement. If you are only simplifying it, well...

thanks,

greg k-h