]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
Staging: rtl8192u: Clean up tests if NULL returned on failure
authorBhumika Goyal <bhumirks@gmail.com>
Wed, 24 Feb 2016 10:17:35 +0000 (15:47 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 12 Mar 2016 06:09:09 +0000 (22:09 -0800)
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

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
drivers/staging/rtl8192u/r8192U_core.c

index 9dfde0794b800d33d30d5999c5e29d4db8ddd9fb..879c41367e7a21b8f3d1314a68c9e5d78d622ed6 100644 (file)
@@ -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;
index 3a93218f320b787e1a5070249cebbb6b280a050e..849a95ef723c6e2d6602b51bbeba836b6f0ab63b 100644 (file)
@@ -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