From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:42048) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SAgYI-0002rG-8K for qemu-devel@nongnu.org; Thu, 22 Mar 2012 07:51:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SAgYB-0004kM-HJ for qemu-devel@nongnu.org; Thu, 22 Mar 2012 07:51:33 -0400 Received: from mail-wg0-f53.google.com ([74.125.82.53]:55089) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SAgYB-0004iC-8Q for qemu-devel@nongnu.org; Thu, 22 Mar 2012 07:51:27 -0400 Received: by mail-wg0-f53.google.com with SMTP id fm10so1298262wgb.10 for ; Thu, 22 Mar 2012 04:51:26 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Thu, 22 Mar 2012 12:51:08 +0100 Message-Id: <1332417072-20329-7-git-send-email-pbonzini@redhat.com> In-Reply-To: <1332417072-20329-1-git-send-email-pbonzini@redhat.com> References: <1332417072-20329-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 06/10] qapi: simplify qmp_input_next_list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: mdroth@linux.vnet.ibm.com, eblake@redhat.com, anthony@codemonkey.vs, lcapitulino@redhat.com 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 --- 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; } -- 1.7.9.1