hmp: Ignore Error objects where the return value suffices
qdev_print_props() receives and throws away Error objects just to check for object_property_get_str() and object_property_print() failure. Unnecessary, both return suitable values, so use those instead. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20200707160613.848843-46-armbru@redhat.com>
This commit is contained in:
parent
2d226cf6d1
commit
a43770df5d
@ -697,22 +697,22 @@ static void qdev_print_props(Monitor *mon, DeviceState *dev, Property *props,
|
|||||||
if (!props)
|
if (!props)
|
||||||
return;
|
return;
|
||||||
for (; props->name; props++) {
|
for (; props->name; props++) {
|
||||||
Error *err = NULL;
|
|
||||||
char *value;
|
char *value;
|
||||||
char *legacy_name = g_strdup_printf("legacy-%s", props->name);
|
char *legacy_name = g_strdup_printf("legacy-%s", props->name);
|
||||||
|
|
||||||
if (object_property_get_type(OBJECT(dev), legacy_name, NULL)) {
|
if (object_property_get_type(OBJECT(dev), legacy_name, NULL)) {
|
||||||
value = object_property_get_str(OBJECT(dev), legacy_name, &err);
|
value = object_property_get_str(OBJECT(dev), legacy_name, NULL);
|
||||||
} else {
|
} else {
|
||||||
value = object_property_print(OBJECT(dev), props->name, true, &err);
|
value = object_property_print(OBJECT(dev), props->name, true,
|
||||||
|
NULL);
|
||||||
}
|
}
|
||||||
g_free(legacy_name);
|
g_free(legacy_name);
|
||||||
|
|
||||||
if (err) {
|
if (!value) {
|
||||||
error_free(err);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
qdev_printf("%s = %s\n", props->name,
|
qdev_printf("%s = %s\n", props->name,
|
||||||
value && *value ? value : "<null>");
|
*value ? value : "<null>");
|
||||||
g_free(value);
|
g_free(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user