diff options
author | Guy Harris <gharris@sonic.net> | 2020-05-25 02:02:34 -0700 |
---|---|---|
committer | Guy Harris <gharris@sonic.net> | 2020-05-25 02:02:34 -0700 |
commit | 2ba1be35231dbdad50729e544fe4c2252aa15008 (patch) | |
tree | 5d1aa4aa5c51c1be8aed14fdfa037c2ea8741574 /print-zeromq.c | |
parent | 5a1d8b7774d1b9359cd0681a29eec3df5c48231c (diff) | |
download | tcpdump-2ba1be35231dbdad50729e544fe4c2252aa15008.tar.gz |
Squelch some warnings.
Use ND_BYTES_AVAILABLE_AFTER() to calculate the number of bytes
remaining in the packet after a given pointer, rather than doing the
subtraction directly; that casts the result to a u_int (we don't handle
packets bigger than the maximum u_int value, so the difference between
the pointers will never be bigger than that value), so we don't have to
deal with it being a 64-bit value on LP64 or LLP64 systems. (It also
makes it a bit clearer what we're doing).
Clean up some indentation while we're at it.
Diffstat (limited to 'print-zeromq.c')
-rw-r--r-- | print-zeromq.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/print-zeromq.c b/print-zeromq.c index ac61056a..31d69968 100644 --- a/print-zeromq.c +++ b/print-zeromq.c @@ -169,13 +169,13 @@ static const u_char * zmtp1_print_intermediate_part(netdissect_options *ndo, const u_char *cp, const u_int len) { u_int frame_offset; - uint64_t remaining_len; + u_int remaining_len; ND_TCHECK_2(cp); frame_offset = GET_BE_U_2(cp); ND_PRINT("\n\t frame offset 0x%04x", frame_offset); cp += 2; - remaining_len = ndo->ndo_snapend - cp; /* without the frame length */ + remaining_len = ND_BYTES_AVAILABLE_AFTER(cp); /* without the frame length */ if (frame_offset == 0xFFFF) frame_offset = len - 2; /* always within the declared length */ @@ -188,14 +188,14 @@ zmtp1_print_intermediate_part(netdissect_options *ndo, const u_char *cp, const u if (frame_offset) { ND_PRINT("\n\t frame intermediate part, %u bytes", frame_offset); if (frame_offset > remaining_len) - ND_PRINT(" (%"PRIu64" captured)", remaining_len); + ND_PRINT(" (%u captured)", remaining_len); if (ndo->ndo_vflag) { - uint64_t len_printed = min(frame_offset, remaining_len); + u_int len_printed = min(frame_offset, remaining_len); if (ndo->ndo_vflag == 1) len_printed = min(VBYTES, len_printed); if (len_printed > 1) { - ND_PRINT(", first %"PRIu64" byte(s):", len_printed); + ND_PRINT(", first %u byte(s):", len_printed); hex_and_ascii_print(ndo, "\n\t ", cp, len_printed); } } |