From: Eric Blake <eblake@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: kwolf@redhat.com, berto@igalia.com, mst@redhat.com,
qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com,
lcapitulino@redhat.com, mreitz@redhat.com, afaerber@suse.de
Subject: Re: [Qemu-devel] [PATCH 1/2] qobject: Use 'bool' for qbool
Date: Fri, 12 Jun 2015 09:38:17 -0600 [thread overview]
Message-ID: <557AFCE9.5030100@redhat.com> (raw)
In-Reply-To: <87a8w57akk.fsf@blackfin.pond.sub.org>
[-- Attachment #1: Type: text/plain, Size: 2191 bytes --]
On 06/11/2015 11:35 PM, Markus Armbruster wrote:
> Patch looks good to me, but it made me wonder about something. Please
> find the question inline.
>
> Eric Blake <eblake@redhat.com> writes:
>
>> We require a C99 compiler, so let's use 'bool' instead of 'int'
>> when dealing with boolean values. There are few enough clients
>> to fix them all in one pass.
>>
>> @@ -593,7 +593,7 @@ static QObject *parse_escape(JSONParserContext *ctxt, va_list *ap)
>> if (token_is_escape(token, "%p")) {
>> obj = va_arg(*ap, QObject *);
>> } else if (token_is_escape(token, "%i")) {
>> - obj = QOBJECT(qbool_from_int(va_arg(*ap, int)));
>> + obj = QOBJECT(qbool_from_bool(va_arg(*ap, int)));
>
> Funny: JSON_ESCAPE "%i" gets an int, but maps it to bool. See also
> patch to check-qjson.c below.
>
> Is this feature actually used anywhere other than the tests?
>
When using va_arg(), you have to use the type argument that things
promote to when called through var-args (that is, va_arg(*ap, bool)
would be a compiler warning).
I don't know if anyone besides the testsuite is using %i; but I've
already mentioned in another thread [1] that the correlation between...
>>
>> - obj = qobject_from_jsonf("%i", true);
>> + /* Test that non-zero values other than 1 get collapsed to true */
>> + obj = qobject_from_jsonf("%i", 2);
>> g_assert(obj != NULL);
>> g_assert(qobject_type(obj) == QTYPE_QBOOL);
>
> These are test test cases for JSON_ESCAPE "%i".
...qobject_from_json in one file to the implementation of %i in another
was very hard to trace when writing this patch, as well as the idea of
getting rid of the remaining 2 out of only 3 clients of %p [1]. So it's
already on my table of ideas to do a followup patch that adds
documentation, and audits all clients to see what can be pruned.
[1] https://lists.gnu.org/archive/html/qemu-devel/2015-05/msg04660.html
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
next prev parent reply other threads:[~2015-06-12 15:40 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-15 22:24 [Qemu-devel] [PATCH 0/2] Use bool for QBool Eric Blake
2015-05-15 22:24 ` [Qemu-devel] [PATCH 1/2] qobject: Use 'bool' for qbool Eric Blake
2015-05-16 13:30 ` Andreas Färber
2015-05-16 17:13 ` Eric Blake
2015-05-18 6:42 ` Markus Armbruster
2015-05-19 12:59 ` Alberto Garcia
2015-06-12 5:35 ` Markus Armbruster
2015-06-12 15:38 ` Eric Blake [this message]
2015-05-15 22:25 ` [Qemu-devel] [PATCH 2/2] qobject: Use 'bool' inside qdict Eric Blake
2015-05-19 13:00 ` Alberto Garcia
2015-05-28 19:54 ` [Qemu-devel] [PATCH 0/2] Use bool for QBool Luiz Capitulino
2015-06-11 17:53 ` Luiz Capitulino
2015-06-16 14:53 ` Markus Armbruster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=557AFCE9.5030100@redhat.com \
--to=eblake@redhat.com \
--cc=afaerber@suse.de \
--cc=armbru@redhat.com \
--cc=berto@igalia.com \
--cc=kwolf@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=mreitz@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.