Staging: irda: drivers: Replace (skb == NULL) with (!skb)
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
@@ -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
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
)Signed-off-by Meghana Madhyastha <[email protected]>
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
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
-1self->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.
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
Signed-off-by Meghana Madhyastha <[email protected]>Acked-by drivers/staging/irda/drivers/ali-ircc.c
Odd acked-by signature :)
Julia Lawall
Acked-byQuoted 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
Signed-off-by Meghana Madhyastha <[email protected]>Acked-by drivers/staging/irda/drivers/ali-ircc.cOdd 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.