qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Zhao Liu <zhao1.liu@intel.com>
To: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Daniel P . Berrangé" <berrange@redhat.com>,
	"Eduardo Habkost" <eduardo@habkost.net>
Cc: qemu-devel@nongnu.org, Zhao Liu <zhao1.liu@intel.com>
Subject: [PATCH 16/16] qom/object: Deprecate type_register()
Date: Tue, 29 Oct 2024 16:59:34 +0800	[thread overview]
Message-ID: <20241029085934.2799066-17-zhao1.liu@intel.com> (raw)
In-Reply-To: <20241029085934.2799066-1-zhao1.liu@intel.com>

At present, type_register() and type_register_static() are identical,
although their documentation expects the *_static variant to accept
the Typeinfo with the strings that have the static lifetime.

However, the code implementation doesn't have any check or guarantee for
static lifetime. In fact, this is unnecessary because type_new()
duplicates all strings, thereby taking ownership of them.

Therefore, type_register() and type_register_static() are redundant, so
one of them should be deprecated.

Since the changes required to deprecate type_register() are smaller,
choose to deprecate type_register() and delete the requirement about
string lifetime from the documentation.

Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
---
 include/qom/object.h | 14 --------------
 qom/object.c         |  7 +------
 2 files changed, 1 insertion(+), 20 deletions(-)

diff --git a/include/qom/object.h b/include/qom/object.h
index 2af9854675c3..24c8e010c2de 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -880,24 +880,10 @@ const char *object_get_typename(const Object *obj);
  * type_register_static:
  * @info: The #TypeInfo of the new type.
  *
- * @info and all of the strings it points to should exist for the life time
- * that the type is registered.
- *
  * Returns: the new #Type.
  */
 Type type_register_static(const TypeInfo *info);
 
-/**
- * type_register:
- * @info: The #TypeInfo of the new type
- *
- * Unlike type_register_static(), this call does not require @info or its
- * string members to continue to exist after the call returns.
- *
- * Returns: the new #Type.
- */
-Type type_register(const TypeInfo *info);
-
 /**
  * type_register_static_array:
  * @infos: The array of the new type #TypeInfo structures.
diff --git a/qom/object.c b/qom/object.c
index 11424cf4711b..c08e7ab652d9 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -175,17 +175,12 @@ static TypeImpl *type_register_internal(const TypeInfo *info)
     return ti;
 }
 
-TypeImpl *type_register(const TypeInfo *info)
+TypeImpl *type_register_static(const TypeInfo *info)
 {
     assert(info->parent);
     return type_register_internal(info);
 }
 
-TypeImpl *type_register_static(const TypeInfo *info)
-{
-    return type_register(info);
-}
-
 void type_register_static_array(const TypeInfo *infos, int nr_infos)
 {
     int i;
-- 
2.34.1



  parent reply	other threads:[~2024-10-29  8:45 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-29  8:59 [PATCH 00/16] qom/object: Deprecate type_register() Zhao Liu
2024-10-29  8:59 ` [PATCH 01/16] arm: Replace type_register() with type_register_static() Zhao Liu
2024-10-29  8:59 ` [PATCH 02/16] hw/block: " Zhao Liu
2024-10-29  8:59 ` [PATCH 03/16] hw/net: " Zhao Liu
2024-10-29  8:59 ` [PATCH 04/16] ppc: " Zhao Liu
2024-10-29  8:59 ` [PATCH 05/16] hw/rtc: " Zhao Liu
2024-10-29  8:59 ` [PATCH 06/16] hw/scsi: " Zhao Liu
2024-10-29  8:59 ` [PATCH 07/16] hw/sensor: " Zhao Liu
2024-10-29  8:59 ` [PATCH 08/16] hw/usb: " Zhao Liu
2024-10-29  8:59 ` [PATCH 09/16] hw/virtio: " Zhao Liu
2024-10-29  8:59 ` [PATCH 10/16] i386: " Zhao Liu
2024-10-29  8:59 ` [PATCH 11/16] target/mips: " Zhao Liu
2024-10-29  8:59 ` [PATCH 12/16] target/sparc: " Zhao Liu
2024-10-29  8:59 ` [PATCH 13/16] target/xtensa: " Zhao Liu
2024-10-29  8:59 ` [PATCH 14/16] ui: " Zhao Liu
2024-10-29  8:59 ` [PATCH 15/16] script/codeconverter/qom_type_info: Deprecate MakeTypeRegisterStatic and MakeTypeRegisterNotStatic Zhao Liu
2024-10-29  8:59 ` Zhao Liu [this message]
2024-12-10 16:20 ` [PATCH 00/16] qom/object: Deprecate type_register() Zhao Liu
2024-12-10 17:43 ` Paolo Bonzini

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=20241029085934.2799066-17-zhao1.liu@intel.com \
    --to=zhao1.liu@intel.com \
    --cc=berrange@redhat.com \
    --cc=eduardo@habkost.net \
    --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 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).