[ovs-dev] [PATCH 11/16] compiler: Remove PACKED macro and its only (unneeded) user.

Ben Pfaff blp at nicira.com
Thu Feb 11 15:18:13 PST 2010


There is no point in marking a well-aligned structure PACKED.  It can only
cause trouble.
---
 lib/compiler.h |    1 -
 lib/pcap.c     |    8 +++++---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/lib/compiler.h b/lib/compiler.h
index 0075ca8..502a48c 100644
--- a/lib/compiler.h
+++ b/lib/compiler.h
@@ -19,7 +19,6 @@
 
 #define NO_RETURN __attribute__((__noreturn__))
 #define OVS_UNUSED __attribute__((__unused__))
-#define PACKED __attribute__((__packed__))
 #define PRINTF_FORMAT(FMT, ARG1) __attribute__((__format__(printf, FMT, ARG1)))
 #define STRFTIME_FORMAT(FMT) __attribute__((__format__(__strftime__, FMT, 0)))
 #define MALLOC_LIKE __attribute__((__malloc__))
diff --git a/lib/pcap.c b/lib/pcap.c
index 967bb5c..0559dec 100644
--- a/lib/pcap.c
+++ b/lib/pcap.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009 Nicira Networks.
+ * Copyright (c) 2009, 2010 Nicira Networks.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -34,14 +34,16 @@ struct pcap_hdr {
     uint32_t sigfigs;        /* accuracy of timestamps */
     uint32_t snaplen;        /* max length of captured packets */
     uint32_t network;        /* data link type */
-} PACKED;
+};
+BUILD_ASSERT_DECL(sizeof(struct pcap_hdr) == 24);
 
 struct pcaprec_hdr {
     uint32_t ts_sec;         /* timestamp seconds */
     uint32_t ts_usec;        /* timestamp microseconds */
     uint32_t incl_len;       /* number of octets of packet saved in file */
     uint32_t orig_len;       /* actual length of packet */
-} PACKED;
+} OVS_PACKED;
+BUILD_ASSERT_DECL(sizeof(struct pcaprec_hdr) == 16);
 
 FILE *
 pcap_open(const char *file_name, const char *mode)
-- 
1.6.6.1





More information about the dev mailing list