[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [PATCH 1/2] block/qapi: make two printf() formats liter
From: |
Eric Blake |
Subject: |
Re: [Qemu-block] [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
signature.asc
Description: OpenPGP digital signature
[Qemu-block] [PATCH 2/2] block/qapi: fix unbounded stack for dump_qdict, Peter Xu, 2016/03/09
Re: [Qemu-block] [Qemu-devel] [PATCH 0/2] block/qapi: trivial fixes, Markus Armbruster, 2016/03/22