]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Squelch a warning with Capsicum enabled. [skip appveyor]
authorDenis Ovsienko <[email protected]>
Tue, 3 Aug 2021 22:38:48 +0000 (23:38 +0100)
committerDenis Ovsienko <[email protected]>
Tue, 3 Aug 2021 23:45:45 +0000 (00:45 +0100)
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]

build.sh
interface.h
tcpdump.c

index 3eafceda849478494c97854352115bdc780164c1..a10a4f66f851e07f482d52d6eb47eee8d1e5bc85 100755 (executable)
--- 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
index d54172eef7bb50d32df47688cd5c3e8efcd211ab..58e5ab33e51f4a0b1878929fa4cfcaf9ccb6bba5 100644 (file)
@@ -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
index dc072e1ff9c2123f52792533f000723be18ca377..611fa69b327bc75ec76efb5c68ea58df7bc00bd7 100644 (file)
--- 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 <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>