Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Bhumika Goyal and committed by
Greg Kroah-Hartman
9155c924 bb106dc0

+12 -12
+1 -1
drivers/staging/rtl8712/recv_linux.c
··· 56 56 57 57 precvbuf->irp_pending = false; 58 58 precvbuf->purb = usb_alloc_urb(0, GFP_KERNEL); 59 - if (precvbuf->purb == NULL) 59 + if (!precvbuf->purb) 60 60 res = _FAIL; 61 61 precvbuf->pskb = NULL; 62 62 precvbuf->reuse = false;
+1 -1
drivers/staging/rtl8712/rtl871x_io.c
··· 113 113 struct io_req *pio_req; 114 114 115 115 pio_queue = kmalloc(sizeof(*pio_queue), GFP_ATOMIC); 116 - if (pio_queue == NULL) 116 + if (!pio_queue) 117 117 goto alloc_io_queue_fail; 118 118 INIT_LIST_HEAD(&pio_queue->free_ioreqs); 119 119 INIT_LIST_HEAD(&pio_queue->processing);
+3 -3
drivers/staging/rtl8712/rtl871x_mlme.c
··· 64 64 memset(&pmlmepriv->assoc_ssid, 0, sizeof(struct ndis_802_11_ssid)); 65 65 pbuf = kmalloc_array(MAX_BSS_CNT, sizeof(struct wlan_network), 66 66 GFP_ATOMIC); 67 - if (pbuf == NULL) 67 + if (!pbuf) 68 68 return _FAIL; 69 69 pmlmepriv->free_bss_buf = pbuf; 70 70 pnetwork = (struct wlan_network *)pbuf; ··· 1202 1202 struct setauth_parm *psetauthparm; 1203 1203 1204 1204 pcmd = kmalloc(sizeof(*pcmd), GFP_ATOMIC); 1205 - if (pcmd == NULL) 1205 + if (!pcmd) 1206 1206 return _FAIL; 1207 1207 1208 1208 psetauthparm = kzalloc(sizeof(*psetauthparm), GFP_ATOMIC); ··· 1232 1232 sint ret = _SUCCESS; 1233 1233 1234 1234 pcmd = kmalloc(sizeof(*pcmd), GFP_ATOMIC); 1235 - if (pcmd == NULL) 1235 + if (!pcmd) 1236 1236 return _FAIL; 1237 1237 psetkeyparm = kzalloc(sizeof(*psetkeyparm), GFP_ATOMIC); 1238 1238 if (psetkeyparm == NULL) {
+2 -2
drivers/staging/rtl8712/rtl871x_mp.c
··· 281 281 u16 code = GEN_CMD_CODE(_SetChannel); 282 282 283 283 pcmd = kmalloc(sizeof(*pcmd), GFP_ATOMIC); 284 - if (pcmd == NULL) 284 + if (!pcmd) 285 285 return; 286 286 pparm = kmalloc(sizeof(*pparm), GFP_ATOMIC); 287 - if (pparm == NULL) { 287 + if (!pparm) { 288 288 kfree(pcmd); 289 289 return; 290 290 }
+1 -1
drivers/staging/rtl8712/rtl871x_sta_mgt.c
··· 53 53 54 54 pstapriv->pallocated_stainfo_buf = kmalloc(sizeof(struct sta_info) * 55 55 NUM_STA + 4, GFP_ATOMIC); 56 - if (pstapriv->pallocated_stainfo_buf == NULL) 56 + if (!pstapriv->pallocated_stainfo_buf) 57 57 return _FAIL; 58 58 pstapriv->pstainfo_buf = pstapriv->pallocated_stainfo_buf + 4 - 59 59 ((addr_t)(pstapriv->pallocated_stainfo_buf) & 3);
+4 -4
drivers/staging/rtl8712/rtl871x_xmit.c
··· 89 89 */ 90 90 pxmitpriv->pallocated_frame_buf = kmalloc(NR_XMITFRAME * sizeof(struct xmit_frame) + 4, 91 91 GFP_ATOMIC); 92 - if (pxmitpriv->pallocated_frame_buf == NULL) { 92 + if (!pxmitpriv->pallocated_frame_buf) { 93 93 pxmitpriv->pxmit_frame_buf = NULL; 94 94 return _FAIL; 95 95 } ··· 128 128 _init_queue(&pxmitpriv->pending_xmitbuf_queue); 129 129 pxmitpriv->pallocated_xmitbuf = kmalloc(NR_XMITBUFF * sizeof(struct xmit_buf) + 4, 130 130 GFP_ATOMIC); 131 - if (pxmitpriv->pallocated_xmitbuf == NULL) 131 + if (!pxmitpriv->pallocated_xmitbuf) 132 132 return _FAIL; 133 133 pxmitpriv->pxmitbuf = pxmitpriv->pallocated_xmitbuf + 4 - 134 134 ((addr_t)(pxmitpriv->pallocated_xmitbuf) & 3); ··· 137 137 INIT_LIST_HEAD(&pxmitbuf->list); 138 138 pxmitbuf->pallocated_buf = kmalloc(MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ, 139 139 GFP_ATOMIC); 140 - if (pxmitbuf->pallocated_buf == NULL) 140 + if (!pxmitbuf->pallocated_buf) 141 141 return _FAIL; 142 142 pxmitbuf->pbuf = pxmitbuf->pallocated_buf + XMITBUF_ALIGN_SZ - 143 143 ((addr_t) (pxmitbuf->pallocated_buf) & ··· 943 943 pxmitpriv->hwxmit_entry = HWXMIT_ENTRY; 944 944 pxmitpriv->hwxmits = kmalloc_array(pxmitpriv->hwxmit_entry, 945 945 sizeof(struct hw_xmit), GFP_ATOMIC); 946 - if (pxmitpriv->hwxmits == NULL) 946 + if (!pxmitpriv->hwxmits) 947 947 return; 948 948 hwxmits = pxmitpriv->hwxmits; 949 949 if (pxmitpriv->hwxmit_entry == 5) {