[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v11 20/28] qapi: Forbid case-insensitive clashes
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v11 20/28] qapi: Forbid case-insensitive clashes |
Date: |
Thu, 12 Nov 2015 22:32:51 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 |
On 11/11/2015 07:53 AM, Markus Armbruster wrote:
> Eric Blake <address@hidden> writes:
>
>> In general, designing user interfaces that rely on case
>> distinction is poor practice. Another benefit of enforcing
>> a restriction against case-insensitive clashes is that we
>> no longer have to worry about the situation of enum values
>> that could be distinguished by case if mapped by c_name(),
>> but which cannot be distinguished when mapped to C as
>> ALL_CAPS by camel_to_upper().
>
> With PATCH 19, they're mapped by c_name(N).upper().
>
Yep, need to reword that, thanks to rebase churn.
>> Thus, having the generator
>> look for case collisions up front will prevent developers
>> from worrying whether different munging rules for member
>> names compared to enum values as a discriminator will cause
>> any problems in qapi unions.
>>
>> There is also the possibility that we may want to add a
>> future extension to QMP of teaching it to be case-insensitive
>> (the user could request command 'Quit' instead of 'quit', or
>> could spell a struct field as 'CPU' instead of 'cpu'). But
>> for that to be a practical extension, we cannot break
>> backwards compatibility with any existing struct that was
>> already relying on case sensitivity. Fortunately, after the
>> previous patch cleaned up CpuInfo, there are no such existing
>> qapi structs. Of course, the idea of a future extension is
>> not as strong of a reason to make the change.
>>
>> At any rate, it is easier to be strict now, and relax things
>> later if we find a reason to need case-sensitive QMP members,
>> than it would be to wish we had the restriction in place.
>
> Suggest to briefly mention the new test.
Will do.
>
>> Signed-off-by: Eric Blake <address@hidden>
>
> Patch looks good.
>
Hmm - this only enforces member name case clashes. It would also be
worth enforcing command/event/type collisions (technically, only
command/event clashes are user-visible, but tracking all entities is
probably easier) - probably by modifying QAPISchema._def_entity() and
.lookup_entity() to do the same trick of keying the map by a munged
name. I'll see about adding that as an additional patch.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- Re: [Qemu-devel] [PATCH v11 13/28] qapi: Hoist tag collision check to Variants.check(), (continued)
[Qemu-devel] [PATCH v11 11/28] qapi: Check for qapi collisions of flat union branches, Eric Blake, 2015/11/11
[Qemu-devel] [PATCH v11 15/28] qapi: Track owner of each object member, Eric Blake, 2015/11/11
[Qemu-devel] [PATCH v11 16/28] qapi: Detect collisions in C member names, Eric Blake, 2015/11/11
[Qemu-devel] [PATCH v11 20/28] qapi: Forbid case-insensitive clashes, Eric Blake, 2015/11/11
[Qemu-devel] [PATCH v11 17/28] cpu: Convert CpuInfo into flat union, Eric Blake, 2015/11/11
[Qemu-devel] [PATCH v11 24/28] qapi: Add positive tests to qapi-schema-test, Eric Blake, 2015/11/11
[Qemu-devel] [PATCH v11 26/28] qapi: Move duplicate member checks to schema check(), Eric Blake, 2015/11/11
[Qemu-devel] [PATCH v11 25/28] qapi: Simplify visits of optional fields, Eric Blake, 2015/11/11
[Qemu-devel] [PATCH v11 22/28] qapi: Simplify visiting of alternate types, Eric Blake, 2015/11/11