From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51146) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YpcXs-0005Oh-A3 for qemu-devel@nongnu.org; Tue, 05 May 2015 09:05:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YpcXn-0008JV-Pe for qemu-devel@nongnu.org; Tue, 05 May 2015 09:05:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47773) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YpcXm-0008J2-PB for qemu-devel@nongnu.org; Tue, 05 May 2015 09:05:51 -0400 Message-ID: <5548C004.5080403@redhat.com> Date: Tue, 05 May 2015 07:05:08 -0600 From: Eric Blake MIME-Version: 1.0 References: <1430751937-17523-1-git-send-email-eblake@redhat.com> <1430751937-17523-21-git-send-email-eblake@redhat.com> <87ioc7v16e.fsf@blackfin.pond.sub.org> In-Reply-To: <87ioc7v16e.fsf@blackfin.pond.sub.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="xBjCpS1vGogRDkfdoWfiM5nK3pmGTsWdQ" Subject: Re: [Qemu-devel] [PATCH v8 20/40] qapi: Better error messages for duplicated expressions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: kwolf@redhat.com, berto@igalia.com, qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --xBjCpS1vGogRDkfdoWfiM5nK3pmGTsWdQ Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 05/05/2015 03:11 AM, Markus Armbruster wrote: > Eric Blake writes: >=20 >> The previous commit demonstrated that the generator overlooked >> duplicate expressions: >> - a complex type or command reusing a built-in type name >> - redeclaration of a type name, whether by the same or different >> metatype >> - redeclaration of a command or event >> - collision of a type with implicit 'Kind' enum for a union >> - collision with an implicit MAX enum constant >> >> Since the c_type() function in the generator treats all names >> as being in the same namespace, this patch adds a global array >> to track all known names and their source, to prevent collisions >> before it can cause further problems. While valid .json files >> won't trigger any of these cases, we might as well be nicer to >> developers that make a typo while trying to add new QAPI code. >> >> +def add_name(name, info, meta, implicit =3D False): >> + global all_names >> + if name in all_names: >> + raise QAPIExprError(info, >> + "%s '%s' is already defined" >> + %(all_names[name], name)) >=20 > Let's put a space between binary operator % and its right operand. I was copying existing examples, but I can easily do a separate followup patch that unifies the style of % formatting (or switches to + concatenation where that is more legible). >=20 >> + if not implicit and name[-4:] =3D=3D 'Kind': >> + raise QAPIExprError(info, >> + "%s '%s' should not end in 'Kind'" >> + %(meta, name)) >=20 > Likewise. Can fix up on commit. Of course, I'll wait until any of your fixups in the pull request are already in place to write such a followup, to minimize rebase churn. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --xBjCpS1vGogRDkfdoWfiM5nK3pmGTsWdQ 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/ iQEcBAEBCAAGBQJVSMAEAAoJEKeha0olJ0NqQWIIAIRHdEyWiiuf8giJxz9MxLrK GyR6qZ3DEcoJvSTQuuqKzhWEJ3xxbmR9XqwAmK4C5jrG7jtWv+KakTFcJFiwuJZF fm3QrguHXTK1ufGPh9GRQtI4Lyth35QsldmxOYZ9CfkVNV4Ebs4ZnGp235rxqDiX c38prCQxXVm70TsjhIUUMklRAmv6pbPD7MD5A4bphOPBd5rSZ+3dYks7rHG+AXTJ zNAcwiMVKBqw+nUT1DC6cqWyuEhNSdQtB7slAsolVzmlCNFWdbxyZgFnavYyBQlT l3ycCB61PZLALIfrS6SE+P1qOOWumpjR0aCl73/IvZ4aNHIHsdZIYE00hiqyjjM= =J2m1 -----END PGP SIGNATURE----- --xBjCpS1vGogRDkfdoWfiM5nK3pmGTsWdQ--