summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Ovsienko <denis@ovsienko.info>2021-08-11 00:17:19 +0100
committerDenis Ovsienko <denis@ovsienko.info>2021-08-11 00:17:19 +0100
commit0c21cb27e629288925f378994eb47a1d90279eab (patch)
treeb6f6629b9cadbd744e7df2f24938d5482b952fc6
parent02bc5d9fca019a71c8148790686dc81728d778e4 (diff)
downloadlibpcap-0c21cb27e629288925f378994eb47a1d90279eab.tar.gz
Fix compiling on Solaris 11.4/AMD64.
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).
-rw-r--r--CHANGES2
-rwxr-xr-xbuild.sh14
-rw-r--r--gencode.c9
-rw-r--r--gencode.h1
-rw-r--r--grammar.y.in9
-rw-r--r--pcap/bpf.h2
-rw-r--r--scanner.l11
7 files changed, 38 insertions, 10 deletions
diff --git a/CHANGES b/CHANGES
index b3f7eb2b..b21d84b9 100644
--- a/CHANGES
+++ b/CHANGES
@@ -4,7 +4,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.
Monthday, Month DD, YYYY:
diff --git a/build.sh b/build.sh
index 87cbf7f1..0ac5204b 100755
--- 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`
diff --git a/gencode.c b/gencode.c
index 07259a70..03deb020 100644
--- a/gencode.c
+++ b/gencode.c
@@ -24,6 +24,13 @@
#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)
diff --git a/gencode.h b/gencode.h
index 647946d0..a1748b88 100644
--- 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:
diff --git a/grammar.y.in b/grammar.y.in
index 2fbd8615..f8d336ea 100644
--- a/grammar.y.in
+++ b/grammar.y.in
@@ -71,6 +71,13 @@
#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
diff --git a/pcap/bpf.h b/pcap/bpf.h
index 54373af8..c5efb748 100644
--- a/pcap/bpf.h
+++ b/pcap/bpf.h
@@ -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
diff --git a/scanner.l b/scanner.l
index 06b9acc1..85fe395a 100644
--- a/scanner.l
+++ b/scanner.l
@@ -24,6 +24,13 @@
*/
#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"
}
@@ -89,10 +96,6 @@
#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.