qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v2 09/16] qapi: Permit alternates with just one


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH v2 09/16] qapi: Permit alternates with just one branch
Date: Fri, 13 Sep 2019 16:47:31 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux)

Eric Blake <address@hidden> writes:

> On 9/10/19 1:37 AM, Markus Armbruster wrote:
>> A union or alternate without branches makes no sense and doesn't work:
>> it can't be instantiated.  A union or alternate with just one branch
>> works, but is degenerate.  We accept the former, but reject the
>> latter.  Weird.  docs/devel/qapi-code-gen.txt doesn't mention the
>> difference.  It claims an alternate definition is "is similar to a
>> simple union type".
>> 
>> Permit degenerate alternates to make them consistent with unions.
>> 
>> Signed-off-by: Markus Armbruster <address@hidden>
>> ---
>>  scripts/qapi/common.py                  | 6 ++----
>>  tests/qapi-schema/alternate-empty.err   | 2 +-
>>  tests/qapi-schema/alternate-empty.json  | 4 ++--
>>  tests/qapi-schema/qapi-schema-test.json | 4 +++-
>>  tests/qapi-schema/qapi-schema-test.out  | 6 ++++--
>>  5 files changed, 12 insertions(+), 10 deletions(-)
>
> Reviewed-by: Eric Blake <address@hidden>
>
> (Might make sense if one of the branches is conditional, where depending
> on compile-time options it could be a two-branch or a one-branch alternate)

The QAPI generator doesn't even try to reason about conditions.  It
happily lets you define a union or alternate with branches that are all
conditional, and where the conditions are all false for a particular
build configuration.  Ensuring the QAPI schema is sane for all build
configurations is the schema author's problem.



reply via email to

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