From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42872) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YRPc1-0005mr-HW for qemu-devel@nongnu.org; Fri, 27 Feb 2015 13:26:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YRPbw-0003jE-IK for qemu-devel@nongnu.org; Fri, 27 Feb 2015 13:26:09 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40449) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YRPbw-0003hz-Ba for qemu-devel@nongnu.org; Fri, 27 Feb 2015 13:26:04 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t1RIQ2dL030938 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 27 Feb 2015 13:26:03 -0500 Message-ID: <54F0B6B9.3010601@redhat.com> Date: Fri, 27 Feb 2015 11:26:01 -0700 From: Eric Blake MIME-Version: 1.0 References: <348e8e5bb9399e700e7d24c3bac6ffe6ebd3f4d4.1425051324.git.crobinso@redhat.com> In-Reply-To: <348e8e5bb9399e700e7d24c3bac6ffe6ebd3f4d4.1425051324.git.crobinso@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Q8BC8WKQucUrdq29o6PexgLNgJbN4fqlX" Subject: Re: [Qemu-devel] [PATCH v2] hmp: info spice: Show string channel name List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Cole Robinson , qemu-devel@nongnu.org Cc: Gerd Hoffmann , Markus Armbruster , Luiz Capitulino This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --Q8BC8WKQucUrdq29o6PexgLNgJbN4fqlX Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 02/27/2015 08:36 AM, Cole Robinson wrote: > Useful for debugging. >=20 > https://bugzilla.redhat.com/show_bug.cgi?id=3D822418 > Signed-off-by: Cole Robinson > --- > v2: > Explicitly list spice channel mappings > Use ARRAY_SIZE macro >=20 > hmp.c | 26 ++++++++++++++++++++++++++ > 1 file changed, 26 insertions(+) >=20 > + const char *channel_name; > + const char * const channel_names[] =3D { > + [ SPICE_CHANNEL_MAIN ] =3D "main", > + [ SPICE_CHANNEL_DISPLAY] =3D "display", > + [ SPICE_CHANNEL_INPUTS ] =3D "input", Why 'input' instead of 'inputs'? > + [ SPICE_CHANNEL_CURSOR ] =3D "cursor", > + [ SPICE_CHANNEL_PLAYBACK ] =3D "playback", > + [ SPICE_CHANNEL_RECORD ] =3D "record", > + [ SPICE_CHANNEL_TUNNEL ] =3D "tunnel", > + [ SPICE_CHANNEL_SMARTCARD ] =3D "smartcard", > + [ SPICE_CHANNEL_USBREDIR ] =3D "usbredir", > + [ SPICE_CHANNEL_PORT ] =3D "port", > + [ SPICE_CHANNEL_WEBDAV ] =3D "webdav", > + }; Are we guaranteed that this array is never sparse? > + channel_name =3D "unknown"; > + if (chan->value->channel_type > 0 && > + chan->value->channel_type < ARRAY_SIZE(channel_names))= { > + channel_name =3D channel_names[chan->value->channel_ty= pe]; If it could be sparse, you might need an additional '&& channel_names[chan->value->channel_type]' in the conditional. Otherwise,= Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --Q8BC8WKQucUrdq29o6PexgLNgJbN4fqlX 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/ iQEcBAEBCAAGBQJU8La5AAoJEKeha0olJ0Nq3ggH/1+lHtt3jPk1f0KmIzkdyBDO lJtMcyXwx+OHfsD5ClFPP3O+mFbpcB7JqgAPcH7SisAAuNbBEtgRY8E0PK2SmAcO ux8itYDkhkh3HbjYjfEk/WtV8vOCYTnH/2gze8FMUb63TvODmyQIdN+ToyiQJPYo yKqQPGpFReI5Qbay4I7dlM0f4bVT6J3DS3LEhur71m1F02BFcEJX1UtC6N9xHCoy I50XxLU1rlnioY+JOuI+NVsuD5BWUQOgJt7XOxsLdI1BXhdULFnFNWQSqvV1h0Bi JrmpTfrHobRDCXy1lrVFzpOzECgtLwH9W1S7WBWTC7hGyh8F7v6XkhmMHkEpISs= =1O28 -----END PGP SIGNATURE----- --Q8BC8WKQucUrdq29o6PexgLNgJbN4fqlX--