qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Cole Robinson <crobinso@redhat.com>
To: Eric Blake <eblake@redhat.com>, qemu-devel@nongnu.org
Cc: Luiz Capitulino <lcapitulino@redhat.com>,
	Gerd Hoffmann <kraxel@redhat.com>,
	Markus Armbruster <armbru@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2] hmp: info spice: Show string channel name
Date: Sun, 01 Mar 2015 09:29:47 -0500	[thread overview]
Message-ID: <54F3225B.9070008@redhat.com> (raw)
In-Reply-To: <54F0B6B9.3010601@redhat.com>

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 <crobinso@redhat.com>
>> ---
>> 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 <eblake@redhat.com>
> 

I've sent v3 with those bits fixed (and some checkpatch warnings :/ )

Thanks,
Cole

      reply	other threads:[~2015-03-01 14:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-27 15:36 [Qemu-devel] [PATCH v2] hmp: info spice: Show string channel name Cole Robinson
2015-02-27 18:26 ` Eric Blake
2015-03-01 14:29   ` Cole Robinson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54F3225B.9070008@redhat.com \
    --to=crobinso@redhat.com \
    --cc=armbru@redhat.com \
    --cc=eblake@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).