qdev-props: convert global_props to GPtrArray

A step towards being able to call a common function,
object_apply_global_props().

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Acked-by: Eduardo Habkost <ehabkost@redhat.com>
This commit is contained in:
Marc-André Lureau 2018-11-07 13:11:25 +04:00
parent 55df8e1a2f
commit e12ca3ce1c

View file

@ -1173,22 +1173,32 @@ void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value)
*ptr = value; *ptr = value;
} }
static GList *global_props; static GPtrArray *global_props(void)
{
static GPtrArray *gp;
if (!gp) {
gp = g_ptr_array_new();
}
return gp;
}
void qdev_prop_register_global(GlobalProperty *prop) void qdev_prop_register_global(GlobalProperty *prop)
{ {
global_props = g_list_append(global_props, prop); g_ptr_array_add(global_props(), prop);
} }
int qdev_prop_check_globals(void) int qdev_prop_check_globals(void)
{ {
GList *l; int i, ret = 0;
int ret = 0;
for (l = global_props; l; l = l->next) { for (i = 0; i < global_props()->len; i++) {
GlobalProperty *prop = l->data; GlobalProperty *prop;
ObjectClass *oc; ObjectClass *oc;
DeviceClass *dc; DeviceClass *dc;
prop = g_ptr_array_index(global_props(), i);
if (prop->used) { if (prop->used) {
continue; continue;
} }
@ -1213,12 +1223,13 @@ int qdev_prop_check_globals(void)
void qdev_prop_set_globals(DeviceState *dev) void qdev_prop_set_globals(DeviceState *dev)
{ {
GList *l; int i;
for (l = global_props; l; l = l->next) { for (i = 0; i < global_props()->len; i++) {
GlobalProperty *prop = l->data; GlobalProperty *prop;
Error *err = NULL; Error *err = NULL;
prop = g_ptr_array_index(global_props(), i);
if (object_dynamic_cast(OBJECT(dev), prop->driver) == NULL) { if (object_dynamic_cast(OBJECT(dev), prop->driver) == NULL) {
continue; continue;
} }