]> The Tcpdump Group git mirrors - libpcap/commitdiff
Fix compiling on Solaris 11.4/AMD64.
authorDenis Ovsienko <[email protected]>
Tue, 10 Aug 2021 23:17:19 +0000 (00:17 +0100)
committerGuy Harris <[email protected]>
Sun, 20 Feb 2022 23:15:45 +0000 (15:15 -0800)
In gencode.h and pcap/bpf.h include necessary headers in order not to
depend on other files to do so.

In gencode.c, grammar.c (via grammar.y.in) and scanner.c (via scanner.l)
include gencode.h and grammar.h as early as it takes for the token enum
identifiers not to clash with the named constants defined in system
headers. This fixes the following error with Clang (also with GCC and a
more vague message):

./grammar.h:116:5: error: expected identifier
    ESP = 326,
/usr/include/sys/regset.h:86:14: note: expanded from macro 'ESP'
 #define ESP             7

In build.sh add an exemption rule for the remaining warnings. Now
libpcap can complete the default matrix build (4 rounds with GCC 7.3.0
and 4 rounds with Clang 6.0.0).

(cherry picked from commit 0c21cb27e629288925f378994eb47a1d90279eab)

CHANGES
build.sh
gencode.c
gencode.h
grammar.y.in
pcap/bpf.h
scanner.l

diff --git a/CHANGES b/CHANGES
index d694feb77f5502e02f095cd7a8bd14506f196009..944f5142c8e3ec1d44fd5ddbc0757c580d344624 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -5,7 +5,7 @@ Monthday, Month DD, YYYY:
     Building and testing:
       Handle some Autoconf/make errors better.
       Fix "make releasetar" on AIX, OpenBSD and Solaris.
-      Fix compiling on Solaris 9.
+      Fix compiling on Solaris 9/SPARC and 11/AMD64.
       Address assorted compiler warnings.
 
 Wednesday, June 9, 2021:
index 87cbf7f11e95c4e872e454e31840cca2cbb5711a..0ac5204b0d045c5b7d0993076aa20bb5932252ba 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -50,6 +50,20 @@ clang-*/NetBSD-*)
     # 'long' to 'suseconds_t' (aka 'int') [-Wshorten-64-to-32]
     LIBPCAP_TAINTED=yes
     ;;
+clang-*/SunOS-5.11)
+    # pcap-bpf.c:1044:18: warning: implicit conversion loses integer precision:
+    #   'uint64_t' (aka 'unsigned long') to 'u_int' (aka 'unsigned int')
+    #   [-Wshorten-64-to-32]
+    # pcap-bpf.c:1045:18: warning: implicit conversion loses integer precision:
+    #   'uint64_t' (aka 'unsigned long') to 'u_int' (aka 'unsigned int')
+    #   [-Wshorten-64-to-32]
+    # pcap-bpf.c:1843:22: warning: implicit conversion loses integer precision:
+    #   'long' to 'int' [-Wshorten-64-to-32]
+    # fad-getad.c:266:52: warning: implicit conversion loses integer precision:
+    #   'uint64_t'(aka 'unsigned long') to 'bpf_u_int32' (aka 'unsigned int')
+    #   [-Wshorten-64-to-32]
+    [ "`uname -p`" = i386 ] && LIBPCAP_TAINTED=yes
+    ;;
 esac
 # shellcheck disable=SC2006
 [ "$LIBPCAP_TAINTED" != yes ] && CFLAGS=`cc_werr_cflags`
index 07259a70c2813193e30a954a13e8a60001e36186..03deb02080ef146d31cdc00d0c355fd98cb7aac7 100644 (file)
--- a/gencode.c
+++ b/gencode.c
 #include <config.h>
 #endif
 
+/*
+ * grammar.h requires gencode.h and sometimes breaks in a polluted namespace
+ * (see ftmacros.h), so include it early.
+ */
+#include "gencode.h"
+#include "grammar.h"
+
 #include <pcap-types.h>
 #ifdef _WIN32
   #include <ws2tcpip.h>
@@ -69,7 +76,6 @@
 #include "ethertype.h"
 #include "nlpid.h"
 #include "llc.h"
-#include "gencode.h"
 #include "ieee80211.h"
 #include "atmuni31.h"
 #include "sunatmpos.h"
@@ -79,7 +85,6 @@
 #include "arcnet.h"
 #include "diag-control.h"
 
-#include "grammar.h"
 #include "scanner.h"
 
 #if defined(linux)
index 647946d0dc03e6b9371ab45fc042fc1133a3c0da..a1748b88543c60ba8c1079e75366e4429983796c 100644 (file)
--- a/gencode.h
+++ b/gencode.h
@@ -23,6 +23,7 @@
 #define gencode_h
 
 #include "pcap/funcattrs.h"
+#include "pcap/bpf.h" /* bpf_u_int32 */
 
 /*
  * ATM support:
index 2fbd861533672484846966a1e87ca3af0f0cbd11..f8d336eab519ad475f13a9550e2f0d51bfd7c5c6 100644 (file)
 #include <config.h>
 #endif
 
+/*
+ * grammar.h requires gencode.h and sometimes breaks in a polluted namespace
+ * (see ftmacros.h), so include it early.
+ */
+#include "gencode.h"
+#include "grammar.h"
+
 #include <stdlib.h>
 
 #ifndef _WIN32
@@ -92,8 +99,6 @@ struct rtentry;
 
 #include "pcap-int.h"
 
-#include "gencode.h"
-#include "grammar.h"
 #include "scanner.h"
 
 #ifdef HAVE_NET_PFVAR_H
index 54373af8a350446afa7fa1a093f4046f7e7f7785..c5efb748797d340bdd39da66399ab6c928169e48 100644 (file)
@@ -80,7 +80,7 @@
 #define lib_pcap_bpf_h
 
 #include <pcap/funcattrs.h>
-
+#include <pcap-types.h> /* u_char, u_short and u_int */
 #include <pcap/dlt.h>
 
 #ifdef __cplusplus
index 06b9acc14ce16d955c642a84d3119c831321e954..85fe395aa55eab473216a574937323ec94131e41 100644 (file)
--- a/scanner.l
+++ b/scanner.l
  */
 #include <pcap/pcap-inttypes.h>
 
+/*
+ * grammar.h requires gencode.h and sometimes breaks in a polluted namespace
+ * (see ftmacros.h), so include it early.
+ */
+#include "gencode.h"
+#include "grammar.h"
+
 #include "diag-control.h"
 }
 
 
 #include "pcap-int.h"
 
-#include "gencode.h"
-
-#include "grammar.h"
-
 /*
  * Earlier versions of Flex don't declare these, so we declare them
  * ourselves to squelch warnings.