qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@gmail.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] qom: Introduce object_property_remove()
Date: Tue,  7 Jan 2014 10:32:29 +0900	[thread overview]
Message-ID: <1389058349-13367-1-git-send-email-namhyung@gmail.com> (raw)

As the object_property_del(), object_property_del_child() and
object_property_del_all() do similar job, factor out the common code
to a new object_property_remove().

It'll also remove unnecessary call to object_property_find() in case
of object_property_del_child() so that we can get rid of the unused
errp argument too.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
---
 qom/object.c | 39 ++++++++++++++++++---------------------
 1 file changed, 18 insertions(+), 21 deletions(-)

diff --git a/qom/object.c b/qom/object.c
index fc19cf6..a38cf72 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -347,30 +347,35 @@ static inline bool object_property_is_link(ObjectProperty *prop)
     return strstart(prop->type, "link<", NULL);
 }
 
+static void object_property_remove(Object *obj, ObjectProperty *prop)
+{
+    QTAILQ_REMOVE(&obj->properties, prop, node);
+
+    if (prop->release) {
+        prop->release(obj, prop->name, prop->opaque);
+    }
+
+    g_free(prop->name);
+    g_free(prop->type);
+    g_free(prop);
+}
+
 static void object_property_del_all(Object *obj)
 {
     while (!QTAILQ_EMPTY(&obj->properties)) {
         ObjectProperty *prop = QTAILQ_FIRST(&obj->properties);
 
-        QTAILQ_REMOVE(&obj->properties, prop, node);
-
-        if (prop->release) {
-            prop->release(obj, prop->name, prop->opaque);
-        }
-
-        g_free(prop->name);
-        g_free(prop->type);
-        g_free(prop);
+        object_property_remove(obj, prop);
     }
 }
 
-static void object_property_del_child(Object *obj, Object *child, Error **errp)
+static void object_property_del_child(Object *obj, Object *child)
 {
     ObjectProperty *prop;
 
     QTAILQ_FOREACH(prop, &obj->properties, node) {
         if (object_property_is_child(prop) && prop->opaque == child) {
-            object_property_del(obj, prop->name, errp);
+            object_property_remove(obj, prop);
             break;
         }
     }
@@ -387,7 +392,7 @@ void object_unparent(Object *obj)
         (obj->class->unparent)(obj);
     }
     if (obj->parent) {
-        object_property_del_child(obj->parent, obj, NULL);
+        object_property_del_child(obj->parent, obj);
     }
     object_unref(obj);
 }
@@ -763,15 +768,7 @@ void object_property_del(Object *obj, const char *name, Error **errp)
         return;
     }
 
-    if (prop->release) {
-        prop->release(obj, name, prop->opaque);
-    }
-
-    QTAILQ_REMOVE(&obj->properties, prop, node);
-
-    g_free(prop->name);
-    g_free(prop->type);
-    g_free(prop);
+    object_property_remove(obj, prop);
 }
 
 void object_property_get(Object *obj, Visitor *v, const char *name,
-- 
1.7.11.7

                 reply	other threads:[~2014-01-07  1:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1389058349-13367-1-git-send-email-namhyung@gmail.com \
    --to=namhyung@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).