Skip to contentSkip to conversation

staging: rtl8712: Make return of 0 explicit

PATCH Superseded Bhaktipriya Shridhar 2 participants 3 messages Feb 25, 2016 Staging

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 staging: rtl8712: Make return of 0 explicit

Delete unnecessary local variable whose value is always 0 and return 0 as the result.
The following Coccinelle script was used:

@@
identifier ret; expression E;
type T;
@@
(
- T ret;
|
- T ret = 0;
)

... when != \(ret=E \|ret--\|ret++\|--ret\|++ret\|ret-=E\|ret+=E\|ret|=E\|ret&=E\) (
?-ret = 0;
)
... when != \(ret=E \|ret--\|ret++\|--ret\|++ret\|ret-=E\|ret+=E\|ret|=E\|ret&=E\) (
return
- ret
+ 0
;
)

---
 drivers/staging/rtl8712/xmit_linux.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/staging/rtl8712/xmit_linux.c +2 -6
index adb51f0..8c15308 100644
@@ -163,19 +163,15 @@ int r8712_xmit_entry(_pkt *pkt, struct  net_device *pnetdev)
 	struct xmit_frame *pxmitframe = NULL;
 	struct _adapter *padapter = netdev_priv(pnetdev);
 	struct xmit_priv *pxmitpriv = &(padapter->xmitpriv);
-	int ret = 0;
 
 	if (!r8712_if_up(padapter)) {
-		ret = 0;
 		goto _xmit_entry_drop;
 	}
 	pxmitframe = r8712_alloc_xmitframe(pxmitpriv);
 	if (!pxmitframe) {
-		ret = 0;
 		goto _xmit_entry_drop;
 	}
 	if ((!r8712_update_attrib(padapter, pkt, &pxmitframe->attrib))) {
-		ret = 0;
 		goto _xmit_entry_drop;
 	}
 	padapter->ledpriv.LedControlHandler(padapter, LED_CTL_TX);
@@ -187,11 +183,11 @@ int r8712_xmit_entry(_pkt *pkt, struct  net_device *pnetdev)
 	}
 	pxmitpriv->tx_pkts++;
 	pxmitpriv->tx_bytes += pxmitframe->attrib.last_txcmdsz;
-	return ret;
+	return 0;
 _xmit_entry_drop:
 	if (pxmitframe)
 		r8712_free_xmitframe(pxmitpriv, pxmitframe);
 	pxmitpriv->tx_drop++;
 	dev_kfree_skb_any(pkt);
-	return ret;
+	return 0;
 }

--
2.1.4

#1 lore raw
Quoted 28 lines · Bhaktipriya Shridhar

Delete unnecessary local variable whose value is always 0 and return 0 as the result.
The following Coccinelle script was used:

@@
identifier ret; expression E;
type T;
@@
(
- T ret;
|
- T ret = 0;
)

... when != \(ret=E \|ret--\|ret++\|--ret\|++ret\|ret-=E\|ret+=E\|ret|=E\|ret&=E\) (
?-ret = 0;
)
... when != \(ret=E \|ret--\|ret++\|--ret\|++ret\|ret-=E\|ret+=E\|ret|=E\|ret&=E\) (
return
- ret
+ 0
;
)

Quoted 2 lines

---

Good job on the semantic patch, but you didn't explain v2.

julia

Quoted 51 lines
 drivers/staging/rtl8712/xmit_linux.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/staging/rtl8712/xmit_linux.c +2 -7
index adb51f0..8c15308 100644
@@ -163,19 +163,15 @@ int r8712_xmit_entry(_pkt *pkt, struct  net_device *pnetdev)
 	struct xmit_frame *pxmitframe = NULL;
 	struct _adapter *padapter = netdev_priv(pnetdev);
 	struct xmit_priv *pxmitpriv = &(padapter->xmitpriv);
-	int ret = 0;
 
 	if (!r8712_if_up(padapter)) {
-		ret = 0;
 		goto _xmit_entry_drop;
 	}
 	pxmitframe = r8712_alloc_xmitframe(pxmitpriv);
 	if (!pxmitframe) {
-		ret = 0;
 		goto _xmit_entry_drop;
 	}
 	if ((!r8712_update_attrib(padapter, pkt, &pxmitframe->attrib))) {
-		ret = 0;
 		goto _xmit_entry_drop;
 	}
 	padapter->ledpriv.LedControlHandler(padapter, LED_CTL_TX);
@@ -187,11 +183,11 @@ int r8712_xmit_entry(_pkt *pkt, struct  net_device *pnetdev)
 	}
 	pxmitpriv->tx_pkts++;
 	pxmitpriv->tx_bytes += pxmitframe->attrib.last_txcmdsz;
-	return ret;
+	return 0;
 _xmit_entry_drop:
 	if (pxmitframe)
 		r8712_free_xmitframe(pxmitpriv, pxmitframe);
 	pxmitpriv->tx_drop++;
 	dev_kfree_skb_any(pkt);
-	return ret;
+	return 0;
 }
--

2.1.4

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20160225101549.GA27308%40Karyakshetra.
For more options, visit https://groups.google.com/d/optout.

#2 lore raw

Hello Julia,

Quoted 30 lines · Julia Lawall
Quoted 28 lines · Bhaktipriya Shridhar

Delete unnecessary local variable whose value is always 0 and return 0 as the result.
The following Coccinelle script was used:

@@
identifier ret; expression E;
type T;
@@
(
- T ret;
|
- T ret = 0;
)

... when != \(ret=E \|ret--\|ret++\|--ret\|++ret\|ret-=E\|ret+=E\|ret|=E\|ret&=E\) (
?-ret = 0;
)
... when != \(ret=E \|ret--\|ret++\|--ret\|++ret\|ret-=E\|ret+=E\|ret|=E\|ret&=E\) (
return
- ret
+ 0
;
)

Quoted 4 lines
Quoted 2 lines

---

Good job on the semantic patch, but you didn't explain v2.

Thank you for your guidance. Sorry, it slipped from my mind. I have sent v2 with the explanation.
Please have a look.

Thanks,
Bhaktipriya

Quoted 54 lines

julia

Quoted 51 lines
 drivers/staging/rtl8712/xmit_linux.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/staging/rtl8712/xmit_linux.c +2 -7
index adb51f0..8c15308 100644
@@ -163,19 +163,15 @@ int r8712_xmit_entry(_pkt *pkt, struct  net_device *pnetdev)
      struct xmit_frame *pxmitframe = NULL;
      struct _adapter *padapter = netdev_priv(pnetdev);
      struct xmit_priv *pxmitpriv = &(padapter->xmitpriv);
-     int ret = 0;
 
      if (!r8712_if_up(padapter)) {
-             ret = 0;
              goto _xmit_entry_drop;
      }
      pxmitframe = r8712_alloc_xmitframe(pxmitpriv);
      if (!pxmitframe) {
-             ret = 0;
              goto _xmit_entry_drop;
      }
      if ((!r8712_update_attrib(padapter, pkt, &pxmitframe->attrib))) {
-             ret = 0;
              goto _xmit_entry_drop;
      }
      padapter->ledpriv.LedControlHandler(padapter, LED_CTL_TX);
@@ -187,11 +183,11 @@ int r8712_xmit_entry(_pkt *pkt, struct  net_device *pnetdev)
      }
      pxmitpriv->tx_pkts++;
      pxmitpriv->tx_bytes += pxmitframe->attrib.last_txcmdsz;
-     return ret;
+     return 0;
 _xmit_entry_drop:
      if (pxmitframe)
              r8712_free_xmitframe(pxmitpriv, pxmitframe);
      pxmitpriv->tx_drop++;
      dev_kfree_skb_any(pkt);
-     return ret;
+     return 0;
 }
--

2.1.4

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20160225101549.GA27308%40Karyakshetra.
For more options, visit https://groups.google.com/d/optout.