[Top][All Lists]

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

Re: [Qemu-devel] [PATCH v7 03/15] qapi: Require all branches of flat uni

From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v7 03/15] qapi: Require all branches of flat union enum to be covered
Date: Tue, 14 Jun 2016 07:46:01 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

On 06/14/2016 07:24 AM, Markus Armbruster wrote:
> Eric Blake <address@hidden> writes:
>> We were previously enforcing that all flat union branches were
>> found in the corresponding enum, but not that all enum values
>> were covered by branches.  The resulting generated code would
>> abort() if the user passes the uncovered enum value.
>> Signed-off-by: Eric Blake <address@hidden>
> I'd let the cases not mentioned default to the empty type (ample
> precedence in other languages), but I can live with making the user ask
> for the empty type explicitly.  But we should then make that less
> cumbersome than now: you have to define an empty struct type, and use
> that.  Examples of such hoop-jumping: CpuInfoOther, Abort,
> NetdevNoneOptions.

Later in the series, I do just that, so that we can write 'other':{}
instead of 'other':'CpuInfoOther'.

What I did not do (but maybe should) is make that short syntax possible
on simple unions (so that we could do 'abort':{} rather than
'abort':'Abort') - and merely distinguish that simple unions cannot
stick anything within the {}, thus leaving non-empty anonymous branches
only for discriminated unions.  Can do that as a followup or if this
series needs a respin.

> Patch looks good.

Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

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