Staging: rtl8192u: Clean up tests if NULL returned on failure
PATCH 1/1 Staging: rtl8192u: Clean up tests if NULL returned on failure
Some functions return Null as their return value on failure. !x is generally preferred over x==NULL or NULL==x. So make use of !x if the value returned on failure is NULL.
Done using coccinelle:
@@
expression e;
statement S;
@@
e = \(kmalloc\|devm_kzalloc\|kmalloc_array
\|devm_ioremap\|usb_alloc_urb\|alloc_netdev\)(...);
- if(e==NULL)
+ if(!e)
S
--- drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | 2 +- drivers/staging/rtl8192u/r8192U_core.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +1 -1
@@ -1289,7 +1289,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, payload = skb->data + hdrlen;//ethertype = (payload[6] << 8) | payload[7]; rxb =kmalloc (sizeof (struct ieee80211_rxb ),GFP_ATOMIC ); -if (rxb ==NULL ) +if (!rxb) {IEEE80211_DEBUG (IEEE80211_DL_ERR ,"%s(): kmalloc rxb error\n" ,__func__); goto rx_dropped;
drivers/staging/rtl8192u/r8192U_core.c +1 -1
@@ -1732,7 +1732,7 @@ static short rtl8192_usb_initendpoints(struct net_device *dev) priv->rx_urb =kmalloc (sizeof (struct urb *) * (MAX_RX_URB +1 ),GFP_KERNEL ); -if (priv->rx_urb ==NULL ) +if (!priv->rx_urb)return -ENOMEM ;#ifndef JACKSON_NEW_RX
Signature · 1 line
1.9.1
Quoted 25 lines · Bhumika Goyal
Some functions return Null as their return value on failure. !x is generally preferred over x==NULL or NULL==x. So make use of !x if the value returned on failure is NULL.
Done using coccinelle:
@@
expression e;
statement S;
@@
e = \(kmalloc\|devm_kzalloc\|kmalloc_array\|devm_ioremap\|usb_alloc_urb\|alloc_netdev\)(...);- if(e==NULL)
+ if(!e)
SSigned-off-by Bhumika Goyal <[email protected]>--- drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | 2 +- drivers/staging/rtl8192u/r8192U_core.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +0
-0
drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, · line 1294
Quoted 7 lines
drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +1
-1@@ -1289,7 +1289,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, payload = skb->data + hdrlen;//ethertype = (payload[6] << 8) | payload[7]; rxb =kmalloc (sizeof (struct ieee80211_rxb ),GFP_ATOMIC ); -if (rxb ==NULL ) +if (!rxb) {IEEE80211_DEBUG (IEEE80211_DL_ERR ,"%s(): kmalloc rxb error\n" ,__func__);
As in the previous case, this message is not needed.
julia
Quoted 24 lines
drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +0
-0goto rx_dropped;drivers/staging/rtl8192u/r8192U_core.c +1
-1@@ -1732,7 +1732,7 @@ static short rtl8192_usb_initendpoints(struct net_device *dev) priv->rx_urb =kmalloc (sizeof (struct urb *) * (MAX_RX_URB +1 ),GFP_KERNEL ); -if (priv->rx_urb ==NULL ) +if (!priv->rx_urb)return -ENOMEM ;#ifndef JACKSON_NEW_RX Signature · 8 lines
1.9.1 -- 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/1456309055-6392-1-git-send-email-bhumirks%40gmail.com. For more options, visit https://groups.google.com/d/optout.