All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] staging: rtl8192e: Clean up the tests on results of functions which return NULL on failure
@ 2016-03-06  9:55 G Pooja Shamili
  0 siblings, 0 replies; only message in thread
From: G Pooja Shamili @ 2016-03-06  9:55 UTC (permalink / raw)
  To: outreachy-kernel

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

Signed-off-by: G Pooja Shamili <poojashamili@gmail.com>
---
Changes from Version 1:
	    * Changed the name in the From: and Signed-off-by: to full
	     name.


 drivers/staging/rtl8192e/rtllib_crypt_ccmp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
index 496de4f..5b893e4 100644
--- a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
+++ b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
@@ -63,7 +63,7 @@ static void *rtllib_ccmp_init(int key_idx)
 	struct rtllib_ccmp_data *priv;
 
 	priv = kzalloc(sizeof(*priv), GFP_ATOMIC);
-	if (priv == NULL)
+	if (!priv)
 		goto fail;
 	priv->key_idx = key_idx;
 
-- 
2.1.4



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-03-06  9:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-06  9:55 [PATCH v2] staging: rtl8192e: Clean up the tests on results of functions which return NULL on failure G Pooja Shamili

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.