]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Refine print_unknown_data().
authorDenis Ovsienko <[email protected]>
Wed, 13 Jan 2021 15:21:25 +0000 (15:21 +0000)
committerDenis Ovsienko <[email protected]>
Wed, 13 Jan 2021 15:21:25 +0000 (15:21 +0000)
Use __func__ and ND_MIN() for simplicity.

util-print.c

index 925cf8d6a34be0e0a9e1a2d1bac70c114fcf72bf..641078c06773f59f731cb9e9ff69751ddc12cce7 100644 (file)
@@ -458,17 +458,12 @@ int
 print_unknown_data(netdissect_options *ndo, const u_char *cp,
                    const char *ident, u_int len)
 {
-       u_int len_to_print;
-
-       len_to_print = len;
        if (!ND_TTEST_LEN(cp, 0)) {
-               ND_PRINT("%sDissector error: print_unknown_data called with pointer past end of packet",
-                   ident);
+               ND_PRINT("%sDissector error: %s() called with pointer past end of packet",
+                   ident, __func__);
                return(0);
        }
-       if (ND_BYTES_AVAILABLE_AFTER(cp) < len_to_print)
-               len_to_print = ND_BYTES_AVAILABLE_AFTER(cp);
-       hex_print(ndo, ident, cp, len_to_print);
+       hex_print(ndo, ident, cp, ND_MIN(len, ND_BYTES_AVAILABLE_AFTER(cp)));
        return(1); /* everything is ok */
 }