When a function returns a null pointer on error and only on error, you
can do
if (!foo(foos, errp)) {
... handle error ...
}
instead of the more cumbersome
Error *err = NULL;
if (!foo(foos, &err)) {
error_propagate(errp, err);
... handle error ...
}
A StringProperty's getter, however, may return null on success! We
then fail to call visit_type_str().
Screwed up in 6a146eb, v1.1.
Fails tests/qom-test in my current, heavily hacked QAPI branch. No
reproducer for master known (but I didn't look hard).
Cc: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: Andreas Färber <afaerber@suse.de>
{
StringProperty *prop = opaque;
char *value;
+ Error *err = NULL;
- value = prop->get(obj, errp);
- if (value) {
- visit_type_str(v, &value, name, errp);
- g_free(value);
+ value = prop->get(obj, &err);
+ if (err) {
+ error_propagate(errp, err);
+ return;
}
+
+ visit_type_str(v, &value, name, errp);
+ g_free(value);
}
static void property_set_str(Object *obj, Visitor *v, void *opaque,