qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v9 21/37] qapi: Document visitor interfaces, add


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH v9 21/37] qapi: Document visitor interfaces, add assertions
Date: Wed, 10 Feb 2016 08:38:46 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Eric Blake <address@hidden> 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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]