From: Pablo Neira Ayuso <pablo@netfilter.org>
To: "Carlos Falgueras García" <carlosfg@riseup.net>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH 2/3 libnftnl] fix some error checking in parser functions
Date: Thu, 16 Jun 2016 14:53:04 +0200 [thread overview]
Message-ID: <20160616125304.GA2864@salvia> (raw)
In-Reply-To: <20160616102012.32036-2-carlosfg@riseup.net>
On Thu, Jun 16, 2016 at 12:20:11PM +0200, Carlos Falgueras García wrote:
> diff --git a/src/rule.c b/src/rule.c
> index b009c37..930ecc0 100644
> --- a/src/rule.c
> +++ b/src/rule.c
> @@ -427,7 +427,7 @@ int nftnl_rule_nlmsg_parse(const struct nlmsghdr *nlh, struct nftnl_rule *r)
> {
> struct nlattr *tb[NFTA_RULE_MAX+1] = {};
> struct nfgenmsg *nfg = mnl_nlmsg_get_payload(nlh);
> - int ret = 0;
> + int ret;
>
> if (mnl_attr_parse(nlh, sizeof(*nfg), nftnl_rule_parse_attr_cb, tb) < 0)
> return -1;
> @@ -452,10 +452,16 @@ int nftnl_rule_nlmsg_parse(const struct nlmsghdr *nlh, struct nftnl_rule *r)
> r->handle = be64toh(mnl_attr_get_u64(tb[NFTA_RULE_HANDLE]));
> r->flags |= (1 << NFTNL_RULE_HANDLE);
> }
> - if (tb[NFTA_RULE_EXPRESSIONS])
> + if (tb[NFTA_RULE_EXPRESSIONS]) {
> ret = nftnl_rule_parse_expr(tb[NFTA_RULE_EXPRESSIONS], r);
> - if (tb[NFTA_RULE_COMPAT])
> + if (ret)
> + return ret;
Please use:
if (ret < 0)
return ret;
instead. I think this is the common idiom we're using all around this
library.
Thanks.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2016-06-16 12:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-16 10:20 [PATCH 1/3 libnftnl] chain: Fix bug. Check correct attribute Carlos Falgueras García
2016-06-16 10:20 ` [PATCH 2/3 libnftnl] fix some error checking in parser functions Carlos Falgueras García
2016-06-16 12:53 ` Pablo Neira Ayuso [this message]
2016-06-16 10:20 ` [PATCH 3/3 libnftnl] Consolidate setters Carlos Falgueras García
2016-06-16 12:51 ` [PATCH 1/3 libnftnl] chain: Fix bug. Check correct attribute Pablo Neira Ayuso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160616125304.GA2864@salvia \
--to=pablo@netfilter.org \
--cc=carlosfg@riseup.net \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).