From: Daniel P. Berrangé Date: Mon, 31 Aug 2020 21:07:23 +0000 (-0400) Subject: qom: make object_ref/unref use a void * instead of Object *. X-Git-Tag: upstream/4.2.1~79 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=654d7a20eba9285428234959d0bb05a41cc024f6;p=tools%2Fqemu-arm-static.git qom: make object_ref/unref use a void * instead of Object *. Git-commit: c5a61e5a3c68144a421117916aef04f2c0fab84b References: bsc#1184574 The object_ref/unref methods are intended for use with any subclass of the base Object. Using "Object *" in the signature is not adding any meaningful level of type safety, since callers simply use "OBJECT(ptr)" and this expands to an unchecked cast "(Object *)". By using "void *" we enable the object_unref() method to be used to provide support for g_autoptr() with any subclass. Signed-off-by: Daniel P. Berrangé Message-Id: <20200723181410.3145233-2-berrange@redhat.com> Message-Id: <20200831210740.126168-2-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost Signed-off-by: Lin Ma --- diff --git a/include/qom/object.h b/include/qom/object.h index 128d00c77..d1e4c2e11 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -974,7 +974,7 @@ GSList *object_class_get_list_sorted(const char *implements_type, * Increase the reference count of a object. A object cannot be freed as long * as its reference count is greater than zero. */ -void object_ref(Object *obj); +void object_ref(void *obj); /** * object_unref: @@ -983,7 +983,7 @@ void object_ref(Object *obj); * Decrease the reference count of a object. A object cannot be freed as long * as its reference count is greater than zero. */ -void object_unref(Object *obj); +void object_unref(void *obj); /** * object_property_add: diff --git a/qom/object.c b/qom/object.c index d51b57fba..6bff8782d 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1054,16 +1054,18 @@ GSList *object_class_get_list_sorted(const char *implements_type, object_class_cmp); } -void object_ref(Object *obj) +void object_ref(void *objptr) { + Object *obj = OBJECT(objptr); if (!obj) { return; } atomic_inc(&obj->ref); } -void object_unref(Object *obj) +void object_unref(void *objptr) { + Object *obj = OBJECT(objptr); if (!obj) { return; }