Skip to contentSkip to conversation

staging: r8188eu: keep the success path and error path separate

PATCH Superseded Vihas Makwana 2 participants 2 messages Feb 9, 2022 Staging

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: r8188eu: keep the success path and error path separate

Keep the success path and error path separate in rtw_usb_if1_init() and drop the "status" variable.
Also, remove do-nothing gotos.

---
 drivers/staging/r8188eu/os_dep/usb_intf.c | 29 ++++++++++-------------
 1 file changed, 12 insertions(+), 17 deletions(-)
drivers/staging/r8188eu/os_dep/usb_intf.c +12 -17
index 10c33e2ae..4ddf3a95a 100644
@@ -336,13 +336,13 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj,
 {
 	struct adapter *padapter = NULL;
 	struct net_device *pnetdev = NULL;
-	int status = _FAIL;
 	struct io_priv *piopriv;
 	struct intf_hdl *pintf;
 
 	padapter = vzalloc(sizeof(*padapter));
 	if (!padapter)
-		goto exit;
+		return NULL;
+
 	padapter->dvobj = dvobj;
 	dvobj->if1 = padapter;
 
@@ -421,25 +421,20 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj,
 		, padapter->hw_init_completed
 	);
 
-	status = _SUCCESS;
+	return padapter;
 
 free_drv_sw:
-	if (status != _SUCCESS) {
-		rtw_cancel_all_timer(padapter);
-		rtw_free_drv_sw(padapter);
-	}
+	rtw_cancel_all_timer(padapter);
+	rtw_free_drv_sw(padapter);
 handle_dualmac:
-	if (status != _SUCCESS)
-		rtw_handle_dualmac(padapter, 0);
+	rtw_handle_dualmac(padapter, 0);
 free_adapter:
-	if (status != _SUCCESS) {
-		if (pnetdev)
-			rtw_free_netdev(pnetdev);
-		else if (padapter)
-			vfree(padapter);
-		padapter = NULL;
-	}
-exit:
+	if (pnetdev)
+		rtw_free_netdev(pnetdev);
+	else if (padapter)
+		vfree(padapter);
+	padapter = NULL;
+
 	return padapter;
 }
 
Signature · 1 line
2.30.2
#1 lore raw

Hi Vihas,

drivers/staging/r8188eu/os_dep/usb_intf.c static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, · line 439

Quoted 9 lines · Vihas Makwana
drivers/staging/r8188eu/os_dep/usb_intf.c +6 -1
-exit:
+	if (pnetdev)
+		rtw_free_netdev(pnetdev);
+	else if (padapter)
+		vfree(padapter);
+	padapter = NULL;
+
  	return padapter;
  }

Why just not return NULL?

With regards,
Pavel Skripkin