]> granicus.if.org Git - ipset/commitdiff
Correct "Suspicious condition (assignment + comparison)" (Thomas Jarosch)
authorJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Mon, 7 Jan 2013 16:07:52 +0000 (17:07 +0100)
committerJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Wed, 9 Jan 2013 22:33:48 +0000 (23:33 +0100)
cppcheck (vaguely) reported:
[lib/parse.c:448]: (style) Suspicious condition (assignment + comparison); Clarify expression with parentheses.

lib/parse.c

index 550048c05914e7797dd98b49866d093c66949b29..951d2f32f86bd8d0d2404cc536289f648f1e10f2 100644 (file)
@@ -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);
        }