qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 06/10] qapi: simplify qmp_input_next_list


From: Anthony Liguori
Subject: Re: [Qemu-devel] [PATCH 06/10] qapi: simplify qmp_input_next_list
Date: Thu, 22 Mar 2012 16:34:44 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2

On 03/22/2012 04:24 PM, Paolo Bonzini wrote:
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,

No problem :-) I was really looking for the commit message breakdown. I convinced myself that what you were doing was right but it took me sufficiently long that I thought it warranted a better commit message.

Regards,

Anthony Liguori



reply via email to

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