qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] qapi-types: add C99 index names to arrays


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH] qapi-types: add C99 index names to arrays
Date: Thu, 19 Feb 2015 08:55:56 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0

On 02/19/2015 03:13 AM, Michael S. Tsirkin wrote:
> It's not easy to figure out how monitor translates
> strings: most QEMU code deals with translated indexes,
> these are translated using _lookup arrays,
> so you need to find the array name, and find the
> appropriate offset.
> 
> This patch adds C99 indexes to lookup arrays, which makes it possible to
> find the correct key using simple grep, and see that the matching is
> correct at a glance.
> 
> Example:
> 
> Before:
> 
> const char *MigrationCapability_lookup[] = {
>     "xbzrle",
>     "rdma-pin-all",
>     "auto-converge",
>     "zero-blocks",
>     NULL,
> };
> 
> After:
> 
> const char *MigrationCapability_lookup[] = {
>     [MIGRATION_CAPABILITY_XBZRLE] = "xbzrle",
>     [MIGRATION_CAPABILITY_RDMA_PIN_ALL] = "rdma-pin-all",
>     [MIGRATION_CAPABILITY_AUTO_CONVERGE] = "auto-converge",
>     [MIGRATION_CAPABILITY_ZERO_BLOCKS] = "zero-blocks",
>     [MIGRATION_CAPABILITY_MAX] = NULL,
> };

I like it :)

> 
> Signed-off-by: Michael S. Tsirkin <address@hidden>
> ---
>  scripts/qapi-types.py | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)

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]