[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 01/17] qom: Clearer reference counting in object_initialize_child
From: |
Markus Armbruster |
Subject: |
[PATCH 01/17] qom: Clearer reference counting in object_initialize_childv() |
Date: |
Tue, 28 Apr 2020 18:34:03 +0200 |
Signed-off-by: Markus Armbruster <address@hidden>
---
qom/object.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/qom/object.c b/qom/object.c
index 1812f79224..e06c78f9a5 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -571,18 +571,18 @@ void object_initialize_childv(Object *parentobj, const
char *propname,
}
}
+out:
/*
- * Since object_property_add_child added a reference to the child object,
- * we can drop the reference added by object_initialize(), so the child
- * property will own the only reference to the object.
+ * We want @obj's reference to be 1 on success, 0 on failure.
+ * On success, it's 2: one taken by object_initialize(), and one
+ * by object_property_add_child().
+ * On failure in object_initialize() or earlier, it's 1.
+ * On failure afterwards, it's also 1: object_unparent() releases
+ * the reference taken by object_property_add_child().
*/
object_unref(obj);
-out:
- if (local_err) {
- error_propagate(errp, local_err);
- object_unref(obj);
- }
+ error_propagate(errp, local_err);
}
static inline bool object_property_is_child(ObjectProperty *prop)
--
2.21.1
- [PATCH 00/17] qom: Spring cleaning, Markus Armbruster, 2020/04/28
- [PATCH 01/17] qom: Clearer reference counting in object_initialize_childv(),
Markus Armbruster <=
- [PATCH 04/17] qom: Change object_property_get_uint16List() to match its doc, Markus Armbruster, 2020/04/28
- [PATCH 03/17] qom: Drop object_property_del_child()'s unused parameter @errp, Markus Armbruster, 2020/04/28
- [PATCH 02/17] qom: Clean up inconsistent use of gchar * vs. char *, Markus Armbruster, 2020/04/28
- [PATCH 07/17] tests/check-qom-proplist: Improve iterator coverage, Markus Armbruster, 2020/04/28
- [PATCH 06/17] qom: Drop object_property_set_description() parameter @errp, Markus Armbruster, 2020/04/28