From: Guy Harris Date: Tue, 16 Nov 2021 07:52:08 +0000 (-0800) Subject: 802.15.4: fix some compiler warnings. X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/02dd14c50d696c8087b8a1f842a005c321fb870a 802.15.4: fix some compiler warnings. C's type conversion rules are a barrel of fun. Did you know that if you add "2" to an "unsigned short", the result has the type "int", even though, at least on a machine where "unsigned int" is longer than "unsigned short", the result is always >= 0? Add "2U" instead, so that one of the operands is an "unsigned int", making the result an "unsigned int". --- diff --git a/print-802_15_4.c b/print-802_15_4.c index f76831b9..a9d43d96 100644 --- a/print-802_15_4.c +++ b/print-802_15_4.c @@ -959,7 +959,7 @@ ieee802_15_4_print_header_ie_list(netdissect_options *ndo, h_ie_names[element_id], ie_len); } } - if (caplen < 2 + ie_len) { + if (caplen < 2U + ie_len) { ND_PRINT("[ERROR: Truncated IE data]"); return -1; } @@ -1441,7 +1441,7 @@ ieee802_15_4_print_payload_ie_list(netdissect_options *ndo, ND_PRINT("\n\t%s [ length = %d, ", p_ie_names[group_id], ie_len); } - if (caplen < 2 + ie_len) { + if (caplen < 2U + ie_len) { ND_PRINT("[ERROR: Truncated IE data]"); return -1; }