|
From: | Eric Blake |
Subject: | Re: [PATCH 1/4] qom: make object_ref/unref use a void * instead of Object *. |
Date: | Thu, 23 Jul 2020 14:04:45 -0500 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 |
On 7/23/20 1:14 PM, Daniel P. Berrangé wrote:
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é <berrange@redhat.com> --- include/qom/object.h | 4 ++-- qom/object.c | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-)
Is it worth a followup patch (probably with Coccinelle) that changes: object_ref(OBJECT(dev)); to the now-simpler object_ref(dev); But I don't think it belongs in this patch, so Reviewed-by: Eric Blake <eblake@redhat.com> -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
[Prev in Thread] | Current Thread | [Next in Thread] |