Message ID | CAFEAcA_wOnQmgc+ujGBF+RUSp7-jH5UkbkrtHzcxCqPVtqn0fA@mail.gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Hello, Peter Maydell, on Fri 19 Feb 2016 12:09:17 +0000, wrote: > We can do that, I think, by updating slirp to use C99 flexible > arrays: Indeed. > diff --git a/slirp/mbuf.h b/slirp/mbuf.h > index 38fedf4..ef5a4f7 100644 > --- a/slirp/mbuf.h > +++ b/slirp/mbuf.h > @@ -81,11 +81,9 @@ struct mbuf { > Slirp *slirp; > bool resolution_requested; > uint64_t expiration_date; > + char *m_ext; > /* start of dynamic buffer area, must be last element */ > - union { > - char m_dat[1]; /* ANSI don't like 0 sized arrays */ > - char *m_ext; > - }; > + char m_dat[]; > }; > > #define ifq_prev m_prev > > [compile-tested, but need to audit the slirp code to check that > it doesn't care that m_dat and m_ext no longer have the same > offset within the struct... I believe that's true. It needs to be cross-checked though. > I'm assuming we don't care about > the fact we've used an extra 4 bytes of struct.] That's probably fine, yes. > However that then needs us to add a new disable-warning flag > -Wno-gnu-variable-sized-type-not-at-end, because slirp.h uses > these 'struct mbuf's embedded inside another structure, Uh. It does so for not so useful reasons, it actually really needs a list head (i.e. a struct quehead), that could probably be reworked. Samuel
On 19 February 2016 at 12:09, Peter Maydell <peter.maydell@linaro.org> wrote: > So I guess I'll apply this pullreq for now and we can look > at improving the SLIRP code to be sanitizer-clean later. Now applied, thanks. -- PMM
Hello Peter, Peter Maydell, on Fri 19 Feb 2016 12:09:17 +0000, wrote: > diff --git a/slirp/mbuf.h b/slirp/mbuf.h > index 38fedf4..ef5a4f7 100644 > --- a/slirp/mbuf.h > +++ b/slirp/mbuf.h > @@ -81,11 +81,9 @@ struct mbuf { > Slirp *slirp; > bool resolution_requested; > uint64_t expiration_date; > + char *m_ext; > /* start of dynamic buffer area, must be last element */ > - union { > - char m_dat[1]; /* ANSI don't like 0 sized arrays */ > - char *m_ext; > - }; > + char m_dat[]; > }; > > #define ifq_prev m_prev Could you give your Signed-off-by on this? Samuel
On 23 March 2016 at 00:05, Samuel Thibault <samuel.thibault@gnu.org> wrote: > Hello Peter, > > Peter Maydell, on Fri 19 Feb 2016 12:09:17 +0000, wrote: >> diff --git a/slirp/mbuf.h b/slirp/mbuf.h >> index 38fedf4..ef5a4f7 100644 >> --- a/slirp/mbuf.h >> +++ b/slirp/mbuf.h >> @@ -81,11 +81,9 @@ struct mbuf { >> Slirp *slirp; >> bool resolution_requested; >> uint64_t expiration_date; >> + char *m_ext; >> /* start of dynamic buffer area, must be last element */ >> - union { >> - char m_dat[1]; /* ANSI don't like 0 sized arrays */ >> - char *m_ext; >> - }; >> + char m_dat[]; >> }; >> >> #define ifq_prev m_prev > > Could you give your Signed-off-by on this? Sure; Signed-off-by: Peter Maydell <peter.maydell@linaro.org> though as I say I only compile tested it... -- PMM
Peter Maydell, on Wed 23 Mar 2016 12:43:44 +0000, wrote: > On 23 March 2016 at 00:05, Samuel Thibault <samuel.thibault@gnu.org> wrote: > > Peter Maydell, on Fri 19 Feb 2016 12:09:17 +0000, wrote: > >> diff --git a/slirp/mbuf.h b/slirp/mbuf.h > >> index 38fedf4..ef5a4f7 100644 > >> --- a/slirp/mbuf.h > >> +++ b/slirp/mbuf.h > >> @@ -81,11 +81,9 @@ struct mbuf { > >> Slirp *slirp; > >> bool resolution_requested; > >> uint64_t expiration_date; > >> + char *m_ext; > >> /* start of dynamic buffer area, must be last element */ > >> - union { > >> - char m_dat[1]; /* ANSI don't like 0 sized arrays */ > >> - char *m_ext; > >> - }; > >> + char m_dat[]; > >> }; > >> > >> #define ifq_prev m_prev > > > > Could you give your Signed-off-by on this? > > Sure; Signed-off-by: Peter Maydell <peter.maydell@linaro.org> > though as I say I only compile tested it... Sure, but I reviewed it and tested it :) Samuel
diff --git a/slirp/mbuf.h b/slirp/mbuf.h index 38fedf4..ef5a4f7 100644 --- a/slirp/mbuf.h +++ b/slirp/mbuf.h @@ -81,11 +81,9 @@ struct mbuf { Slirp *slirp; bool resolution_requested; uint64_t expiration_date; + char *m_ext; /* start of dynamic buffer area, must be last element */ - union { - char m_dat[1]; /* ANSI don't like 0 sized arrays */ - char *m_ext; - }; + char m_dat[]; }; #define ifq_prev m_prev