qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v12 27/36] qapi: Forbid case-insensitive clashes


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v12 27/36] qapi: Forbid case-insensitive clashes
Date: Wed, 18 Nov 2015 15:52:21 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

On 11/18/2015 01:53 AM, Eric Blake wrote:
> 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 c_enum_const() [via c_name(name, False).upper()].
> 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.
> 

> @@ -1202,11 +1205,32 @@ class QAPISchema(object):
>      def _def_entity(self, ent):
>          # Only the predefined types are allowed to not have info
>          assert ent.info or self._predefining
> -        assert ent.name not in self._entity_dict
> -        self._entity_dict[ent.name] = ent
> +        # On insertion, we need to check for an exact match in either
> +        # namespace, then for case collision in a single namespace
> +        if self.lookup_entity(ent.name):
> +            raise QAPIExprError(ent.info,
> +                                "Entity '%s' already defined" % end.name)

Latent typo (s/end/ent/); we can't hit this line of code until we nuke
ad hoc parser checks.  So using an assert here is better in the meantime.

-- 
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]