[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 34/49] qom/object: Remove type_register()
From: |
Paolo Bonzini |
Subject: |
[PULL 34/49] qom/object: Remove type_register() |
Date: |
Wed, 11 Dec 2024 17:27:04 +0100 |
From: Zhao Liu <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 removed.
Since the changes required to remove type_register() were smaller,
type_register() was replaced with type_register_static() throughout the
code base. Drop its definition, and delete the requirement about string
lifetime from the documentation.
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Link: https://lore.kernel.org/r/20241029085934.2799066-17-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 43c135984a6..a201c9712a1 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 9edc06d391f..c7660f9a097 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.47.1
- [PULL 23/49] hw/rtc: Replace type_register() with type_register_static(), (continued)
- [PULL 23/49] hw/rtc: Replace type_register() with type_register_static(), Paolo Bonzini, 2024/12/11
- [PULL 26/49] hw/usb: Replace type_register() with type_register_static(), Paolo Bonzini, 2024/12/11
- [PULL 25/49] hw/sensor: Replace type_register() with type_register_static(), Paolo Bonzini, 2024/12/11
- [PULL 28/49] i386: Replace type_register() with type_register_static(), Paolo Bonzini, 2024/12/11
- [PULL 27/49] hw/virtio: Replace type_register() with type_register_static(), Paolo Bonzini, 2024/12/11
- [PULL 29/49] target/mips: Replace type_register() with type_register_static(), Paolo Bonzini, 2024/12/11
- [PULL 30/49] target/sparc: Replace type_register() with type_register_static(), Paolo Bonzini, 2024/12/11
- [PULL 31/49] target/xtensa: Replace type_register() with type_register_static(), Paolo Bonzini, 2024/12/11
- [PULL 32/49] ui: Replace type_register() with type_register_static(), Paolo Bonzini, 2024/12/11
- [PULL 33/49] script/codeconverter/qom_type_info: Deprecate MakeTypeRegisterStatic and MakeTypeRegisterNotStatic, Paolo Bonzini, 2024/12/11
- [PULL 34/49] qom/object: Remove type_register(),
Paolo Bonzini <=
- [PULL 35/49] bql: check that the BQL is not dropped within marked sections, Paolo Bonzini, 2024/12/11
- [PULL 36/49] rust: cell: add BQL-enforcing Cell variant, Paolo Bonzini, 2024/12/11
- [PULL 38/49] rust: define prelude, Paolo Bonzini, 2024/12/11
- [PULL 37/49] rust: cell: add BQL-enforcing RefCell variant, Paolo Bonzini, 2024/12/11
- [PULL 39/49] rust: add bindings for interrupt sources, Paolo Bonzini, 2024/12/11
- [PULL 40/49] rust: add a bit operation module, Paolo Bonzini, 2024/12/11
- [PULL 41/49] rust: qom: add default definitions for ObjectImpl, Paolo Bonzini, 2024/12/11
- [PULL 42/49] rust: qom: rename Class trait to ClassInitImpl, Paolo Bonzini, 2024/12/11
- [PULL 43/49] rust: qom: convert type_info! macro to an associated const, Paolo Bonzini, 2024/12/11