From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49313) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOTSP-00053A-Rm for qemu-devel@nongnu.org; Thu, 19 Feb 2015 10:56:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YOTSM-00024b-IX for qemu-devel@nongnu.org; Thu, 19 Feb 2015 10:56:05 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51043) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOTSM-00024P-A5 for qemu-devel@nongnu.org; Thu, 19 Feb 2015 10:56:02 -0500 Message-ID: <54E6078C.3060701@redhat.com> Date: Thu, 19 Feb 2015 08:55:56 -0700 From: Eric Blake MIME-Version: 1.0 References: <1424340754-24444-1-git-send-email-mst@redhat.com> In-Reply-To: <1424340754-24444-1-git-send-email-mst@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="KPjWUgjIuClivgprnLGKN29p8bGTstg6o" Subject: Re: [Qemu-devel] [PATCH] qapi-types: add C99 index names to arrays List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" , qemu-devel@nongnu.org Cc: Peter Maydell , Markus Armbruster , Wenchao Xia , Luiz Capitulino This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --KPjWUgjIuClivgprnLGKN29p8bGTstg6o Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 02/19/2015 03:13 AM, Michael S. Tsirkin wrote: > It's not easy to figure out how monitor translates > strings: most QEMU code deals with translated indexes, > these are translated using _lookup arrays, > so you need to find the array name, and find the > appropriate offset. >=20 > This patch adds C99 indexes to lookup arrays, which makes it possible t= o > find the correct key using simple grep, and see that the matching is > correct at a glance. >=20 > Example: >=20 > Before: >=20 > const char *MigrationCapability_lookup[] =3D { > "xbzrle", > "rdma-pin-all", > "auto-converge", > "zero-blocks", > NULL, > }; >=20 > After: >=20 > const char *MigrationCapability_lookup[] =3D { > [MIGRATION_CAPABILITY_XBZRLE] =3D "xbzrle", > [MIGRATION_CAPABILITY_RDMA_PIN_ALL] =3D "rdma-pin-all", > [MIGRATION_CAPABILITY_AUTO_CONVERGE] =3D "auto-converge", > [MIGRATION_CAPABILITY_ZERO_BLOCKS] =3D "zero-blocks", > [MIGRATION_CAPABILITY_MAX] =3D NULL, > }; I like it :) >=20 > Signed-off-by: Michael S. Tsirkin > --- > scripts/qapi-types.py | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --KPjWUgjIuClivgprnLGKN29p8bGTstg6o Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJU5geMAAoJEKeha0olJ0NqZxIH/i8D8F71fA/uwW7RpzO8WaRY FpQGZaus9RqvhiJNU9qNxJwaQhaXdqRNfFeUXm0UcnieM9oZcXTfghOskrwMIedO jlr+TElHB2azrs7nq+sZabaOb/pkkIH0kQGL9cffwp7zQX0/+iWYNkgzj1GzAFPZ RV6lNilB4w9pq71y33sAr2RU17LoHsIRjJxuoPONU2yKsX4u8itRq6je3bdKbLE7 TckRz2kjgFNYsSz6BwgMaqfyr8lS3zrzQGpN/nRDJPqqVaKeclxoAw9MQZlHqXMO eI6TS8sDy8rLxHoEr9ad6kMMOqSOG1A8PmS1/M3qkcfm3YMTxx1oe3pQNjhbExk= =PDxj -----END PGP SIGNATURE----- --KPjWUgjIuClivgprnLGKN29p8bGTstg6o--