Skip to content

Commit

Permalink
netfilter: use PTR_ERR_OR_ZERO()
Browse files Browse the repository at this point in the history
Fix ptr_ret.cocci warnings:

  net/netfilter/xt_connlimit.c:96:1-3: WARNING: PTR_ERR_OR_ZERO can be used
  net/netfilter/nft_numgen.c:240: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

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
  • Loading branch information
YueHaibing authored and Pablo Neira Ayuso committed Jul 30, 2018
1 parent 51c23b4 commit 33b78aa
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
4 changes: 1 addition & 3 deletions net/netfilter/nft_numgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,8 @@ static int nft_ng_random_map_init(const struct nft_ctx *ctx,
priv->map = nft_set_lookup_global(ctx->net, ctx->table,
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_random_dump(struct sk_buff *skb, const struct nft_expr *expr)
Expand Down
4 changes: 1 addition & 3 deletions net/netfilter/xt_connlimit.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,8 @@ static int connlimit_mt_check(const struct xt_mtchk_param *par)

/* init private data */
info->data = nf_conncount_init(par->net, par->family, keylen);
if (IS_ERR(info->data))
return PTR_ERR(info->data);

return 0;
return PTR_ERR_OR_ZERO(info->data);
}

static void connlimit_mt_destroy(const struct xt_mtdtor_param *par)
Expand Down

0 comments on commit 33b78aa

Please sign in to comment.