* [PATCH] staging: rtl8192e: replace explicit NULL comparison
@ 2017-02-23 20:06 Gargi Sharma
2017-02-23 20:32 ` [Outreachy kernel] " Julia Lawall
0 siblings, 1 reply; 4+ messages in thread
From: Gargi Sharma @ 2017-02-23 20:06 UTC (permalink / raw)
To: outreachy-kernel; +Cc: gregkh, Gargi Sharma
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
Signed-off-by: Gargi Sharma <gs051095@gmail.com>
---
drivers/staging/rtl8192e/rtl819x_BAProc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c
index 20260af..1d39631 100644
--- a/drivers/staging/rtl8192e/rtl819x_BAProc.c
+++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c
@@ -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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Outreachy kernel] [PATCH] staging: rtl8192e: replace explicit NULL comparison
2017-02-23 20:06 [PATCH] staging: rtl8192e: replace explicit NULL comparison Gargi Sharma
@ 2017-02-23 20:32 ` Julia Lawall
2017-02-23 20:39 ` Gargi Sharma
2017-02-24 17:26 ` Greg KH
0 siblings, 2 replies; 4+ messages in thread
From: Julia Lawall @ 2017-02-23 20:32 UTC (permalink / raw)
To: Gargi Sharma; +Cc: outreachy-kernel, gregkh
On Fri, 24 Feb 2017, Gargi Sharma wrote:
> 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
>
> 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
>
> Signed-off-by: Gargi Sharma <gs051095@gmail.com>
> ---
> drivers/staging/rtl8192e/rtl819x_BAProc.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c
> index 20260af..1d39631 100644
> --- a/drivers/staging/rtl8192e/rtl819x_BAProc.c
> +++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c
> @@ -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 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/1487880419-28962-1-git-send-email-gs051095%40gmail.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: rtl8192e: replace explicit NULL comparison
2017-02-23 20:32 ` [Outreachy kernel] " Julia Lawall
@ 2017-02-23 20:39 ` Gargi Sharma
2017-02-24 17:26 ` Greg KH
1 sibling, 0 replies; 4+ messages in thread
From: Gargi Sharma @ 2017-02-23 20:39 UTC (permalink / raw)
To: Julia Lawall; +Cc: outreachy-kernel, Greg KH
[-- Attachment #1: Type: text/plain, Size: 2495 bytes --]
On Fri, Feb 24, 2017 at 2:02 AM, Julia Lawall <julia.lawall@lip6.fr> wrote:
>
> On Fri, 24 Feb 2017, Gargi Sharma wrote:
>
> > 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
>
> julia
>
> >
> > 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
> >
> > Signed-off-by: Gargi Sharma <gs051095@gmail.com>
> > ---
> > drivers/staging/rtl8192e/rtl819x_BAProc.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c
b/drivers/staging/rtl8192e/rtl819x_BAProc.c
> > index 20260af..1d39631 100644
> > --- a/drivers/staging/rtl8192e/rtl819x_BAProc.c
> > +++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c
> > @@ -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 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/1487880419-28962-1-git-send-
email-gs051095%40gmail.com.
> > For more options, visit https://groups.google.com/d/optout.
> >
[-- Attachment #2: Type: text/html, Size: 3809 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Outreachy kernel] [PATCH] staging: rtl8192e: replace explicit NULL comparison
2017-02-23 20:32 ` [Outreachy kernel] " Julia Lawall
2017-02-23 20:39 ` Gargi Sharma
@ 2017-02-24 17:26 ` Greg KH
1 sibling, 0 replies; 4+ messages in thread
From: Greg KH @ 2017-02-24 17:26 UTC (permalink / raw)
To: Julia Lawall; +Cc: Gargi Sharma, outreachy-kernel
On Thu, Feb 23, 2017 at 09:32:32PM +0100, Julia Lawall wrote:
> On Fri, 24 Feb 2017, Gargi Sharma wrote:
>
> > 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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-02-24 17:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-23 20:06 [PATCH] staging: rtl8192e: replace explicit NULL comparison Gargi Sharma
2017-02-23 20:32 ` [Outreachy kernel] " Julia Lawall
2017-02-23 20:39 ` Gargi Sharma
2017-02-24 17:26 ` Greg KH
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.