From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59096) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZzBaY-00042I-9p for qemu-devel@nongnu.org; Wed, 18 Nov 2015 17:52:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZzBaV-0002IM-4V for qemu-devel@nongnu.org; Wed, 18 Nov 2015 17:52:30 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38832) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZzBaU-0002I4-Ua for qemu-devel@nongnu.org; Wed, 18 Nov 2015 17:52:27 -0500 References: <1447836791-369-1-git-send-email-eblake@redhat.com> <1447836791-369-28-git-send-email-eblake@redhat.com> From: Eric Blake Message-ID: <564D0125.50903@redhat.com> Date: Wed, 18 Nov 2015 15:52:21 -0700 MIME-Version: 1.0 In-Reply-To: <1447836791-369-28-git-send-email-eblake@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="jm7XDk3RG48IVSSEgVRxXMxSg1JoAfx2W" Subject: Re: [Qemu-devel] [PATCH v12 27/36] qapi: Forbid case-insensitive clashes List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: armbru@redhat.com, Michael Roth This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --jm7XDk3RG48IVSSEgVRxXMxSg1JoAfx2W Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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. >=20 > @@ -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] =3D 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.na= me) 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.= --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --jm7XDk3RG48IVSSEgVRxXMxSg1JoAfx2W Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJWTQElAAoJEKeha0olJ0Nq6h0H/0cUq833EDAoPjtbBIxSKWck SeA7hbuJI7rTw5qLypUbQd8iYmTfskLGfOUYMTlXQZikuRn9bPHGiTMTGHATdBB+ HAZGXXv4JEbH2PeXaTPALj8INodBcpLGWeA0shLPtyEbE05ssoaXHiROYx0Fu1V9 j5SVLa7DEhAbiaYxCw2z8HVNSI3dnLSly4fov8wQSnRb6MinaC2t832BQ/XVAqnq t9eFExzyPEfBRldG/KrruWUdLBneA7Jq/vtJmhUEfDTVc7CC7rMcOLf0gj4ESc8u Fo2YWQ1eYy+9aMDJ4jlkBy4i6PZLm9TQ/8Vxn1MifEwucF+OYbtaQtwe7PhKFT0= =4Ro9 -----END PGP SIGNATURE----- --jm7XDk3RG48IVSSEgVRxXMxSg1JoAfx2W--