From: Paolo Bonzini <pbonzini@redhat.com>
To: Anthony Liguori <anthony@codemonkey.ws>
Cc: anthony@codemonkey.vs, lcapitulino@redhat.com, eblake@redhat.com,
qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com
Subject: Re: [Qemu-devel] [PATCH 06/10] qapi: simplify qmp_input_next_list
Date: Thu, 22 Mar 2012 22:24:04 +0100 [thread overview]
Message-ID: <4F6B9874.4020108@redhat.com> (raw)
In-Reply-To: <4F6B8A1C.3080209@codemonkey.ws>
Il 22/03/2012 21:22, Anthony Liguori ha scritto:
>>
>> Signed-off-by: Paolo Bonzini<pbonzini@redhat.com>
>
> I've been staring a this patch for the past 5 minutes and I can't figure
> out what's going on here.
>
> Maybe the code was too obscure to begin with. Could you enhance the
> commit message a bit with what's going on here?
There's three possible questions about what's going on:
1) What's going on before the patch with so->entry
2) What's going on after the patch with so->entry
3) What's going on with *list. The patch doesn't change this, it just
unties it with so->entry, but it's the most puzzling part so the
question is a good one. :)
First of all, so->entry here is advanced and also used to figure out
whether we have a next element. It is then accessed in qmp_input_get_obj.
The caller must:
* call start_list
* call next_list for each element *including the first*
* on the first call to next_list, the result is the head of the list
(works for both input and output visitor).
Before: so->entry is initialized to qlist_first on start_list. The
first call will have *list == NULL, so it skips the qlist_next. The
caller assigns the result and makes *list not NULL, so that the next
iteration will advance so->entry and modify (*list)->next.
After: so->entry is initialized to NULL on start_list. The first call
sees so->entry == NULL and does qlist_first; subsequent calls do
qlist_next. *list is handled same as above: assignment done by the
caller on the first call, done by next_list on the next ones.
Thanks for making me write all this down, because it looks like there is
still room for further simplifying the handling of *list (for example,
do not have the caller write the list head). I'll submit a v2.
Depending on the amount of simplification I'll document the result in
either a code comment or the commit message.
Luckily this code is very well tested. It broke all the time for me. :P
Paolo
next prev parent reply other threads:[~2012-03-22 21:24 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-22 11:51 [Qemu-devel] [PATCH 00/10] QAPI minor fixes and strict mode Paolo Bonzini
2012-03-22 11:51 ` [Qemu-devel] [PATCH 01/10] qapi: add a test case for type errors Paolo Bonzini
2012-03-22 20:17 ` Anthony Liguori
2012-03-22 11:51 ` [Qemu-devel] [PATCH 02/10] qapi: fail hard on stack imbalance Paolo Bonzini
2012-03-22 20:17 ` Anthony Liguori
2012-03-26 14:15 ` Luiz Capitulino
2012-03-26 15:06 ` Michael Roth
2012-03-22 11:51 ` [Qemu-devel] [PATCH 03/10] qapi: fix memory leak on error Paolo Bonzini
2012-03-22 20:17 ` Anthony Liguori
2012-03-22 11:51 ` [Qemu-devel] [PATCH 04/10] qapi: shortcut visits on errors Paolo Bonzini
2012-03-22 20:17 ` Anthony Liguori
2012-03-22 11:51 ` [Qemu-devel] [PATCH 05/10] qapi: allow freeing partially-allocated objects Paolo Bonzini
2012-03-22 20:18 ` Anthony Liguori
2012-03-22 11:51 ` [Qemu-devel] [PATCH 06/10] qapi: simplify qmp_input_next_list Paolo Bonzini
2012-03-22 20:22 ` Anthony Liguori
2012-03-22 21:24 ` Paolo Bonzini [this message]
2012-03-22 21:34 ` Anthony Liguori
2012-03-22 21:38 ` [Qemu-devel] [PATCH v2 06/10] qapi: untangle next_list Paolo Bonzini
2012-03-23 16:42 ` Michael Roth
2012-03-22 11:51 ` [Qemu-devel] [PATCH 07/10] qapi: place outermost object on qiv stack Paolo Bonzini
2012-03-22 20:25 ` Anthony Liguori
2012-03-22 11:51 ` [Qemu-devel] [PATCH 08/10] qapi: add strict mode to input visitor Paolo Bonzini
2012-03-22 20:25 ` Anthony Liguori
2012-04-02 10:34 ` Laurent Desnogues
2012-04-02 11:28 ` Paolo Bonzini
2012-03-22 11:51 ` [Qemu-devel] [PATCH 09/10] qmp: add and use q type specifier Paolo Bonzini
2012-03-22 20:27 ` Anthony Liguori
2012-03-22 11:51 ` [Qemu-devel] [PATCH 10/10] qmp: parse commands in strict mode Paolo Bonzini
2012-03-22 20:28 ` Anthony Liguori
2012-03-22 20:30 ` Luiz Capitulino
2012-03-22 21:39 ` [Qemu-devel] [PATCH 11/10] qmp: document strict parsing Paolo Bonzini
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=4F6B9874.4020108@redhat.com \
--to=pbonzini@redhat.com \
--cc=anthony@codemonkey.vs \
--cc=anthony@codemonkey.ws \
--cc=eblake@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=mdroth@linux.vnet.ibm.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.