Fix wrong bracket placing
Subsystems (2)
PATCH 1/1 Fix wrong bracket placing
cppcheck (vaguely) reported:
[lib/parse.c:448]: (style) Suspicious condition (assignment + comparison); Clarify expression with parentheses.
Signed-off-by Thomas Jarosch <[email protected]>
--- lib/parse.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/parse.c +2 -2
@@ -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); }
Signature · 1 line
1.7.11.7
Hi Thomas,
Quoted 26 lines · Thomas Jarosch
cppcheck (vaguely) reported:
[lib/parse.c:448]: (style) Suspicious condition (assignment + comparison); Clarify expression with parentheses.Signed-off-by Thomas Jarosch <[email protected]>--- lib/parse.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)lib/parse.c +2
-2@@ -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); }Signature · 1 line
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:
lib/parse.c +3 -4
@@ -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 : [email protected], [email protected] 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