qom: Fix invalid error check in property_get_str()
commita479b21c111a87a50203a7413c4e5ec419fc88dd
authorMarkus Armbruster <armbru@redhat.com>
Tue, 25 Aug 2015 18:00:46 +0000 (25 20:00 +0200)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Wed, 21 Oct 2015 03:57:42 +0000 (20 22:57 -0500)
tree1ff44768388ae28045929e592ea9baf5b6e7d936
parentd11ff15fd5236bdb82b2def0ecc568290bfdba35
qom: Fix invalid error check in property_get_str()

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>
(cherry picked from commit e1c8237df5395f6a453f18109bd9dd33fb2a397c)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
qom/object.c