Skip to content

Commit

Permalink
netfilter: fix ptr_ret.cocci warnings
Browse files Browse the repository at this point in the history
net/netfilter/nft_numgen.c:117:1-3: WARNING: PTR_ERR_OR_ZERO can be used
net/netfilter/nft_hash.c:180:1-3: WARNING: PTR_ERR_OR_ZERO can be used
net/netfilter/nft_hash.c:223:1-3: WARNING: PTR_ERR_OR_ZERO can be used

 Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR

Generated by: scripts/coccinelle/api/ptr_ret.cocci

Fixes: b9ccc07 ("netfilter: nft_hash: add map lookups for hashing operations")
Fixes: d734a28 ("netfilter: nft_numgen: add map lookups for numgen statements")
CC: Laura Garcia Liebana <nevola@gmail.com>
Signed-off-by: kbuild test robot <fengguang.wu@intel.com>
Acked-by: Laura Garcia Liebana <nevola@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
  • Loading branch information
kbuild test robot authored and ummakynes committed Jun 1, 2018
1 parent e523452 commit 7849958
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
10 changes: 2 additions & 8 deletions net/netfilter/nft_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,7 @@ static int nft_jhash_map_init(const struct nft_ctx *ctx,
priv->map = nft_set_lookup_global(ctx->net, ctx->table,
tb[NFTA_HASH_SET_NAME],
tb[NFTA_HASH_SET_ID], genmask);
if (IS_ERR(priv->map))
return PTR_ERR(priv->map);

return 0;
return PTR_ERR_OR_ZERO(priv->map);
}

static int nft_symhash_init(const struct nft_ctx *ctx,
Expand Down Expand Up @@ -220,10 +217,7 @@ static int nft_symhash_map_init(const struct nft_ctx *ctx,
priv->map = nft_set_lookup_global(ctx->net, ctx->table,
tb[NFTA_HASH_SET_NAME],
tb[NFTA_HASH_SET_ID], genmask);
if (IS_ERR(priv->map))
return PTR_ERR(priv->map);

return 0;
return PTR_ERR_OR_ZERO(priv->map);
}

static int nft_jhash_dump(struct sk_buff *skb,
Expand Down
5 changes: 1 addition & 4 deletions net/netfilter/nft_numgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,7 @@ static int nft_ng_inc_map_init(const struct nft_ctx *ctx,
tb[NFTA_NG_SET_NAME],
tb[NFTA_NG_SET_ID], genmask);

if (IS_ERR(priv->map))
return PTR_ERR(priv->map);

return 0;
return PTR_ERR_OR_ZERO(priv->map);
}

static int nft_ng_dump(struct sk_buff *skb, enum nft_registers dreg,
Expand Down

0 comments on commit 7849958

Please sign in to comment.