]> The Tcpdump Group git mirrors - tcpdump/commitdiff
ICMPv6: Squelch a GCC warning
authorFrancois-Xavier Le Bail <[email protected]>
Wed, 14 Feb 2018 10:51:09 +0000 (11:51 +0100)
committerFrancois-Xavier Le Bail <[email protected]>
Wed, 14 Feb 2018 10:51:09 +0000 (11:51 +0100)
The warning was:
./print-icmp6.c: In function 'icmp6_print':
./print-icmp6.c:1284:10: warning: cast discards '__attribute__((const))'
  qualifier from pointer target type [-Wcast-qual]
    in6 = (const nd_ipv6 *)(dp + 1);
          ^

print-icmp6.c

index ac52af233313d58dc363daf2d3fc4b6a93c75bc9..9bbd5c81f5d38a812db6b96f719eed06edf96d95 100644 (file)
@@ -1275,16 +1275,17 @@ icmp6_print(netdissect_options *ndo,
                 break;
        case ICMP6_HADISCOV_REPLY:
                if (ndo->ndo_vflag) {
                 break;
        case ICMP6_HADISCOV_REPLY:
                if (ndo->ndo_vflag) {
-                       const nd_ipv6 *in6;
                        const u_char *cp;
                        const u_char *cp;
+                       const u_char *p;
 
                        ND_TCHECK_2(dp->icmp6_data16[0]);
                        ND_PRINT(", id 0x%04x", EXTRACT_BE_U_2(dp->icmp6_data16[0]));
                        cp = (const u_char *)dp + length;
 
                        ND_TCHECK_2(dp->icmp6_data16[0]);
                        ND_PRINT(", id 0x%04x", EXTRACT_BE_U_2(dp->icmp6_data16[0]));
                        cp = (const u_char *)dp + length;
-                       in6 = (const nd_ipv6 *)(dp + 1);
-                       for (; (const u_char *)in6 < cp; in6++) {
-                               ND_TCHECK_SIZE(in6);
-                               ND_PRINT(", %s", ip6addr_string(ndo, (const u_char *)in6));
+                       p = (const u_char *)(dp + 1);
+                       while (p < cp) {
+                               ND_TCHECK_16(p);
+                               ND_PRINT(", %s", ip6addr_string(ndo, p));
+                               p += 16;
                        }
                }
                break;
                        }
                }
                break;