Skip to content

Commit 51f9c3b

Browse files
committed
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]
1 parent bbeedf4 commit 51f9c3b

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

build.sh

-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ print_cc_version
3131
# shellcheck disable=SC2006
3232
case `os_id`/"$CMAKE" in
3333
FreeBSD-*/yes)
34-
# tcpdump.c:2290:3: error: implicit declaration of function 'bpf_dump'
35-
# [-Werror=implicit-function-declaration]
36-
[ "$BUILD_LIBPCAP" = yes ] && TCPDUMP_TAINTED=yes
3734
case `cc_id` in
3835
clang-*)
3936
# tcpdump.c:2434:32: error: '_Generic' is a C11 extension

interface.h

+6
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,13 @@ extern char *program_name; /* used to generate self-identifying messages */
5757

5858
#ifndef HAVE_BPF_DUMP
5959
struct bpf_program;
60+
#endif
6061

62+
/*
63+
* With Capsicum bpf_dump() may be not declared even if HAVE_BPF_DUMP is set.
64+
*/
65+
#if !defined(HAVE_BPF_DUMP) || \
66+
(defined(HAVE_BPF_DUMP) && HAVE_CAPSICUM && !defined(bpf_dump))
6167
extern void bpf_dump(const struct bpf_program *, int);
6268

6369
#endif

tcpdump.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ The Regents of the University of California. All rights reserved.\n";
7878
#endif
7979
/* Capsicum-specific code requires macros from <net/bpf.h>, which will fail
8080
* to compile if <pcap.h> has already been included; including the headers
81-
* in the opposite order works fine.
81+
* in the opposite order works fine. For the most part anyway, because in
82+
* FreeBSD <pcap/pcap.h> declares bpf_dump() instead of <net/bpf.h>. Thus
83+
* interface.h takes care of it later to avoid a compiler warning.
8284
*/
8385
#ifdef HAVE_CAPSICUM
8486
#include <sys/capsicum.h>

0 commit comments

Comments
 (0)