]> The Tcpdump Group git mirrors - tcpdump/commitdiff
DHCPv6: axe a couple invariant expressions
authorDenis Ovsienko <[email protected]>
Thu, 10 Apr 2014 10:23:17 +0000 (14:23 +0400)
committerDenis Ovsienko <[email protected]>
Thu, 10 Apr 2014 10:23:17 +0000 (14:23 +0400)
The "type > 65535" condition in dhcp6opt_name() was always false because
the function is given a 16-bit argument.

The "dh6->dh6_msgtype" condition in dhcp6_print() was always true
because name == NULL only when none of the preceding switch block cases
matched.

print-dhcp6.c

index 178ec6f8953f503d118b7f130855ec7111e4bb81..cd7a588ed0103be931ea7abb6c700cfc38f0b168 100644 (file)
@@ -185,9 +185,6 @@ dhcp6opt_name(int type)
 {
        static char genstr[sizeof("opt_65535") + 1]; /* XXX thread unsafe */
 
 {
        static char genstr[sizeof("opt_65535") + 1]; /* XXX thread unsafe */
 
-       if (type > 65535)
-               return "INVALID-option";
-
        switch(type) {
        case DH6OPT_CLIENTID:
                return "client-ID";
        switch(type) {
        case DH6OPT_CLIENTID:
                return "client-ID";
@@ -883,10 +880,8 @@ dhcp6_print(netdissect_options *ndo,
        if (!ndo->ndo_vflag) {
                if (name)
                        ND_PRINT((ndo, " %s", name));
        if (!ndo->ndo_vflag) {
                if (name)
                        ND_PRINT((ndo, " %s", name));
-               else if (dh6->dh6_msgtype != DH6_RELAY_FORW &&
-                   dh6->dh6_msgtype != DH6_RELAY_REPLY) {
+               else
                        ND_PRINT((ndo, " msgtype-%u", dh6->dh6_msgtype));
                        ND_PRINT((ndo, " msgtype-%u", dh6->dh6_msgtype));
-               }
                return;
        }
 
                return;
        }