qemu-devel
[Top][All Lists]
Advanced

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

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


From: Paolo Bonzini
Subject: [Qemu-devel] [PATCH 06/10] qapi: simplify qmp_input_next_list
Date: Thu, 22 Mar 2012 12:51:08 +0100

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 <address@hidden>
---
 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





reply via email to

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