All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	"Daniel P. Berrange" <berrange@redhat.com>
Subject: [PATCH 25/41] qom: make object_ref/unref use a void * instead of Object *.
Date: Thu, 13 Aug 2020 18:26:09 -0400	[thread overview]
Message-ID: <20200813222625.243136-26-ehabkost@redhat.com> (raw)
In-Reply-To: <20200813222625.243136-1-ehabkost@redhat.com>

From: Daniel P. Berrangé <berrange@redhat.com>

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>
Message-Id: <20200723181410.3145233-2-berrange@redhat.com>
---
 include/qom/object.h | 4 ++--
 qom/object.c         | 6 ++++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/include/qom/object.h b/include/qom/object.h
index 0f3a60617c..1f8aa2d48e 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -1035,7 +1035,7 @@ GSList *object_class_get_list_sorted(const char *implements_type,
  * as its reference count is greater than zero.
  * Returns: @obj
  */
-Object *object_ref(Object *obj);
+Object *object_ref(void *obj);
 
 /**
  * object_unref:
@@ -1044,7 +1044,7 @@ Object *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_try_add:
diff --git a/qom/object.c b/qom/object.c
index 00fdf89b3b..b1822a2ef4 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -1124,8 +1124,9 @@ GSList *object_class_get_list_sorted(const char *implements_type,
                         object_class_cmp);
 }
 
-Object *object_ref(Object *obj)
+Object *object_ref(void *objptr)
 {
+    Object *obj = OBJECT(objptr);
     if (!obj) {
         return NULL;
     }
@@ -1133,8 +1134,9 @@ Object *object_ref(Object *obj)
     return obj;
 }
 
-void object_unref(Object *obj)
+void object_unref(void *objptr)
 {
+    Object *obj = OBJECT(objptr);
     if (!obj) {
         return;
     }
-- 
2.26.2



  parent reply	other threads:[~2020-08-13 22:41 UTC|newest]

Thread overview: 103+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-13 22:25 [PATCH 00/41] qom: Automated conversion of type checking boilerplate Eduardo Habkost
2020-08-13 22:25 ` [PATCH 01/41] pl1110: Rename PL1110 enum Eduardo Habkost
2020-08-14 17:45   ` Philippe Mathieu-Daudé
2020-08-18 21:30     ` Eduardo Habkost
2020-08-19  2:45       ` Philippe Mathieu-Daudé
2020-08-13 22:25 ` [PATCH 02/41] e1000: Rename QOM class cast macros Eduardo Habkost
2020-08-17 15:49   ` Daniel P. Berrangé
2020-08-13 22:25 ` [PATCH 03/41] megasas: " Eduardo Habkost
2020-08-17 15:53   ` Daniel P. Berrangé
2020-08-13 22:25 ` [PATCH 04/41] vmw_pvscsi: " Eduardo Habkost
2020-08-17 15:54   ` Daniel P. Berrangé
2020-08-13 22:25 ` [PATCH 05/41] aspeed_timer: Fix ASPEED_TIMER macro definition Eduardo Habkost
2020-08-14 17:47   ` Philippe Mathieu-Daudé
2020-08-17 15:54   ` Daniel P. Berrangé
2020-08-13 22:25 ` [PATCH 06/41] allwinner-h3: Rename memmap enum constants Eduardo Habkost
2020-08-14 17:54   ` Philippe Mathieu-Daudé
2020-08-17 19:07     ` Niek Linnenbank
2020-08-18 21:43       ` Eduardo Habkost
2020-08-13 22:25 ` [PATCH 07/41] aspeed_soc: Rename memmap/irqmap " Eduardo Habkost
2020-08-13 22:25 ` [PATCH 08/41] opentitan: Rename memmap " Eduardo Habkost
2020-08-14 15:06   ` Alistair Francis
2020-08-14 17:56   ` Philippe Mathieu-Daudé
2020-08-17  9:52     ` Bin Meng
2020-08-21 18:53       ` Alistair Francis
2020-08-25 12:38         ` Bin Meng
2020-08-13 22:25 ` [PATCH 09/41] sifive_e: " Eduardo Habkost
2020-08-14 15:07   ` Alistair Francis
2020-08-13 22:25 ` [PATCH 10/41] sifive_u: " Eduardo Habkost
2020-08-14 15:09   ` Alistair Francis
2020-08-13 22:25 ` [PATCH 11/41] versatile: Fix typo in PCI_VPB_HOST definition Eduardo Habkost
2020-08-14 17:59   ` Philippe Mathieu-Daudé
2020-08-17 15:56   ` Daniel P. Berrangé
2020-08-13 22:25 ` [PATCH 12/41] virtio-ccw: Fix definition of VIRTIO_CCW_BUS_GET_CLASS Eduardo Habkost
2020-08-17  7:25   ` Cornelia Huck
2020-08-17 15:57   ` Daniel P. Berrangé
2020-08-13 22:25 ` [PATCH 13/41] hvf: Add missing include Eduardo Habkost
2020-08-17 15:58   ` Daniel P. Berrangé
2020-08-18  7:12   ` Philippe Mathieu-Daudé
2020-08-18 10:29   ` Roman Bolshakov
2020-08-13 22:25 ` [PATCH 14/41] hcd-dwc2: Rename USB_*CLASS macros for consistency Eduardo Habkost
2020-08-14 18:00   ` Philippe Mathieu-Daudé
2020-08-17 15:58   ` Daniel P. Berrangé
2020-08-13 22:25 ` [PATCH 15/41] tulip: Move TulipState typedef to header Eduardo Habkost
2020-08-14 18:01   ` Philippe Mathieu-Daudé
2020-08-17 15:59   ` Daniel P. Berrangé
2020-08-13 22:26 ` [PATCH 16/41] throttle-groups: Move ThrottleGroup " Eduardo Habkost
2020-08-14 18:01   ` Philippe Mathieu-Daudé
2020-08-17 15:59   ` Daniel P. Berrangé
2020-08-13 22:26 ` [PATCH 17/41] pci: Move PCIBusClass typedef to pci.h Eduardo Habkost
2020-08-17 16:00   ` Daniel P. Berrangé
2020-08-13 22:26 ` [PATCH 18/41] i8254: Move PITCommonState/PITCommonClass typedefs to i8254.h Eduardo Habkost
2020-08-14 18:02   ` Philippe Mathieu-Daudé
2020-08-17 16:00   ` Daniel P. Berrangé
2020-08-13 22:26 ` [PATCH 19/41] hvf: Move HVFState typedef to hvf.h Eduardo Habkost
2020-08-17 16:01   ` Daniel P. Berrangé
2020-08-13 22:26 ` [PATCH 20/41] mcf_fec: Move mcf_fec_state typedef to header Eduardo Habkost
2020-08-17 16:02   ` Daniel P. Berrangé
2020-08-13 22:26 ` [PATCH 21/41] s390_flic: Move KVMS390FLICState " Eduardo Habkost
2020-08-17  7:26   ` Cornelia Huck
2020-08-17 16:02   ` Daniel P. Berrangé
2020-08-13 22:26 ` [PATCH 22/41] can_emu: Delete macros for non-existing typedef Eduardo Habkost
2020-08-14 18:03   ` Philippe Mathieu-Daudé
2020-08-17 16:02   ` Daniel P. Berrangé
2020-08-13 22:26 ` [PATCH 23/41] nubus: Delete unused NUBUS_BRIDGE macro Eduardo Habkost
2020-08-14 18:03   ` Philippe Mathieu-Daudé
2020-08-17 16:03   ` Daniel P. Berrangé
2020-08-13 22:26 ` [PATCH 24/41] platform-bus: Delete macros for non-existing typedef Eduardo Habkost
2020-08-17 16:03   ` Daniel P. Berrangé
2020-08-13 22:26 ` Eduardo Habkost [this message]
2020-08-13 22:26 ` [PATCH 26/41] qom: provide convenient macros for declaring and defining types Eduardo Habkost
2020-08-13 22:26 ` [PATCH 27/41] qom: Fix G_DEFINE_AUTOPTR_CLEANUP_FUNC Eduardo Habkost
2020-08-17 16:04   ` Daniel P. Berrangé
2020-08-13 22:26 ` [PATCH 28/41] qom: Allow class type name to be specified in OBJECT_DECLARE* Eduardo Habkost
2020-08-17 16:06   ` Daniel P. Berrangé
2020-08-13 22:26 ` [PATCH 29/41] qom: DECLARE_*_CHECKERS macros Eduardo Habkost
2020-08-17 16:06   ` Daniel P. Berrangé
2020-08-13 22:26 ` [PATCH 30/41] qom: Make type checker functions accept const pointers Eduardo Habkost
2020-08-14 18:05   ` Philippe Mathieu-Daudé
2020-08-17 16:08   ` Daniel P. Berrangé
2020-08-18 20:56     ` Eduardo Habkost
2020-08-13 22:26 ` [PATCH 31/41] qom: TYPE_INFO macro Eduardo Habkost
2020-08-17 16:09   ` Daniel P. Berrangé
2020-08-13 22:26 ` [PATCH 32/41] codeconverter: script for automating QOM code cleanups Eduardo Habkost
2020-08-13 22:26 ` [PATCH 33/41] [automated] Delete duplicate QOM typedefs Eduardo Habkost
2020-08-17 16:11   ` Daniel P. Berrangé
2020-08-13 22:26 ` [PATCH 34/41] [automated] Use TYPE_INFO macro Eduardo Habkost
2020-08-17 16:14   ` Daniel P. Berrangé
2020-08-13 22:26 ` [PATCH 35/41] [automated] Move QOM typedefs and add missing includes Eduardo Habkost
2020-08-17 16:16   ` Daniel P. Berrangé
2020-08-13 22:26 ` [PATCH 36/41] [automated] Use DECLARE_*CHECKER* macros Eduardo Habkost
2020-08-17 16:17   ` Daniel P. Berrangé
2020-08-13 22:26 ` [PATCH 37/41] [automated] Use DECLARE_*CHECKER* when possible (--force mode) Eduardo Habkost
2020-08-17 16:29   ` Daniel P. Berrangé
2020-08-17 17:14     ` Eduardo Habkost
2020-08-13 22:26 ` [PATCH 38/41] [automated] Use OBJECT_DECLARE_TYPE where possible Eduardo Habkost
2020-08-13 22:26 ` [PATCH 39/41] [automated] Use OBJECT_DECLARE_SIMPLE_TYPE when possible Eduardo Habkost
2020-08-13 22:26 ` [PATCH 40/41] crypto: use QOM macros for declaration/definition of secret types Eduardo Habkost
2020-08-13 22:26 ` [PATCH 41/41] crypto: use QOM macros for declaration/definition of TLS creds types Eduardo Habkost
2020-08-13 23:01 ` [PATCH 00/41] qom: Automated conversion of type checking boilerplate no-reply
2020-08-13 23:03 ` no-reply
2020-08-13 23:07 ` no-reply
2020-08-18  9:59 ` Roman Bolshakov
2020-08-18 13:19   ` Eduardo Habkost

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=20200813222625.243136-26-ehabkost@redhat.com \
    --to=ehabkost@redhat.com \
    --cc=berrange@redhat.com \
    --cc=pbonzini@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.