]> The Tcpdump Group git mirrors - tcpdump/commitdiff
802.15.4: fix some compiler warnings.
authorGuy Harris <[email protected]>
Tue, 16 Nov 2021 07:52:08 +0000 (23:52 -0800)
committerGuy Harris <[email protected]>
Tue, 16 Nov 2021 07:52:08 +0000 (23:52 -0800)
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".

print-802_15_4.c

index f76831b940d2f410a38abd0a48c6b437de54467f..a9d43d96cb3c8be17e0443a0d2586daee11d3f52 100644 (file)
@@ -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;
                }