[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 01/40] qdev: Don't always force the global property array non
From: |
Richard Henderson |
Subject: |
[RFC PATCH 01/40] qdev: Don't always force the global property array non-null |
Date: |
Tue, 3 Jan 2023 10:16:07 -0800 |
Only qdev_prop_register_global requires a non-null array.
The other instances can simply exit early.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
hw/core/qdev-properties.c | 43 ++++++++++++++++++++++++---------------
1 file changed, 27 insertions(+), 16 deletions(-)
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 357b8761b5..f7775d0ea4 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -739,29 +739,31 @@ void qdev_prop_set_enum(DeviceState *dev, const char
*name, int value)
&error_abort);
}
-static GPtrArray *global_props(void)
-{
- static GPtrArray *gp;
-
- if (!gp) {
- gp = g_ptr_array_new();
- }
-
- return gp;
-}
+static GPtrArray *global_properties;
void qdev_prop_register_global(GlobalProperty *prop)
{
- g_ptr_array_add(global_props(), prop);
+ GPtrArray *props = global_properties;
+
+ if (!props) {
+ props = g_ptr_array_new();
+ global_properties = props;
+ }
+
+ g_ptr_array_add(props, prop);
}
const GlobalProperty *qdev_find_global_prop(Object *obj,
const char *name)
{
- GPtrArray *props = global_props();
+ GPtrArray *props = global_properties;
const GlobalProperty *p;
int i;
+ if (!props) {
+ return NULL;
+ }
+
for (i = 0; i < props->len; i++) {
p = g_ptr_array_index(props, i);
if (object_dynamic_cast(obj, p->driver)
@@ -774,14 +776,19 @@ const GlobalProperty *qdev_find_global_prop(Object *obj,
int qdev_prop_check_globals(void)
{
+ GPtrArray *props = global_properties;
int i, ret = 0;
- for (i = 0; i < global_props()->len; i++) {
+ if (!props) {
+ return 0;
+ }
+
+ for (i = 0; i < props->len; i++) {
GlobalProperty *prop;
ObjectClass *oc;
DeviceClass *dc;
- prop = g_ptr_array_index(global_props(), i);
+ prop = g_ptr_array_index(props, i);
if (prop->used) {
continue;
}
@@ -806,8 +813,12 @@ int qdev_prop_check_globals(void)
void qdev_prop_set_globals(DeviceState *dev)
{
- object_apply_global_props(OBJECT(dev), global_props(),
- dev->hotplugged ? NULL : &error_fatal);
+ GPtrArray *props = global_properties;
+
+ if (props) {
+ object_apply_global_props(OBJECT(dev), props,
+ dev->hotplugged ? NULL : &error_fatal);
+ }
}
/* --- 64bit unsigned int 'size' type --- */
--
2.34.1
- [RFC PATCH 03/40] qom: Create class properties, (continued)
- [RFC PATCH 03/40] qom: Create class properties, Richard Henderson, 2023/01/03
- [RFC PATCH 04/40] target/arm: Remove aarch64_cpu_finalizefn, Richard Henderson, 2023/01/03
- [RFC PATCH 06/40] target/arm: Remove AArch64CPUClass, Richard Henderson, 2023/01/03
- [RFC PATCH 12/40] target/arm: Copy isar and friends from ARMCPUClass, Richard Henderson, 2023/01/03
- [RFC PATCH 11/40] target/arm: Copy features from ARMCPUClass, Richard Henderson, 2023/01/03
- [RFC PATCH 01/40] qdev: Don't always force the global property array non-null,
Richard Henderson <=
- [RFC PATCH 09/40] target/arm: Utilize arm-cpu instance_post_init hook, Richard Henderson, 2023/01/03
- [RFC PATCH 16/40] target/arm: Represent the entire MPIDR_EL1, Richard Henderson, 2023/01/03
[RFC PATCH 18/40] target/arm: Create cpreg definition functions with GHashTable arg, Richard Henderson, 2023/01/03
[RFC PATCH 05/40] target/arm: Create arm_cpu_register_parent, Richard Henderson, 2023/01/03