Il 22/03/2012 21:22, Anthony Liguori ha scritto:
Signed-off-by: Paolo Bonzini<address@hidden>
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,