]> The Tcpdump Group git mirrors - tcpdump/commitdiff
nhrp: add casts to squelch narrowing warnings.
authorGuy Harris <[email protected]>
Tue, 11 Apr 2023 11:21:10 +0000 (04:21 -0700)
committerGuy Harris <[email protected]>
Tue, 11 Apr 2023 11:21:10 +0000 (04:21 -0700)
Get rid of some commented-out code while we're at it.

print-nhrp.c

index 2ef08ba74eb63db29c279c11fe542ae22b0b17b7..1e63f01b0aeca1b4260cc98f07387481806b2a34 100644 (file)
@@ -212,7 +212,7 @@ nhrp_print(netdissect_options *ndo, const u_char *bp, u_int length)
        }
        length -= sizeof(*fixed_hdr);
        if (mand_part_len > length)
-               mand_part_len = length;
+               mand_part_len = (uint16_t)length;
 
        /* We start looking at the mandatory header here. */
        ND_TCHECK_LEN(bp, sizeof(*fixed_hdr));
@@ -222,9 +222,6 @@ nhrp_print(netdissect_options *ndo, const u_char *bp, u_int length)
        ND_TCHECK_LEN(bp, sizeof(*mand_hdr));
        mand_hdr = (const struct nhrp_mand_header *)bp;
 
-//     nhrpext = p + extoff;
-//     nhrpend = p + pktsz;
-
        switch (op_type) {
        case NHRP_PKT_RESOLUTION_REQUEST:
        case NHRP_PKT_RESOLUTION_REPLY:
@@ -339,10 +336,14 @@ nhrp_print(netdissect_options *ndo, const u_char *bp, u_int length)
                while (mand_part_len != 0) {
                        u_int cie_len;
 
+                       /*
+                        * cie_len is guaranteed by nhrp_print_cie()
+                        * to be <= mand_part_len.
+                        */
                        cie_len = nhrp_print_cie(ndo, bp, mand_part_len,
                            afn, pro_type);
                        bp += cie_len;
-                       mand_part_len -= cie_len;
+                       mand_part_len -= (uint16_t)cie_len;
                }
                break;
        case NHRP_PKT_ERROR_INDICATION: