From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:56672) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SAoXE-0004Ay-0G for qemu-devel@nongnu.org; Thu, 22 Mar 2012 16:23:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SAoXB-0001iq-K3 for qemu-devel@nongnu.org; Thu, 22 Mar 2012 16:22:59 -0400 Received: from mail-gx0-f173.google.com ([209.85.161.173]:40510) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SAoXB-0001ie-FE for qemu-devel@nongnu.org; Thu, 22 Mar 2012 16:22:57 -0400 Received: by ggnj2 with SMTP id j2so2594266ggn.4 for ; Thu, 22 Mar 2012 13:22:56 -0700 (PDT) Message-ID: <4F6B8A1C.3080209@codemonkey.ws> Date: Thu, 22 Mar 2012 15:22:52 -0500 From: Anthony Liguori MIME-Version: 1.0 References: <1332417072-20329-1-git-send-email-pbonzini@redhat.com> <1332417072-20329-7-git-send-email-pbonzini@redhat.com> In-Reply-To: <1332417072-20329-7-git-send-email-pbonzini@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 06/10] qapi: simplify qmp_input_next_list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: anthony@codemonkey.vs, lcapitulino@redhat.com, eblake@redhat.com, qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com On 03/22/2012 06:51 AM, Paolo Bonzini wrote: > Tweak a bit the code so that there is cleaner separation between > operation on the list and operation on the output. The next patch > requires this change. > > Signed-off-by: Paolo Bonzini 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? Regards, Anthony Liguori > --- > qapi/qmp-input-visitor.c | 15 +++++++-------- > 1 files changed, 7 insertions(+), 8 deletions(-) > > diff --git a/qapi/qmp-input-visitor.c b/qapi/qmp-input-visitor.c > index ef9288f..dfc859a 100644 > --- a/qapi/qmp-input-visitor.c > +++ b/qapi/qmp-input-visitor.c > @@ -64,9 +64,7 @@ static const QObject *qmp_input_get_object(QmpInputVisitor *qiv, > static void qmp_input_push(QmpInputVisitor *qiv, const QObject *obj, Error **errp) > { > qiv->stack[qiv->nb_stack].obj = obj; > - if (qobject_type(obj) == QTYPE_QLIST) { > - qiv->stack[qiv->nb_stack].entry = qlist_first(qobject_to_qlist(obj)); > - } > + qiv->stack[qiv->nb_stack].entry = NULL; > qiv->nb_stack++; > > if (qiv->nb_stack>= QIV_STACK_SIZE) { > @@ -134,16 +132,17 @@ static GenericList *qmp_input_next_list(Visitor *v, GenericList **list, > StackObject *so =&qiv->stack[qiv->nb_stack - 1]; > > if (so->entry == NULL) { > + so->entry = qlist_first(qobject_to_qlist(so->obj)); > + } else { > + so->entry = qlist_next(so->entry); > + } > + > + if (so->entry == NULL) { > return NULL; > } > > entry = g_malloc0(sizeof(*entry)); > if (*list) { > - so->entry = qlist_next(so->entry); > - if (so->entry == NULL) { > - g_free(entry); > - return NULL; > - } > (*list)->next = entry; > } >