[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v11 03/15] qapi: Forbid 'any' inside an alternat
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v11 03/15] qapi: Forbid 'any' inside an alternate |
Date: |
Thu, 18 Feb 2016 07:40:08 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 |
On 02/18/2016 05:05 AM, Markus Armbruster wrote:
> Eric Blake <address@hidden> writes:
>
>> The whole point of an alternate is to allow some type-safety while
>> still accepting more than one JSON type. Meanwhile, the 'any'
>> type exists to bypass type-safety altogether. The two are
>> incompatible: you can't accept every type, and still tell which
>> branch of the alternate to use for the parse; fix this to give a
>> sane error instead of a Python stack trace.
>>
>> Signed-off-by: Eric Blake <address@hidden>
>>
>
> Interestingly, find_alternate_member_qtype(T) can return None in two
> ways: when builtin_types[T] is None (only for T == 'any'), and when T is
> neither built-in, struct, enum or union (it must be alternate then).
>
> This leads to the question whether this patch catches exactly 'any', as
> the commit message claims, or alternate as well.
>
>>
>> @@ -629,7 +629,10 @@ def check_alternate(expr, expr_info):
>> value,
>> allow_metas=['built-in', 'union', 'struct', 'enum'])
>> qtype = find_alternate_member_qtype(value)
>
>
> Could use a test for alternate member of alternate type.
One step ahead of you: commit 3d0c4829 added the test
alternate-nested.json, and commits 44bd1276 and dd883c6f fixed the
parser to reject it (first by a hard-coded check, then via allow_metas[]
excluding alternates). 'any' is the only value that could sneak
through, because it is a subset of 'built-in' which allow_metas[]
whitelisted.
If you want to squash any of this information into the commit message,
though, I don't mind.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- [Qemu-devel] [PATCH v11 04/15] qapi: Add tests of complex objects within alternate, (continued)
- [Qemu-devel] [PATCH v11 04/15] qapi: Add tests of complex objects within alternate, Eric Blake, 2016/02/18
- [Qemu-devel] [PATCH v11 05/15] qapi-visit: Simplify how we visit common union members, Eric Blake, 2016/02/18
- [Qemu-devel] [PATCH v11 02/15] qapi: Forbid empty unions and useless alternates, Eric Blake, 2016/02/18
- [Qemu-devel] [PATCH v11 07/15] qapi-visit: Unify struct and union visit, Eric Blake, 2016/02/18
- [Qemu-devel] [PATCH v11 15/15] qapi: Change visit_start_implicit_struct to visit_start_alternate, Eric Blake, 2016/02/18
- [Qemu-devel] [PATCH v11 03/15] qapi: Forbid 'any' inside an alternate, Eric Blake, 2016/02/18
[Qemu-devel] [PATCH v11 06/15] qapi: Visit variants in visit_type_FOO_fields(), Eric Blake, 2016/02/18
[Qemu-devel] [PATCH v11 10/15] qapi: Emit structs used as variants in topological order, Eric Blake, 2016/02/18
[Qemu-devel] [PATCH v11 09/15] qapi: Adjust layout of FooList types, Eric Blake, 2016/02/18