diff options
author | Bhumika Goyal <bhumirks@gmail.com> | 2016-02-24 16:09:31 +0530 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-03-11 22:09:09 -0800 |
commit | 9155c92463ecbb55c6eca6145e139869e9ba1546 (patch) | |
tree | 91e983d48b730fbdd2a26477e452bc04701fa927 /drivers/staging/rtl8712 | |
parent | bb106dc0e227f7a04d9034cad25913b3c21146a8 (diff) | |
download | linux-stable-9155c92463ecbb55c6eca6145e139869e9ba1546.tar.gz linux-stable-9155c92463ecbb55c6eca6145e139869e9ba1546.tar.bz2 linux-stable-9155c92463ecbb55c6eca6145e139869e9ba1546.zip |
Staging: rtl8712: Clean up tests if NULL returned on failure
Some functions like kmalloc/usb_alloc_urb/kmalloc_array returns 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
by these functions 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>
Diffstat (limited to 'drivers/staging/rtl8712')
-rw-r--r-- | drivers/staging/rtl8712/recv_linux.c | 2 | ||||
-rw-r--r-- | drivers/staging/rtl8712/rtl871x_io.c | 2 | ||||
-rw-r--r-- | drivers/staging/rtl8712/rtl871x_mlme.c | 6 | ||||
-rw-r--r-- | drivers/staging/rtl8712/rtl871x_mp.c | 4 | ||||
-rw-r--r-- | drivers/staging/rtl8712/rtl871x_sta_mgt.c | 2 | ||||
-rw-r--r-- | drivers/staging/rtl8712/rtl871x_xmit.c | 8 |
6 files changed, 12 insertions, 12 deletions
diff --git a/drivers/staging/rtl8712/recv_linux.c b/drivers/staging/rtl8712/recv_linux.c index 2f5460dbda8b..be970efcf645 100644 --- a/drivers/staging/rtl8712/recv_linux.c +++ b/drivers/staging/rtl8712/recv_linux.c @@ -56,7 +56,7 @@ int r8712_os_recvbuf_resource_alloc(struct _adapter *padapter, precvbuf->irp_pending = false; precvbuf->purb = usb_alloc_urb(0, GFP_KERNEL); - if (precvbuf->purb == NULL) + if (!precvbuf->purb) res = _FAIL; precvbuf->pskb = NULL; precvbuf->reuse = false; diff --git a/drivers/staging/rtl8712/rtl871x_io.c b/drivers/staging/rtl8712/rtl871x_io.c index fbbc63570eab..3a10940db9b7 100644 --- a/drivers/staging/rtl8712/rtl871x_io.c +++ b/drivers/staging/rtl8712/rtl871x_io.c @@ -113,7 +113,7 @@ uint r8712_alloc_io_queue(struct _adapter *adapter) struct io_req *pio_req; pio_queue = kmalloc(sizeof(*pio_queue), GFP_ATOMIC); - if (pio_queue == NULL) + if (!pio_queue) goto alloc_io_queue_fail; INIT_LIST_HEAD(&pio_queue->free_ioreqs); INIT_LIST_HEAD(&pio_queue->processing); diff --git a/drivers/staging/rtl8712/rtl871x_mlme.c b/drivers/staging/rtl8712/rtl871x_mlme.c index 1b022dbda046..14a780efba90 100644 --- a/drivers/staging/rtl8712/rtl871x_mlme.c +++ b/drivers/staging/rtl8712/rtl871x_mlme.c @@ -64,7 +64,7 @@ static sint _init_mlme_priv(struct _adapter *padapter) memset(&pmlmepriv->assoc_ssid, 0, sizeof(struct ndis_802_11_ssid)); pbuf = kmalloc_array(MAX_BSS_CNT, sizeof(struct wlan_network), GFP_ATOMIC); - if (pbuf == NULL) + if (!pbuf) return _FAIL; pmlmepriv->free_bss_buf = pbuf; pnetwork = (struct wlan_network *)pbuf; @@ -1202,7 +1202,7 @@ sint r8712_set_auth(struct _adapter *adapter, struct setauth_parm *psetauthparm; pcmd = kmalloc(sizeof(*pcmd), GFP_ATOMIC); - if (pcmd == NULL) + if (!pcmd) return _FAIL; psetauthparm = kzalloc(sizeof(*psetauthparm), GFP_ATOMIC); @@ -1232,7 +1232,7 @@ sint r8712_set_key(struct _adapter *adapter, sint ret = _SUCCESS; pcmd = kmalloc(sizeof(*pcmd), GFP_ATOMIC); - if (pcmd == NULL) + if (!pcmd) return _FAIL; psetkeyparm = kzalloc(sizeof(*psetkeyparm), GFP_ATOMIC); if (psetkeyparm == NULL) { diff --git a/drivers/staging/rtl8712/rtl871x_mp.c b/drivers/staging/rtl8712/rtl871x_mp.c index 44da4fe89381..9b5a4e7ff060 100644 --- a/drivers/staging/rtl8712/rtl871x_mp.c +++ b/drivers/staging/rtl8712/rtl871x_mp.c @@ -281,10 +281,10 @@ void r8712_SetChannel(struct _adapter *pAdapter) u16 code = GEN_CMD_CODE(_SetChannel); pcmd = kmalloc(sizeof(*pcmd), GFP_ATOMIC); - if (pcmd == NULL) + if (!pcmd) return; pparm = kmalloc(sizeof(*pparm), GFP_ATOMIC); - if (pparm == NULL) { + if (!pparm) { kfree(pcmd); return; } diff --git a/drivers/staging/rtl8712/rtl871x_sta_mgt.c b/drivers/staging/rtl8712/rtl871x_sta_mgt.c index 3fe45b6d4853..e90c00de7499 100644 --- a/drivers/staging/rtl8712/rtl871x_sta_mgt.c +++ b/drivers/staging/rtl8712/rtl871x_sta_mgt.c @@ -53,7 +53,7 @@ u32 _r8712_init_sta_priv(struct sta_priv *pstapriv) pstapriv->pallocated_stainfo_buf = kmalloc(sizeof(struct sta_info) * NUM_STA + 4, GFP_ATOMIC); - if (pstapriv->pallocated_stainfo_buf == NULL) + if (!pstapriv->pallocated_stainfo_buf) return _FAIL; pstapriv->pstainfo_buf = pstapriv->pallocated_stainfo_buf + 4 - ((addr_t)(pstapriv->pallocated_stainfo_buf) & 3); diff --git a/drivers/staging/rtl8712/rtl871x_xmit.c b/drivers/staging/rtl8712/rtl871x_xmit.c index 506136ca6b44..c6d952f5d8f9 100644 --- a/drivers/staging/rtl8712/rtl871x_xmit.c +++ b/drivers/staging/rtl8712/rtl871x_xmit.c @@ -89,7 +89,7 @@ sint _r8712_init_xmit_priv(struct xmit_priv *pxmitpriv, */ pxmitpriv->pallocated_frame_buf = kmalloc(NR_XMITFRAME * sizeof(struct xmit_frame) + 4, GFP_ATOMIC); - if (pxmitpriv->pallocated_frame_buf == NULL) { + if (!pxmitpriv->pallocated_frame_buf) { pxmitpriv->pxmit_frame_buf = NULL; return _FAIL; } @@ -128,7 +128,7 @@ sint _r8712_init_xmit_priv(struct xmit_priv *pxmitpriv, _init_queue(&pxmitpriv->pending_xmitbuf_queue); pxmitpriv->pallocated_xmitbuf = kmalloc(NR_XMITBUFF * sizeof(struct xmit_buf) + 4, GFP_ATOMIC); - if (pxmitpriv->pallocated_xmitbuf == NULL) + if (!pxmitpriv->pallocated_xmitbuf) return _FAIL; pxmitpriv->pxmitbuf = pxmitpriv->pallocated_xmitbuf + 4 - ((addr_t)(pxmitpriv->pallocated_xmitbuf) & 3); @@ -137,7 +137,7 @@ sint _r8712_init_xmit_priv(struct xmit_priv *pxmitpriv, INIT_LIST_HEAD(&pxmitbuf->list); pxmitbuf->pallocated_buf = kmalloc(MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ, GFP_ATOMIC); - if (pxmitbuf->pallocated_buf == NULL) + if (!pxmitbuf->pallocated_buf) return _FAIL; pxmitbuf->pbuf = pxmitbuf->pallocated_buf + XMITBUF_ALIGN_SZ - ((addr_t) (pxmitbuf->pallocated_buf) & @@ -943,7 +943,7 @@ static void alloc_hwxmits(struct _adapter *padapter) pxmitpriv->hwxmit_entry = HWXMIT_ENTRY; pxmitpriv->hwxmits = kmalloc_array(pxmitpriv->hwxmit_entry, sizeof(struct hw_xmit), GFP_ATOMIC); - if (pxmitpriv->hwxmits == NULL) + if (!pxmitpriv->hwxmits) return; hwxmits = pxmitpriv->hwxmits; if (pxmitpriv->hwxmit_entry == 5) { |