]> The Tcpdump Group git mirrors - libpcap/commitdiff
Always use offsetof() via <stddef.h>.
authorDenis Ovsienko <[email protected]>
Sun, 9 Feb 2025 13:07:02 +0000 (13:07 +0000)
committerDenis Ovsienko <[email protected]>
Sun, 9 Feb 2025 21:08:50 +0000 (21:08 +0000)
In gencode.c do not check whether offsetof() is defined: <stddef.h>
defines it since at least C99, so just make sure to have the header
included.  Also include the header in pcap-util.c.

gencode.c
pcap-util.c

index 1e5f9558d203d4e8b5fb23b791954219c519a78a..f859e9de31e695b68dd4daea68129d131be3aaa5 100644 (file)
--- a/gencode.c
+++ b/gencode.c
@@ -34,6 +34,7 @@
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdint.h>
+#include <stddef.h>
 
 #include "pcap-int.h"
 
 #include <linux/filter.h>
 #endif
 
-#ifndef offsetof
-#define offsetof(s, e) ((size_t)&((s *)0)->e)
-#endif
-
 #ifdef _WIN32
   #ifdef INET6
     #if defined(__MINGW32__) && defined(DEFINE_ADDITIONAL_IPV6_STUFF)
index 1aa8e13e323e495460074aa9440a5cc0d5d83f96..650f5b2a9d9721701fdbcb8137155133293d9d33 100644 (file)
@@ -23,6 +23,8 @@
 
 #include <config.h>
 
+#include <stddef.h>
+
 #include <pcap-types.h>
 
 #include "pcap/can_socketcan.h"