qom: Simplify object_property_get_enum()
Reuse object_property_get_str(). Switches from the string to the qobject visitor under the hood. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20200505152926.18877-5-armbru@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
f73a32a514
commit
b555f89fcb
11
qom/object.c
11
qom/object.c
@ -1521,8 +1521,6 @@ typedef struct EnumProperty {
|
||||
int object_property_get_enum(Object *obj, const char *name,
|
||||
const char *typename, Error **errp)
|
||||
{
|
||||
Error *err = NULL;
|
||||
Visitor *v;
|
||||
char *str;
|
||||
int ret;
|
||||
ObjectProperty *prop = object_property_find(obj, name, errp);
|
||||
@ -1541,15 +1539,10 @@ int object_property_get_enum(Object *obj, const char *name,
|
||||
|
||||
enumprop = prop->opaque;
|
||||
|
||||
v = string_output_visitor_new(false, &str);
|
||||
object_property_get(obj, v, name, &err);
|
||||
if (err) {
|
||||
error_propagate(errp, err);
|
||||
visit_free(v);
|
||||
str = object_property_get_str(obj, name, errp);
|
||||
if (!str) {
|
||||
return 0;
|
||||
}
|
||||
visit_complete(v, &str);
|
||||
visit_free(v);
|
||||
|
||||
ret = qapi_enum_parse(enumprop->lookup, str, -1, errp);
|
||||
g_free(str);
|
||||
|
Loading…
Reference in New Issue
Block a user