From: Guy Harris Date: Sat, 5 Aug 2023 20:28:53 +0000 (-0700) Subject: Make nd_trunc_longjmp() not static inline. X-Git-Tag: tcpdump-4.99.5~179 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/59b65340e619f3d898ff2ca5b3a8b5d5df894d73 Make nd_trunc_longjmp() not static inline. 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) --- diff --git a/netdissect.c b/netdissect.c index 000d1ffc..93e633a6 100644 --- a/netdissect.c +++ b/netdissect.c @@ -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 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 */ +} diff --git a/netdissect.h b/netdissect.h index 675af511..0eaf8eb2 100644 --- a/netdissect.h +++ b/netdissect.h @@ -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 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 */