Patchwork Flexible array should be last in struct mbuf

login
register
mail settings
Submitter Elie Richa
Date Sept. 8, 2011, 2:51 p.m.
Message ID <1315493470-32346-1-git-send-email-richa@adacore.com>
Download mbox | patch
Permalink /patch/113906/
State New
Headers show

Comments

Elie Richa - Sept. 8, 2011, 2:51 p.m.
The flexible array member should remain the last member in the structure
as this assumption is based upon in the code.

Signed-off-by: Elie Richa <richa@adacore.com>
---
 slirp/mbuf.h |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

Patch

diff --git a/slirp/mbuf.h b/slirp/mbuf.h
index 55170e5..e13ff71 100644
--- a/slirp/mbuf.h
+++ b/slirp/mbuf.h
@@ -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