* [ipset PATCH] Fix wrong bracket placing
@ 2012-12-27 15:46 Thomas Jarosch
2013-01-09 22:40 ` Jozsef Kadlecsik
0 siblings, 1 reply; 2+ messages in thread
From: Thomas Jarosch @ 2012-12-27 15:46 UTC (permalink / raw)
To: netfilter-devel; +Cc: Jozsef Kadlecsik
cppcheck (vaguely) reported:
[lib/parse.c:448]: (style) Suspicious condition (assignment + comparison); Clarify expression with parentheses.
Signed-off-by: Thomas Jarosch <thomas.jarosch@intra2net.com>
---
lib/parse.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/parse.c b/lib/parse.c
index 550048c..d06e9cd 100644
--- a/lib/parse.c
+++ b/lib/parse.c
@@ -445,8 +445,8 @@ ipset_parse_proto(struct ipset_session *session,
uint8_t protonum;
int err;
- if (!((err = string_to_u8(session, str, &protonum) == 0) &&
- (protoent = getprotobynumber(protonum)) != NULL))
+ if (!((err = string_to_u8(session, str, &protonum)) == 0) &&
+ (protoent = getprotobynumber(protonum)) != NULL)
return syntax_err("cannot parse '%s' "
"as a protocol", str);
}
--
1.7.11.7
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [ipset PATCH] Fix wrong bracket placing
2012-12-27 15:46 [ipset PATCH] Fix wrong bracket placing Thomas Jarosch
@ 2013-01-09 22:40 ` Jozsef Kadlecsik
0 siblings, 0 replies; 2+ messages in thread
From: Jozsef Kadlecsik @ 2013-01-09 22:40 UTC (permalink / raw)
To: Thomas Jarosch; +Cc: netfilter-devel
Hi Thomas,
On Thu, 27 Dec 2012, Thomas Jarosch wrote:
> cppcheck (vaguely) reported:
> [lib/parse.c:448]: (style) Suspicious condition (assignment + comparison); Clarify expression with parentheses.
>
> Signed-off-by: Thomas Jarosch <thomas.jarosch@intra2net.com>
> ---
> lib/parse.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/lib/parse.c b/lib/parse.c
> index 550048c..d06e9cd 100644
> --- a/lib/parse.c
> +++ b/lib/parse.c
> @@ -445,8 +445,8 @@ ipset_parse_proto(struct ipset_session *session,
> uint8_t protonum;
> int err;
>
> - if (!((err = string_to_u8(session, str, &protonum) == 0) &&
> - (protoent = getprotobynumber(protonum)) != NULL))
> + if (!((err = string_to_u8(session, str, &protonum)) == 0) &&
> + (protoent = getprotobynumber(protonum)) != NULL)
> return syntax_err("cannot parse '%s' "
> "as a protocol", str);
> }
> --
> 1.7.11.7
>
Your patch fixes the warning but modifies the condition. So I simplified
the condition and am going to apply the next patch:
diff --git a/lib/parse.c b/lib/parse.c
index 550048c..951d2f3 100644
--- a/lib/parse.c
+++ b/lib/parse.c
@@ -442,11 +442,10 @@ ipset_parse_proto(struct ipset_session *session,
protoent = getprotobyname(strcasecmp(str, "icmpv6") == 0
? "ipv6-icmp" : str);
if (protoent == NULL) {
- uint8_t protonum;
- int err;
+ uint8_t protonum = 0;
- if (!((err = string_to_u8(session, str, &protonum) == 0) &&
- (protoent = getprotobynumber(protonum)) != NULL))
+ if (string_to_u8(session, str, &protonum) ||
+ (protoent = getprotobynumber(protonum)) == NULL)
return syntax_err("cannot parse '%s' "
"as a protocol", str);
}
Best regards,
Jozsef
-
E-mail : kadlec@blackhole.kfki.hu, kadlecsik.jozsef@wigner.mta.hu
PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : Wigner Research Centre for Physics, Hungarian Academy of Sciences
H-1525 Budapest 114, POB. 49, Hungary
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-01-09 22:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-27 15:46 [ipset PATCH] Fix wrong bracket placing Thomas Jarosch
2013-01-09 22:40 ` Jozsef Kadlecsik
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).