qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 1/2] block/qapi: make two printf() formats liter


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH 1/2] block/qapi: make two printf() formats literal
Date: Wed, 9 Mar 2016 15:14:03 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0

On 03/08/2016 10:56 PM, Peter Xu wrote:
> Fix two places to use literal printf format when possible.
> 
> Signed-off-by: Peter Xu <address@hidden>
> ---
>  block/qapi.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)

Reviewed-by: Eric Blake <address@hidden>

> 
> diff --git a/block/qapi.c b/block/qapi.c
> index db2d3fb..c4c2115 100644
> --- a/block/qapi.c
> +++ b/block/qapi.c
> @@ -619,9 +619,8 @@ static void dump_qlist(fprintf_function func_fprintf, 
> void *f, int indentation,
>      for (entry = qlist_first(list); entry; entry = qlist_next(entry), i++) {
>          QType type = qobject_type(entry->value);
>          bool composite = (type == QTYPE_QDICT || type == QTYPE_QLIST);
> -        const char *format = composite ? "%*s[%i]:\n" : "%*s[%i]: ";
> -
> -        func_fprintf(f, format, indentation * 4, "", i);
> +        func_fprintf(f, "%*s[%i]:%c", indentation * 4, "", i,
> +                     composite ? '\n' : ' ');

[The nerd in me wants to point out that you could avoid the ternary by
writing '"\n "[composite]', but that's too ugly to use outside of IOCCC
submissions, and I wouldn't be surprised if it (rightfully) triggers
clang warnings]

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