All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Cole Robinson <crobinso@redhat.com>, qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	Luiz Capitulino <lcapitulino@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2] hmp: info spice: Show string channel name
Date: Fri, 27 Feb 2015 11:26:01 -0700	[thread overview]
Message-ID: <54F0B6B9.3010601@redhat.com> (raw)
In-Reply-To: <348e8e5bb9399e700e7d24c3bac6ffe6ebd3f4d4.1425051324.git.crobinso@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1632 bytes --]

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>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

  reply	other threads:[~2015-02-27 18:26 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 [this message]
2015-03-01 14:29   ` Cole Robinson

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=54F0B6B9.3010601@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=crobinso@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.