qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v3 for-2.5 07/12] qjson: Inline token_is_escape(


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH v3 for-2.5 07/12] qjson: Inline token_is_escape() and simplify
Date: Thu, 26 Nov 2015 09:34:27 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Eric Blake <address@hidden> writes:

> On 11/25/2015 02:23 PM, Markus Armbruster wrote:
>> Signed-off-by: Markus Armbruster <address@hidden>
>> ---
>>  qobject/json-parser.c | 32 +++++++++++++++-----------------
>>  1 file changed, 15 insertions(+), 17 deletions(-)
>> 
>
>> +    if (!strcmp(val, "%p")) {
>>          obj = va_arg(*ap, QObject *);
>> -    } else if (token_is_escape(token, "%i")) {
>> +    } else if (!strcmp(val, "%i")) {
>>          obj = QOBJECT(qbool_from_bool(va_arg(*ap, int)));
>> -    } else if (token_is_escape(token, "%d")) {
>> +    } else if (!strcmp(val, "%d")) {
>>          obj = QOBJECT(qint_from_int(va_arg(*ap, int)));
>> -    } else if (token_is_escape(token, "%ld")) {
>> +    } else if (!strcmp(val, "%ld")) {
>
> Not for this patch, but I'd love to kill our support for "%ld" - it has
> behavior that differs between 32-bit and 64-bit platforms, and is
> therefore useless for our goal of using fixed-width integer types.
>
>>          obj = QOBJECT(qint_from_int(va_arg(*ap, long)));
>> -    } else if (token_is_escape(token, "%lld") ||
>> -               token_is_escape(token, "%I64d")) {
>> +    } else if (!strcmp(val, "%lld") ||
>> +               !strcmp(val, "%I64d")) {
>
> Not for this patch, but I'd love to kill our support for "%I64d". Isn't
> modern mingw friendlier to using POSIX escape sequences in printf()?
> I'm assuming mingw is the only reason we have this hold-out?

These escapes are chosen so we can get type checking from gcc via format
attribute.  The code here is somewhat unclean; it should arguably
compare to "%" PRId64, whatever that may be.  Instead, we accept
anything we anticipate it could be.

> Reviewed-by: Eric Blake <address@hidden>

Thanks!



reply via email to

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