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: Cole Robinson
Subject: Re: [Qemu-devel] [PATCH v2] hmp: info spice: Show string channel name
Date: Sun, 01 Mar 2015 09:29:47 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0

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 <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>
> 

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

Thanks,
Cole



reply via email to

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