Skip to contentSkip to conversation

staging: rtl8192e: Clean up tests on the results of functions that return a NULL on failure.

PATCH New G Pooja Shamili 1 participant 1 message Mar 6, 2016 Staging

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 staging: rtl8192e: Clean up tests on the results of functions that return a NULL on failure.

Functions returning NULL as a return value on failure can be tested for as !x, NULL == x or x == NULL. As !x is commonly used, all the tests need to be modified to use !x for a consistent coding style. In this patch, the function kzalloc is considered. Coccinelle is used to achieve this, the semantic patch being:

@@
expression E;
statement S;
@@

E = kzalloc(...);

if (
(
+ !
E
- == NULL
|
+ !
- NULL ==
E
)
) S

---
Changes from Version 1:
* Changed the name in the From: and Signed-off-by: to full name.

 drivers/staging/rtl8192e/rtllib_crypt_tkip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8192e/rtllib_crypt_tkip.c +1 -1
index 2096d78..0907d3c 100644
@@ -62,7 +62,7 @@ static void *rtllib_tkip_init(int key_idx)
 	struct rtllib_tkip_data *priv;
 
 	priv = kzalloc(sizeof(*priv), GFP_ATOMIC);
-	if (priv == NULL)
+	if (!priv)
 		goto fail;
 	priv->key_idx = key_idx;
 	priv->tx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0,
Signature · 1 line
2.1.4