Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1605433

[PATCH 4/5] netfilter: nfnetlink: Clean up tests if NULL returned on failure

From simran singhal <singhalsimran0@gmail.com>
Newsgroups linux.kernel
Subject [PATCH 4/5] netfilter: nfnetlink: Clean up tests if NULL returned on failure
Date 2017-03-21 09:50 +0100
Message-ID <tnnEm-OE-39@gated-at.bofh.it> (permalink)
References <tnnEl-OE-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Some functions like kmalloc/kzalloc return NULL on failure. When NULL
represents failure, !x is commonly used.

This was done using Coccinelle:
@@
expression *e;
identifier l1;
@@
e = \(kmalloc\|kzalloc\|kcalloc\|devm_kzalloc\)(...);
...
- e == NULL
+ !e

Signed-off-by: simran singhal <singhalsimran0@gmail.com>
---

 --This is my contribution to the netfilter project of
   Outreachy Round 14.

 net/netfilter/nfnetlink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c
index 68eda920..c39f16c 100644
--- a/net/netfilter/nfnetlink.c
+++ b/net/netfilter/nfnetlink.c
@@ -232,7 +232,7 @@ static int nfnl_err_add(struct list_head *list, struct nlmsghdr *nlh, int err)
 	struct nfnl_err *nfnl_err;
 
 	nfnl_err = kmalloc(sizeof(struct nfnl_err), GFP_KERNEL);
-	if (nfnl_err == NULL)
+	if (!nfnl_err)
 		return -ENOMEM;
 
 	nfnl_err->nlh = nlh;
-- 
2.7.4

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/5] netfilter: Clean up tests if NULL returned on failure simran singhal <singhalsimran0@gmail.com> - 2017-03-21 09:50 +0100
  [PATCH 3/5] netfilter: nf_tables_api: Clean up tests if NULL returned on failure simran singhal <singhalsimran0@gmail.com> - 2017-03-21 09:50 +0100
  [PATCH 4/5] netfilter: nfnetlink: Clean up tests if NULL returned on failure simran singhal <singhalsimran0@gmail.com> - 2017-03-21 09:50 +0100
  Re: [PATCH 0/5] netfilter: Clean up tests if NULL returned on failure Pablo Neira Ayuso <pablo@netfilter.org> - 2017-03-22 14:40 +0100
    Re: [PATCH 0/5] netfilter: Clean up tests if NULL returned on failure SIMRAN SINGHAL <singhalsimran0@gmail.com> - 2017-03-22 14:50 +0100

csiph-web