Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1605429 > unrolled thread
| Started by | simran singhal <singhalsimran0@gmail.com> |
|---|---|
| First post | 2017-03-21 09:50 +0100 |
| Last post | 2017-03-22 14:50 +0100 |
| Articles | 5 — 3 participants |
Back to article view | Back to linux.kernel
[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
| From | simran singhal <singhalsimran0@gmail.com> |
|---|---|
| Date | 2017-03-21 09:50 +0100 |
| Subject | [PATCH 0/5] netfilter: Clean up tests if NULL returned on failure |
| Message-ID | <tnnEl-OE-7@gated-at.bofh.it> |
This patch series clean up tests if NULL returned on failure. simran singhal (5): netfilter: ipvs: Clean up tests if NULL returned on failure netfilter: Clean up tests if NULL returned on failure netfilter: nf_tables_api: Clean up tests if NULL returned on failure netfilter: nfnetlink: Clean up tests if NULL returned on failure netfilter: xt_TEE: Clean up tests if NULL returned on failure net/netfilter/ipvs/ip_vs_ctl.c | 4 ++-- net/netfilter/ipvs/ip_vs_dh.c | 2 +- net/netfilter/ipvs/ip_vs_lblc.c | 2 +- net/netfilter/ipvs/ip_vs_lblcr.c | 4 ++-- net/netfilter/ipvs/ip_vs_sh.c | 2 +- net/netfilter/ipvs/ip_vs_wrr.c | 2 +- net/netfilter/nf_conntrack_netlink.c | 2 +- net/netfilter/nf_conntrack_proto.c | 2 +- net/netfilter/nf_nat_core.c | 2 +- net/netfilter/nf_tables_api.c | 24 ++++++++++++------------ net/netfilter/nfnetlink.c | 2 +- net/netfilter/xt_TEE.c | 2 +- 12 files changed, 25 insertions(+), 25 deletions(-) -- 2.7.4
[toc] | [next] | [standalone]
| From | simran singhal <singhalsimran0@gmail.com> |
|---|---|
| Date | 2017-03-21 09:50 +0100 |
| Subject | [PATCH 3/5] netfilter: nf_tables_api: Clean up tests if NULL returned on failure |
| Message-ID | <tnnEm-OE-41@gated-at.bofh.it> |
| In reply to | #1605429 |
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/nf_tables_api.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 5e0ccfd..25a3951 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -117,7 +117,7 @@ static struct nft_trans *nft_trans_alloc_gfp(const struct nft_ctx *ctx,
struct nft_trans *trans;
trans = kzalloc(sizeof(struct nft_trans) + size, gfp);
- if (trans == NULL)
+ if (!trans)
return NULL;
trans->msg_type = msg_type;
@@ -720,7 +720,7 @@ static int nf_tables_newtable(struct net *net, struct sock *nlsk,
err = -ENOMEM;
table = kzalloc(sizeof(*table), GFP_KERNEL);
- if (table == NULL)
+ if (!table)
goto err2;
nla_strlcpy(table->name, name, NFT_TABLE_MAXNAMELEN);
@@ -1478,7 +1478,7 @@ static int nf_tables_newchain(struct net *net, struct sock *nlsk,
return err;
basechain = kzalloc(sizeof(*basechain), GFP_KERNEL);
- if (basechain == NULL) {
+ if (!basechain) {
nft_chain_release_hook(&hook);
return -ENOMEM;
}
@@ -1526,7 +1526,7 @@ static int nf_tables_newchain(struct net *net, struct sock *nlsk,
basechain->policy = policy;
} else {
chain = kzalloc(sizeof(*chain), GFP_KERNEL);
- if (chain == NULL)
+ if (!chain)
return -ENOMEM;
}
@@ -1800,7 +1800,7 @@ struct nft_expr *nft_expr_init(const struct nft_ctx *ctx,
err = -ENOMEM;
expr = kzalloc(info.ops->size, GFP_KERNEL);
- if (expr == NULL)
+ if (!expr)
goto err2;
err = nf_tables_newexpr(ctx, &info, expr);
@@ -2214,7 +2214,7 @@ static int nf_tables_newrule(struct net *net, struct sock *nlsk,
err = -ENOMEM;
rule = kzalloc(sizeof(*rule) + size + usize, GFP_KERNEL);
- if (rule == NULL)
+ if (!rule)
goto err1;
nft_activate_next(net, rule);
@@ -2810,7 +2810,7 @@ static int nf_tables_getset(struct net *net, struct sock *nlsk,
struct nft_ctx *ctx_dump;
ctx_dump = kmalloc(sizeof(*ctx_dump), GFP_KERNEL);
- if (ctx_dump == NULL)
+ if (!ctx_dump)
return -ENOMEM;
*ctx_dump = ctx;
@@ -3014,7 +3014,7 @@ static int nf_tables_newset(struct net *net, struct sock *nlsk,
err = -ENOMEM;
set = kzalloc(sizeof(*set) + size + udlen, GFP_KERNEL);
- if (set == NULL)
+ if (!set)
goto err1;
nla_strlcpy(name, nla[NFTA_SET_NAME], sizeof(set->name));
@@ -3543,7 +3543,7 @@ void *nft_set_elem_init(const struct nft_set *set,
void *elem;
elem = kzalloc(set->ops->elemsize + tmpl->len, gfp);
- if (elem == NULL)
+ if (!elem)
return NULL;
ext = nft_set_elem_ext(set, elem);
@@ -3998,7 +3998,7 @@ struct nft_set_gc_batch *nft_set_gc_batch_alloc(const struct nft_set *set,
struct nft_set_gc_batch *gcb;
gcb = kzalloc(sizeof(*gcb), gfp);
- if (gcb == NULL)
+ if (!gcb)
return gcb;
gcb->head.set = set;
return gcb;
@@ -4084,7 +4084,7 @@ static struct nft_object *nft_obj_init(const struct nft_object_type *type,
err = -ENOMEM;
obj = kzalloc(sizeof(struct nft_object) + type->size, GFP_KERNEL);
- if (obj == NULL)
+ if (!obj)
goto err1;
err = type->init((const struct nlattr * const *)tb, obj);
@@ -5567,7 +5567,7 @@ static int __init nf_tables_module_init(void)
info = kmalloc(sizeof(struct nft_expr_info) * NFT_RULE_MAXEXPRS,
GFP_KERNEL);
- if (info == NULL) {
+ if (!info) {
err = -ENOMEM;
goto err1;
}
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | simran singhal <singhalsimran0@gmail.com> |
|---|---|
| Date | 2017-03-21 09:50 +0100 |
| Subject | [PATCH 4/5] netfilter: nfnetlink: Clean up tests if NULL returned on failure |
| Message-ID | <tnnEm-OE-39@gated-at.bofh.it> |
| In reply to | #1605429 |
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
[toc] | [prev] | [next] | [standalone]
| From | Pablo Neira Ayuso <pablo@netfilter.org> |
|---|---|
| Date | 2017-03-22 14:40 +0100 |
| Message-ID | <tnOEy-37h-27@gated-at.bofh.it> |
| In reply to | #1605429 |
On Tue, Mar 21, 2017 at 02:14:34PM +0530, simran singhal wrote: > This patch series clean up tests if NULL returned on failure. $ git grep "== NULL" net/netfilter/ | wc -l 461 This is cleaning up just some of them, we still seem to have quite a bit of them. Main problem with this changes is that it creates lots of work to people backporting patches and stable maintainers, I remember that they have complain about this. Either way, I would prefer you fix this coding style issue in one go, ie. one single patch, it will be a large one.
[toc] | [prev] | [next] | [standalone]
| From | SIMRAN SINGHAL <singhalsimran0@gmail.com> |
|---|---|
| Date | 2017-03-22 14:50 +0100 |
| Message-ID | <tnOOd-3b8-11@gated-at.bofh.it> |
| In reply to | #1606499 |
On Wed, Mar 22, 2017 at 7:08 PM, Pablo Neira Ayuso <pablo@netfilter.org> wrote: > On Tue, Mar 21, 2017 at 02:14:34PM +0530, simran singhal wrote: >> This patch series clean up tests if NULL returned on failure. > > $ git grep "== NULL" net/netfilter/ | wc -l > 461 > > This is cleaning up just some of them, we still seem to have quite a > bit of them. > > Main problem with this changes is that it creates lots of work to > people backporting patches and stable maintainers, I remember that > they have complain about this. > > Either way, I would prefer you fix this coding style issue in one go, > ie. one single patch, it will be a large one. ok, I will send the single patch.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web