From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55791) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YS4sT-0001Oz-8Y for qemu-devel@nongnu.org; Sun, 01 Mar 2015 09:29:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YS4sQ-00078v-2B for qemu-devel@nongnu.org; Sun, 01 Mar 2015 09:29:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53848) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YS4sP-00078l-Iz for qemu-devel@nongnu.org; Sun, 01 Mar 2015 09:29:49 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t21ETmqJ001997 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Sun, 1 Mar 2015 09:29:48 -0500 Message-ID: <54F3225B.9070008@redhat.com> Date: Sun, 01 Mar 2015 09:29:47 -0500 From: Cole Robinson MIME-Version: 1.0 References: <348e8e5bb9399e700e7d24c3bac6ffe6ebd3f4d4.1425051324.git.crobinso@redhat.com> <54F0B6B9.3010601@redhat.com> In-Reply-To: <54F0B6B9.3010601@redhat.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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: Eric Blake , qemu-devel@nongnu.org Cc: Luiz Capitulino , Gerd Hoffmann , Markus Armbruster On 02/27/2015 01:26 PM, Eric Blake wrote: > On 02/27/2015 08:36 AM, Cole Robinson wrote: >> Useful for debugging. >> >> https://bugzilla.redhat.com/show_bug.cgi?id=822418 >> Signed-off-by: Cole Robinson >> --- >> v2: >> Explicitly list spice channel mappings >> Use ARRAY_SIZE macro >> >> hmp.c | 26 ++++++++++++++++++++++++++ >> 1 file changed, 26 insertions(+) >> > >> + const char *channel_name; >> + const char * const channel_names[] = { >> + [ SPICE_CHANNEL_MAIN ] = "main", >> + [ SPICE_CHANNEL_DISPLAY] = "display", >> + [ SPICE_CHANNEL_INPUTS ] = "input", > > Why 'input' instead of 'inputs'? > >> + [ SPICE_CHANNEL_CURSOR ] = "cursor", >> + [ SPICE_CHANNEL_PLAYBACK ] = "playback", >> + [ SPICE_CHANNEL_RECORD ] = "record", >> + [ SPICE_CHANNEL_TUNNEL ] = "tunnel", >> + [ SPICE_CHANNEL_SMARTCARD ] = "smartcard", >> + [ SPICE_CHANNEL_USBREDIR ] = "usbredir", >> + [ SPICE_CHANNEL_PORT ] = "port", >> + [ SPICE_CHANNEL_WEBDAV ] = "webdav", >> + }; > > Are we guaranteed that this array is never sparse? > >> + channel_name = "unknown"; >> + if (chan->value->channel_type > 0 && >> + chan->value->channel_type < ARRAY_SIZE(channel_names)) { >> + channel_name = channel_names[chan->value->channel_type]; > > If it could be sparse, you might need an additional '&& > channel_names[chan->value->channel_type]' in the conditional. Otherwise, > > Reviewed-by: Eric Blake > I've sent v3 with those bits fixed (and some checkpatch warnings :/ ) Thanks, Cole