qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2] hmp: info spice: Show string channel name


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v2] hmp: info spice: Show string channel name
Date: Fri, 27 Feb 2015 11:26:01 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0

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 <address@hidden>
> ---
> 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 <address@hidden>

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

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]