Skip to content

Commit

Permalink
Squelch a warning with Capsicum enabled. [skip appveyor]
Browse files Browse the repository at this point in the history
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]
  • Loading branch information
infrastation committed Aug 3, 2021
1 parent bbeedf4 commit 51f9c3b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
3 changes: 0 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion tcpdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ The Regents of the University of California. All rights reserved.\n";
#endif
/* Capsicum-specific code requires macros from <net/bpf.h>, which will fail
* to compile if <pcap.h> 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 <pcap/pcap.h> declares bpf_dump() instead of <net/bpf.h>. Thus
* interface.h takes care of it later to avoid a compiler warning.
*/
#ifdef HAVE_CAPSICUM
#include <sys/capsicum.h>
Expand Down

0 comments on commit 51f9c3b

Please sign in to comment.