Skip to content

Commit 5faefb7

Browse files
committed
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.
1 parent 4da3308 commit 5faefb7

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

netdissect.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,3 +299,17 @@ nd_pop_all_packet_info(netdissect_options *ndo)
299299
while (ndo->ndo_packet_info_stack != NULL)
300300
nd_pop_packet_info(ndo);
301301
}
302+
303+
NORETURN void
304+
nd_trunc_longjmp(netdissect_options *ndo)
305+
{
306+
longjmp(ndo->ndo_early_end, ND_TRUNCATED);
307+
#ifdef _AIX
308+
/*
309+
* In AIX <setjmp.h> decorates longjmp() with "#pragma leaves", which tells
310+
* XL C that the function is noreturn, but GCC remains unaware of that and
311+
* yields a "'noreturn' function does return" warning.
312+
*/
313+
ND_UNREACHABLE
314+
#endif /* _AIX */
315+
}

netdissect.h

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -272,19 +272,10 @@ extern void nd_change_snaplen(netdissect_options *, const u_char *, const u_int)
272272
extern void nd_pop_packet_info(netdissect_options *);
273273
extern void nd_pop_all_packet_info(netdissect_options *);
274274

275-
static inline NORETURN void
276-
nd_trunc_longjmp(netdissect_options *ndo)
277-
{
278-
longjmp(ndo->ndo_early_end, ND_TRUNCATED);
279-
#ifdef _AIX
280-
/*
281-
* In AIX <setjmp.h> decorates longjmp() with "#pragma leaves", which tells
282-
* XL C that the function is noreturn, but GCC remains unaware of that and
283-
* yields a "'noreturn' function does return" warning.
284-
*/
285-
ND_UNREACHABLE
286-
#endif /* _AIX */
287-
}
275+
/*
276+
* Report a packet truncation with a longjmp().
277+
*/
278+
NORETURN void nd_trunc_longjmp(netdissect_options *ndo);
288279

289280
#define PT_VAT 1 /* Visual Audio Tool */
290281
#define PT_WB 2 /* distributed White Board */

0 commit comments

Comments
 (0)