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 15:22:52 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2

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<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?

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;
      }





reply via email to

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