Skip to contentSkip to conversation

Flexible array should be last in struct mbuf

PATCH New Elie Richa 1 participant 1 message Sep 8, 2011

lore
Share & tools
lore

Elie Richa

author
#0 lore raw

PATCH 1/1 Flexible array should be last in struct mbuf

The flexible array member should remain the last member in the structure as this assumption is based upon in the code.

---
 slirp/mbuf.h |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
slirp/mbuf.h +4 -3
index 55170e5..e13ff71 100644
@@ -82,12 +82,13 @@ struct m_hdr {
 struct mbuf {
 	struct	m_hdr m_hdr;
 	Slirp *slirp;
+	bool     arp_requested;
+	uint64_t expiration_date;
 	union M_dat {
 		char	m_dat_[1]; /* ANSI don't like 0 sized arrays */
 		char	*m_ext_;
-	} M_dat;
-    bool     arp_requested;
-    uint64_t expiration_date;
+	} M_dat; /* This is a "flexible array member". It should always remain
+                    the last member of the structure */
 };
 
 #define m_next		m_hdr.mh_next
Signature · 1 line
1.7.4.1