All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Staging: irda: drivers: Replace (skb == NULL) with (!skb)
@ 2017-09-15  9:13 Meghana Madhyastha
  2017-09-15 10:42 ` [Outreachy kernel] " Julia Lawall
  0 siblings, 1 reply; 4+ messages in thread
From: Meghana Madhyastha @ 2017-09-15  9:13 UTC (permalink / raw)
  To: outreachy-kernel

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
)

Signed-off-by: Meghana Madhyastha <meghana.madhyastha@gmail.com>
---
 drivers/staging/irda/drivers/ali-ircc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/irda/drivers/ali-ircc.c b/drivers/staging/irda/drivers/ali-ircc.c
index 35f198d..756ae53 100644
--- a/drivers/staging/irda/drivers/ali-ircc.c
+++ b/drivers/staging/irda/drivers/ali-ircc.c
@@ -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++;
 
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Outreachy kernel] [PATCH] Staging: irda: drivers: Replace (skb == NULL) with (!skb)
  2017-09-15  9:13 [PATCH] Staging: irda: drivers: Replace (skb == NULL) with (!skb) Meghana Madhyastha
@ 2017-09-15 10:42 ` Julia Lawall
  2017-09-18  9:48   ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Julia Lawall @ 2017-09-15 10:42 UTC (permalink / raw)
  To: Meghana Madhyastha; +Cc: outreachy-kernel



On Fri, 15 Sep 2017, Meghana Madhyastha wrote:

> 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 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.

> |
> -if (NULL == i)
> +if (!i)
> S
> )
>
> Signed-off-by: Meghana Madhyastha <meghana.madhyastha@gmail.com>

Acked-by: drivers/staging/irda/drivers/ali-ircc.c

> ---
>  drivers/staging/irda/drivers/ali-ircc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/irda/drivers/ali-ircc.c b/drivers/staging/irda/drivers/ali-ircc.c
> index 35f198d..756ae53 100644
> --- a/drivers/staging/irda/drivers/ali-ircc.c
> +++ b/drivers/staging/irda/drivers/ali-ircc.c
> @@ -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

>  				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 outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> 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.
>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Outreachy kernel] [PATCH] Staging: irda: drivers: Replace (skb == NULL) with (!skb)
  2017-09-18  9:48   ` Greg KH
@ 2017-09-18  9:48     ` Julia Lawall
  0 siblings, 0 replies; 4+ messages in thread
From: Julia Lawall @ 2017-09-18  9:48 UTC (permalink / raw)
  To: Greg KH; +Cc: Julia Lawall, Meghana Madhyastha, outreachy-kernel



On Mon, 18 Sep 2017, Greg KH wrote:

> On Fri, Sep 15, 2017 at 12:42:42PM +0200, Julia Lawall wrote:
> >
> >
> > On Fri, 15 Sep 2017, Meghana Madhyastha wrote:
> >
> > > 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 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.
> >
> > > |
> > > -if (NULL == i)
> > > +if (!i)
> > > S
> > > )
> > >
> > > Signed-off-by: Meghana Madhyastha <meghana.madhyastha@gmail.com>
> >
> > Acked-by: drivers/staging/irda/drivers/ali-ircc.c
>
> Odd acked-by signature :)

Oops :)

Acked-by: Julia Lawall <julia.lawall@lip6.fr>


>
> --
> 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 outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> 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.
>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Outreachy kernel] [PATCH] Staging: irda: drivers: Replace (skb == NULL) with (!skb)
  2017-09-15 10:42 ` [Outreachy kernel] " Julia Lawall
@ 2017-09-18  9:48   ` Greg KH
  2017-09-18  9:48     ` Julia Lawall
  0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2017-09-18  9:48 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Meghana Madhyastha, outreachy-kernel

On Fri, Sep 15, 2017 at 12:42:42PM +0200, Julia Lawall wrote:
> 
> 
> On Fri, 15 Sep 2017, Meghana Madhyastha wrote:
> 
> > 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 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.
> 
> > |
> > -if (NULL == i)
> > +if (!i)
> > S
> > )
> >
> > Signed-off-by: Meghana Madhyastha <meghana.madhyastha@gmail.com>
> 
> Acked-by: drivers/staging/irda/drivers/ali-ircc.c

Odd acked-by signature :)



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-09-18  9:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-15  9:13 [PATCH] Staging: irda: drivers: Replace (skb == NULL) with (!skb) Meghana Madhyastha
2017-09-15 10:42 ` [Outreachy kernel] " Julia Lawall
2017-09-18  9:48   ` Greg KH
2017-09-18  9:48     ` Julia Lawall

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.