Received: from eggs.gnu.org ([2001:4830:134:3::10]:38867) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aTPMV-0000VO-5l for qemu-devel@nongnu.org; Wed, 10 Feb 2016 02:38:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aTPMQ-0003ql-5a for qemu-devel@nongnu.org; Wed, 10 Feb 2016 02:38:55 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48699) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aTPMQ-0003qh-0Q for qemu-devel@nongnu.org; Wed, 10 Feb 2016 02:38:50 -0500 From: Markus Armbruster References: <1453219845-30939-1-git-send-email-eblake@redhat.com> <1453219845-30939-22-git-send-email-eblake@redhat.com> <87vb6m7l25.fsf@blackfin.pond.sub.org> <56A17830.7010305@redhat.com> <87mvrx24fa.fsf@blackfin.pond.sub.org> <56BA82F7.1020202@redhat.com> Date: Wed, 10 Feb 2016 08:38:46 +0100 In-Reply-To: <56BA82F7.1020202@redhat.com> (Eric Blake's message of "Tue, 9 Feb 2016 17:23:19 -0700") Message-ID: <87io1x816h.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v9 21/37] qapi: Document visitor interfaces, add assertions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: marcandre.lureau@redhat.com, qemu-devel@nongnu.org, Michael Roth Eric Blake writes: > On 01/22/2016 05:18 AM, Markus Armbruster wrote: [...] >> Crazy thought: unboxing the implicit struct should make this interface >> wart go away. If we commit to do that later, we can "solve" our >> documentation problem the same way as for visit_start_union(): FIXME >> should not be needed. > > I _want_ to get rid of the boxing. But as it is not in my current queue > of pending patches, it will have to wait until the current queue is > flushed; so I'm going for documenting it with FIXMEs for now. > > Basically, our current flat union representation is: > > struct Union { > Type tag; > union { > Subtype1 *one; > Subtype2 *two; > } u; > }; > > which requires two malloc's to completely populate the struct, and where > we access union->u.one->member, or pass union->u.one to a function > taking Subtype1*. But it _should_ be: > > struct Union { > Type tag; > union { > Subtype1 one; > Subtype2 two; > } u; > }; > > where a single malloc is sufficient, and where we access > union->u.one.member, or pass &union->u.one to a function taking Subtype1*. > > It's a tree-wide conversion; and may be easier if done in stages (fix > the generator to take a temporary boolean flag on whether a particular > structure uses inline or boxing, then a series of patches adding that > flag to a few QMP commands at a time, then a final patch to clear out > the temporary flag support) rather than all at once. I'm not sure how > much Coccinelle will help, because I specifically haven't started the > conversion work until after we can get the current backlog flushed. I hope the use of unions in C code is localized enough to do it in one step.