]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Make nd_trunc_longjmp() not static inline.
authorGuy Harris <[email protected]>
Sat, 5 Aug 2023 20:28:53 +0000 (13:28 -0700)
committerFrancois-Xavier Le Bail <[email protected]>
Fri, 13 Oct 2023 09:47:14 +0000 (11:47 +0200)
It should rarely be called (if it's called, either the packet was cut
short by snapshot-based slicing or it's malformed, or the dissector has
a bug), so inlining it doesn't help much, and, as it calls longjmp(),
which often expands to a call to __builtin_longjmp(), GCC won't inline
it anyway (see "An Inline Function is As Fast As a Macro" in the GCC
documentation), and Apple clang version 14.0.3 (clang-1403.0.22.14.1),
at least, doesn't inline it, either, so you get a bunch of inlined
definitions of it throughout the generated code.

Just make it a regular routine.

(cherry picked from commit 5faefb7542821b54193414fe03d7650c25d05380)

netdissect.c
netdissect.h

index 000d1ffce8c2c6eb9a47f36e9a79e0b5ec2b258e..93e633a6af93e093c7a2a0f19ac4993a77dd066e 100644 (file)
@@ -299,3 +299,17 @@ nd_pop_all_packet_info(netdissect_options *ndo)
        while (ndo->ndo_packet_info_stack != NULL)
                nd_pop_packet_info(ndo);
 }
+
+NORETURN void
+nd_trunc_longjmp(netdissect_options *ndo)
+{
+       longjmp(ndo->ndo_early_end, ND_TRUNCATED);
+#ifdef _AIX
+       /*
+        * In AIX <setjmp.h> decorates longjmp() with "#pragma leaves", which tells
+        * XL C that the function is noreturn, but GCC remains unaware of that and
+        * yields a "'noreturn' function does return" warning.
+        */
+       ND_UNREACHABLE
+#endif /* _AIX */
+}
index 675af5112cf39cf1ab5574b9e0e35d79ad364c4c..0eaf8eb2d6215e4ebb7a130848cd0912d3351d36 100644 (file)
@@ -269,19 +269,10 @@ extern void nd_change_snaplen(netdissect_options *, const u_char *, const u_int)
 extern void nd_pop_packet_info(netdissect_options *);
 extern void nd_pop_all_packet_info(netdissect_options *);
 
-static inline NORETURN void
-nd_trunc_longjmp(netdissect_options *ndo)
-{
-       longjmp(ndo->ndo_early_end, ND_TRUNCATED);
-#ifdef _AIX
-       /*
-        * In AIX <setjmp.h> decorates longjmp() with "#pragma leaves", which tells
-        * XL C that the function is noreturn, but GCC remains unaware of that and
-        * yields a "'noreturn' function does return" warning.
-        */
-       ND_UNREACHABLE
-#endif /* _AIX */
-}
+/*
+ * Report a packet truncation with a longjmp().
+ */
+NORETURN void nd_trunc_longjmp(netdissect_options *ndo);
 
 #define PT_VAT         1       /* Visual Audio Tool */
 #define PT_WB          2       /* distributed White Board */