mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 08:13:54 -06:00
qom: make user_creatable_complete() specific to UserCreatable
Instead of accepting any Object*, change user_creatable_complete() to require a UserCreatable*. Modify the callers to pass the appropriate argument, removing redundant dynamic cast checks in object creation. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Message-Id: <20181204142023.15982-4-marcandre.lureau@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
This commit is contained in:
parent
aa1b35b975
commit
3650b2de34
5 changed files with 15 additions and 19 deletions
12
qom/object.c
12
qom/object.c
|
@ -417,6 +417,7 @@ void object_initialize_childv(Object *parentobj, const char *propname,
|
|||
{
|
||||
Error *local_err = NULL;
|
||||
Object *obj;
|
||||
UserCreatable *uc;
|
||||
|
||||
object_initialize(childobj, size, type);
|
||||
obj = OBJECT(childobj);
|
||||
|
@ -431,8 +432,9 @@ void object_initialize_childv(Object *parentobj, const char *propname,
|
|||
goto out;
|
||||
}
|
||||
|
||||
if (object_dynamic_cast(obj, TYPE_USER_CREATABLE)) {
|
||||
user_creatable_complete(obj, &local_err);
|
||||
uc = (UserCreatable *)object_dynamic_cast(obj, TYPE_USER_CREATABLE);
|
||||
if (uc) {
|
||||
user_creatable_complete(uc, &local_err);
|
||||
if (local_err) {
|
||||
object_unparent(obj);
|
||||
goto out;
|
||||
|
@ -590,6 +592,7 @@ Object *object_new_with_propv(const char *typename,
|
|||
Object *obj;
|
||||
ObjectClass *klass;
|
||||
Error *local_err = NULL;
|
||||
UserCreatable *uc;
|
||||
|
||||
klass = object_class_by_name(typename);
|
||||
if (!klass) {
|
||||
|
@ -612,8 +615,9 @@ Object *object_new_with_propv(const char *typename,
|
|||
goto error;
|
||||
}
|
||||
|
||||
if (object_dynamic_cast(obj, TYPE_USER_CREATABLE)) {
|
||||
user_creatable_complete(obj, &local_err);
|
||||
uc = (UserCreatable *)object_dynamic_cast(obj, TYPE_USER_CREATABLE);
|
||||
if (uc) {
|
||||
user_creatable_complete(uc, &local_err);
|
||||
if (local_err) {
|
||||
object_unparent(obj);
|
||||
goto error;
|
||||
|
|
|
@ -8,18 +8,10 @@
|
|||
#include "qapi/opts-visitor.h"
|
||||
#include "qemu/config-file.h"
|
||||
|
||||
void user_creatable_complete(Object *obj, Error **errp)
|
||||
void user_creatable_complete(UserCreatable *uc, Error **errp)
|
||||
{
|
||||
UserCreatableClass *ucc = USER_CREATABLE_GET_CLASS(uc);
|
||||
|
||||
UserCreatableClass *ucc;
|
||||
UserCreatable *uc =
|
||||
(UserCreatable *)object_dynamic_cast(obj, TYPE_USER_CREATABLE);
|
||||
|
||||
if (!uc) {
|
||||
return;
|
||||
}
|
||||
|
||||
ucc = USER_CREATABLE_GET_CLASS(uc);
|
||||
if (ucc->complete) {
|
||||
ucc->complete(uc, errp);
|
||||
}
|
||||
|
@ -89,7 +81,7 @@ Object *user_creatable_add_type(const char *type, const char *id,
|
|||
goto out;
|
||||
}
|
||||
|
||||
user_creatable_complete(obj, &local_err);
|
||||
user_creatable_complete(USER_CREATABLE(obj), &local_err);
|
||||
if (local_err) {
|
||||
object_property_del(object_get_objects_root(),
|
||||
id, &error_abort);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue