Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 13 Dec 2013 19:32:03 +0000 (UTC)
From:      "Pedro F. Giffuni" <pfg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r259326 - stable/10/contrib/tcpdump
Message-ID:  <201312131932.rBDJW3iw088831@svn.freebsd.org>

Next in thread | Raw E-Mail | Index | Archive | Help
Author: pfg
Date: Fri Dec 13 19:32:02 2013
New Revision: 259326
URL: http://svnweb.freebsd.org/changeset/base/259326

Log:
  MFV r258571:
  
  Removes strict-aliasing warnings from newer GCC in tcpdump.
  
  Corresponds to MFC r258573, but for some reason our new pre-commit hooks
  will not let us merge it from there.

Modified:
  stable/10/contrib/tcpdump/extract.h

Modified: stable/10/contrib/tcpdump/extract.h
==============================================================================
--- stable/10/contrib/tcpdump/extract.h	Fri Dec 13 19:27:23 2013	(r259325)
+++ stable/10/contrib/tcpdump/extract.h	Fri Dec 13 19:32:02 2013	(r259326)
@@ -51,13 +51,25 @@ typedef struct {
 	u_int32_t	val;
 } __attribute__((packed)) unaligned_u_int32_t;
 
-#define EXTRACT_16BITS(p) \
-	((u_int16_t)ntohs(((const unaligned_u_int16_t *)(p))->val))
-#define EXTRACT_32BITS(p) \
-	((u_int32_t)ntohl(((const unaligned_u_int32_t *)(p))->val))
-#define EXTRACT_64BITS(p) \
-	((u_int64_t)(((u_int64_t)ntohl(((const unaligned_u_int32_t *)(p) + 0)->val)) << 32 | \
-		     ((u_int64_t)ntohl(((const unaligned_u_int32_t *)(p) + 1)->val)) << 0))
+static inline u_int16_t
+EXTRACT_16BITS(const void *p)
+{
+	return ((u_int16_t)ntohs(((const unaligned_u_int16_t *)(p))->val));
+}
+
+static inline u_int32_t
+EXTRACT_32BITS(const void *p)
+{
+	return ((u_int32_t)ntohl(((const unaligned_u_int32_t *)(p))->val));
+}
+
+static inline u_int64_t
+EXTRACT_64BITS(const void *p)
+{
+	return ((u_int64_t)(((u_int64_t)ntohl(((const unaligned_u_int32_t *)(p) + 0)->val)) << 32 | \
+		((u_int64_t)ntohl(((const unaligned_u_int32_t *)(p) + 1)->val)) << 0));
+
+}
 
 #else /* HAVE___ATTRIBUTE__ */
 /*
@@ -88,13 +100,26 @@ typedef struct {
  * The processor natively handles unaligned loads, so we can just
  * cast the pointer and fetch through it.
  */
-#define EXTRACT_16BITS(p) \
-	((u_int16_t)ntohs(*(const u_int16_t *)(p)))
-#define EXTRACT_32BITS(p) \
-	((u_int32_t)ntohl(*(const u_int32_t *)(p)))
-#define EXTRACT_64BITS(p) \
-	((u_int64_t)(((u_int64_t)ntohl(*((const u_int32_t *)(p) + 0))) << 32 | \
-		     ((u_int64_t)ntohl(*((const u_int32_t *)(p) + 1))) << 0))
+static inline u_int16_t
+EXTRACT_16BITS(const void *p)
+{
+	return ((u_int16_t)ntohs(*(const u_int16_t *)(p)));
+}
+
+static inline u_int32_t
+EXTRACT_32BITS(const void *p)
+{
+	return ((u_int32_t)ntohl(*(const u_int32_t *)(p)));
+}
+
+static inline u_int64_t
+EXTRACT_64BITS(const void *p)
+{
+	return ((u_int64_t)(((u_int64_t)ntohl(*((const u_int32_t *)(p) + 0))) << 32 | \
+		((u_int64_t)ntohl(*((const u_int32_t *)(p) + 1))) << 0));
+
+}
+
 #endif /* LBL_ALIGN */
 
 #define EXTRACT_24BITS(p) \



Want to link to this message? Use this URL: <http://docs.FreeBSD.org/cgi/mid.cgi?201312131932.rBDJW3iw088831>