Skip to contentSkip to conversation

Staging: irda: drivers: Replace (skb == NULL) with (!skb)

PATCH In review Meghana Madhyastha 3 participants 4 messages Sep 15, 2017 – Sep 18, 2017 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: irda: drivers: Replace (skb == NULL) with (!skb)

Some functions return NULL as an indication of failure. The style (!skb) is more common than (skb == NULL) for these functions.

Found by the following Coccinelle script.

@@
identifier i;
statement S;
@@

i = (\(kmalloc\|devm_kzalloc\|kmalloc_array\|devm_ioremap\|usb_alloc_urb\| alloc_netdev\|dev_alloc_skb\)(...));

(
-if (i == NULL)
+if (!i)
S
|
-if (NULL == i)
+if (!i)
S
)

---
 drivers/staging/irda/drivers/ali-ircc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/irda/drivers/ali-ircc.c +1 -1
index 35f198d..756ae53 100644
@@ -1876,7 +1876,7 @@ static int  ali_ircc_dma_receive_complete(struct ali_ircc_cb *self)
 			self->stamp = ktime_get();
 
 			skb = dev_alloc_skb(len+1);
-			if (skb == NULL)  
+			if (!skb)
 			{
 				self->netdev->stats.rx_dropped++;
 
Signature · 1 line
2.7.4
Acked-by drivers/staging/irda/drivers/ali-ircc.c on v1 1/1
#1 lore raw
Quoted 17 lines · Meghana Madhyastha

Some functions return NULL as an indication of failure. The style (!skb) is more common than (skb == NULL) for these functions.

Found by the following Coccinelle script.

@@
identifier i;
statement S;
@@

i = (\(kmalloc\|devm_kzalloc\|kmalloc_array\|devm_ioremap\|usb_alloc_urb\| alloc_netdev\|dev_alloc_skb\)(...));

(

(quoted diff) +1 -1
-if (i == NULL)
+if (!i)
Quoted 1 line

S

If you provide just this option, Coccinelle should expand your rule to consider the other option as well.

You can see the section on isomorphisms in the Coccinelle tutorial.

Quoted 7 lines

|

(quoted diff) +1 -1
-if (NULL == i)
+if (!i)

S
)

Acked-by drivers/staging/irda/drivers/ali-ircc.c
Quoted 9 lines
---
 drivers/staging/irda/drivers/ali-ircc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/irda/drivers/ali-ircc.c +0 -0
index 35f198d..756ae53 100644

drivers/staging/irda/drivers/ali-ircc.c static int ali_ircc_dma_receive_complete(struct ali_ircc_cb *self) · line 1880

Quoted 6 lines
drivers/staging/irda/drivers/ali-ircc.c +1 -1
@@ -1876,7 +1876,7 @@ static int  ali_ircc_dma_receive_complete(struct ali_ircc_cb *self)
 			self->stamp = ktime_get();
 
 			skb = dev_alloc_skb(len+1);
-			if (skb == NULL)
+			if (!skb)
 			{

It's not related to the change in your patch, but this brace should b up on the line before.

julia

Quoted 12 lines
drivers/staging/irda/drivers/ali-ircc.c +0 -1
 				self->netdev->stats.rx_dropped++;
 
--

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/20170915091310.GA21039%40meghana-HP-Pavilion-Notebook.
For more options, visit https://groups.google.com/d/optout.

#2 lore raw
Quoted 34 lines · Julia Lawall
Quoted 17 lines · Meghana Madhyastha

Some functions return NULL as an indication of failure. The style (!skb) is more common than (skb == NULL) for these functions.

Found by the following Coccinelle script.

@@
identifier i;
statement S;
@@

i = (\(kmalloc\|devm_kzalloc\|kmalloc_array\|devm_ioremap\|usb_alloc_urb\| alloc_netdev\|dev_alloc_skb\)(...));

(

(quoted diff) +1 -1
-if (i == NULL)
+if (!i)
Quoted 1 line

S

If you provide just this option, Coccinelle should expand your rule to consider the other option as well.

You can see the section on isomorphisms in the Coccinelle tutorial.

Quoted 6 lines

|

(quoted diff) +1 -1
-if (NULL == i)
+if (!i)

S
)

Quoted 3 lines
Quoted 1 line
Acked-by drivers/staging/irda/drivers/ali-ircc.c

Odd acked-by signature :)

Acked-by
#3 lore raw
Quoted 35 lines · Greg KH
Quoted 34 lines · Julia Lawall
Quoted 17 lines · Meghana Madhyastha

Some functions return NULL as an indication of failure. The style (!skb) is more common than (skb == NULL) for these functions.

Found by the following Coccinelle script.

@@
identifier i;
statement S;
@@

i = (\(kmalloc\|devm_kzalloc\|kmalloc_array\|devm_ioremap\|usb_alloc_urb\| alloc_netdev\|dev_alloc_skb\)(...));

(

(quoted diff) +1 -1
-if (i == NULL)
+if (!i)
Quoted 1 line

S

If you provide just this option, Coccinelle should expand your rule to consider the other option as well.

You can see the section on isomorphisms in the Coccinelle tutorial.

Quoted 6 lines

|

(quoted diff) +1 -1
-if (NULL == i)
+if (!i)

S
)

Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Acked-by drivers/staging/irda/drivers/ali-ircc.c

Odd acked-by signature :)

Oops :)

Quoted 8 lines

--
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/20170918094843.GA24318%40kroah.com.
For more options, visit https://groups.google.com/d/optout.