Skip to contentSkip to conversation

staging: rtl8192e: replace explicit NULL comparison

PATCH In review Gargi Sharma 3 participants 4 messages Feb 23, 2017 – Feb 24, 2017 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: rtl8192e: replace explicit NULL comparison

Replace explicit NULL comparison with ! operator to simplify code.

Found with Coccinelle script:
@@
expression ptr;
position p;
statement s0, s1;
@@

ptr@p = \(kmalloc\|devm_kzalloc\|kmalloc_array\|devm_ioremap\|usb_alloc_urb\| alloc_netdev\|dev_alloc_skb\)(...)
... when != ptr

if (
(
+ !
ptr
- == NULL
)
) s0 else s1

---
 drivers/staging/rtl8192e/rtl819x_BAProc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rtl8192e/rtl819x_BAProc.c +2 -2
index 20260af..1d39631 100644
@@ -88,7 +88,7 @@ static struct sk_buff *rtllib_ADDBA(struct rtllib_device *ieee, u8 *Dst,
 		return NULL;
 	}
 	skb = dev_alloc_skb(len + sizeof(struct rtllib_hdr_3addr));
-	if (skb == NULL)
+	if (!skb)
 		return NULL;
 
 	memset(skb->data, 0, sizeof(struct rtllib_hdr_3addr));
@@ -154,7 +154,7 @@ static struct sk_buff *rtllib_DELBA(struct rtllib_device *ieee, u8 *dst,
 	DelbaParamSet.field.TID	= pBA->BaParamSet.field.TID;
 
 	skb = dev_alloc_skb(len + sizeof(struct rtllib_hdr_3addr));
-	if (skb == NULL)
+	if (!skb)
 		return NULL;
 
 	skb_reserve(skb, ieee->tx_headroom);
Signature · 1 line
2.7.4
#1 lore raw
Quoted 2 lines · Gargi Sharma

Replace explicit NULL comparison with ! operator to simplify code.

This change is already made in my kernel, suggesting that I already acked some other patch doing the same thing.

julia

Quoted 58 lines

Found with Coccinelle script:
@@
expression ptr;
position p;
statement s0, s1;
@@

ptr@p = \(kmalloc\|devm_kzalloc\|kmalloc_array\|devm_ioremap\|usb_alloc_urb\| alloc_netdev\|dev_alloc_skb\)(...)
... when != ptr

if (
(
+ !
ptr
- == NULL
)
) s0 else s1

---
 drivers/staging/rtl8192e/rtl819x_BAProc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rtl8192e/rtl819x_BAProc.c +2 -3
index 20260af..1d39631 100644
@@ -88,7 +88,7 @@ static struct sk_buff *rtllib_ADDBA(struct rtllib_device *ieee, u8 *Dst,
 		return NULL;
 	}
 	skb = dev_alloc_skb(len + sizeof(struct rtllib_hdr_3addr));
-	if (skb == NULL)
+	if (!skb)
 		return NULL;
 
 	memset(skb->data, 0, sizeof(struct rtllib_hdr_3addr));
@@ -154,7 +154,7 @@ static struct sk_buff *rtllib_DELBA(struct rtllib_device *ieee, u8 *dst,
 	DelbaParamSet.field.TID	= pBA->BaParamSet.field.TID;
 
 	skb = dev_alloc_skb(len + sizeof(struct rtllib_hdr_3addr));
-	if (skb == NULL)
+	if (!skb)
 		return NULL;
 
 	skb_reserve(skb, ieee->tx_headroom);
--

2.7.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/1487880419-28962-1-git-send-email-gs051095%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

#2 lore raw
Quoted 8 lines · Julia Lawall
Quoted 2 lines · Gargi Sharma

Replace explicit NULL comparison with ! operator to simplify code.

This change is already made in my kernel, suggesting that I already acked some other patch doing the same thing.

Sorry, my bad. Somebody used checkpatch to detect this, and did indeed make the
same changes. I'll redact this patch.

thanks,
gargi

Quoted 24 lines

julia

Quoted 21 lines

Found with Coccinelle script:
@@
expression ptr;
position p;
statement s0, s1;
@@

ptr@p = \(kmalloc\|devm_kzalloc\|kmalloc_array\|devm_ioremap\|usb_alloc_urb\| alloc_netdev\|dev_alloc_skb\)(...)
... when != ptr

if (
(
+ !
ptr
- == NULL
)
) s0 else s1

Quoted 6 lines

Review

Quoted 6 lines
---
 drivers/staging/rtl8192e/rtl819x_BAProc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/staging/rtl8192e/rtl819x_BAProc.c

Quoted 4 lines

drivers/staging/rtl8192e/rtl819x_BAProc.c static struct sk_buff *rtllib_ADDBA(struct

Quoted 4 lines

index 20260af..1d39631 100644

drivers/staging/rtl8192e/rtl819x_BAProc.c +0 -0
@@ -88,7 +88,7 @@ static struct sk_buff *rtllib_ADDBA(struct

rtllib_device *ieee, u8 *Dst,

Quoted 9 lines

drivers/staging/rtl8192e/rtl819x_BAProc.c static struct sk_buff *rtllib_DELBA(struct

Quoted 9 lines
drivers/staging/rtl8192e/rtl819x_BAProc.c +1 -1
              return NULL;
      }
      skb = dev_alloc_skb(len + sizeof(struct rtllib_hdr_3addr));
-     if (skb == NULL)
+     if (!skb)
              return NULL;
 
      memset(skb->data, 0, sizeof(struct rtllib_hdr_3addr));
@@ -154,7 +154,7 @@ static struct sk_buff *rtllib_DELBA(struct

rtllib_device *ieee, u8 *dst,

Quoted 7 lines
Quoted 7 lines
drivers/staging/rtl8192e/rtl819x_BAProc.c +1 -1
      DelbaParamSet.field.TID = pBA->BaParamSet.field.TID;
 
      skb = dev_alloc_skb(len + sizeof(struct rtllib_hdr_3addr));
-     if (skb == NULL)
+     if (!skb)
              return NULL;
 
Quoted 6 lines
Quoted 6 lines
drivers/staging/rtl8192e/rtl819x_BAProc.c +0 -1
      skb_reserve(skb, ieee->tx_headroom);
--

2.7.4

--
You received this message because you are subscribed to the Google

Groups "outreachy-kernel" group.

Quoted 1 line
Quoted 1 line

To unsubscribe from this group and stop receiving emails from it, send

an email to [email protected].

Quoted 2 lines
Quoted 2 lines

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/1487880419-28962-1-git-send- email-gs051095%40gmail.com.

Quoted 2 lines
Quoted 2 lines

For more options, visit https://groups.google.com/d/optout.

maintainer
#3 lore raw
In reply to Julia Lawall
Quoted 7 lines · Julia Lawall
Quoted 2 lines · Gargi Sharma

Replace explicit NULL comparison with ! operator to simplify code.

This change is already made in my kernel, suggesting that I already acked some other patch doing the same thing.

Really? I don't see it in mine, so I'll go take it :)

thanks,

greg k-h