From: Denis Ovsienko Date: Tue, 3 Aug 2021 22:38:48 +0000 (+0100) Subject: Squelch a warning with Capsicum enabled. [skip appveyor] X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/51f9c3b947eac89254c4e3662902487e0844a699 Squelch a warning with Capsicum enabled. [skip appveyor] The Capsicum workaround I added in commit 706c79e causes a side effect on FreeBSD 11.4, 12.2 and 13.0 with local libpcap when Capsicum is enabled, that is, in CMake builds (Capsicum detection is broken in Autoconf builds, as it turns out). Add a workaround for the side effect as well and get rid of another warning and respective exemption: tcpdump.c:2286:3: warning: implicit declaration of function 'bpf_dump' is invalid in C99 [-Wimplicit-function-declaration] --- diff --git a/build.sh b/build.sh index 3eafceda..a10a4f66 100755 --- a/build.sh +++ b/build.sh @@ -31,9 +31,6 @@ print_cc_version # shellcheck disable=SC2006 case `os_id`/"$CMAKE" in FreeBSD-*/yes) - # tcpdump.c:2290:3: error: implicit declaration of function 'bpf_dump' - # [-Werror=implicit-function-declaration] - [ "$BUILD_LIBPCAP" = yes ] && TCPDUMP_TAINTED=yes case `cc_id` in clang-*) # tcpdump.c:2434:32: error: '_Generic' is a C11 extension diff --git a/interface.h b/interface.h index d54172ee..58e5ab33 100644 --- a/interface.h +++ b/interface.h @@ -57,7 +57,13 @@ extern char *program_name; /* used to generate self-identifying messages */ #ifndef HAVE_BPF_DUMP struct bpf_program; +#endif +/* + * With Capsicum bpf_dump() may be not declared even if HAVE_BPF_DUMP is set. + */ +#if !defined(HAVE_BPF_DUMP) || \ + (defined(HAVE_BPF_DUMP) && HAVE_CAPSICUM && !defined(bpf_dump)) extern void bpf_dump(const struct bpf_program *, int); #endif diff --git a/tcpdump.c b/tcpdump.c index dc072e1f..611fa69b 100644 --- a/tcpdump.c +++ b/tcpdump.c @@ -78,7 +78,9 @@ The Regents of the University of California. All rights reserved.\n"; #endif /* Capsicum-specific code requires macros from , which will fail * to compile if has already been included; including the headers - * in the opposite order works fine. + * in the opposite order works fine. For the most part anyway, because in + * FreeBSD declares bpf_dump() instead of . Thus + * interface.h takes care of it later to avoid a compiler warning. */ #ifdef HAVE_CAPSICUM #include