diff options
author | Markus Armbruster | 2020-07-07 18:05:56 +0200 |
---|---|---|
committer | Markus Armbruster | 2020-07-10 15:18:08 +0200 |
commit | 778a2dc59213d789f5bf8409547b529af4eb9ead (patch) | |
tree | 5fa10bb05617c2d20de9d7daf5376a85914e3967 /hw/s390x | |
parent | qom: Make functions taking Error ** return bool, not void (diff) | |
download | qemu-778a2dc59213d789f5bf8409547b529af4eb9ead.tar.gz qemu-778a2dc59213d789f5bf8409547b529af4eb9ead.tar.xz qemu-778a2dc59213d789f5bf8409547b529af4eb9ead.zip |
qom: Use returned bool to check for failure, Coccinelle part
The previous commit enables conversion of
foo(..., &err);
if (err) {
...
}
to
if (!foo(..., errp)) {
...
}
for QOM functions that now return true / false on success / error.
Coccinelle script:
@@
identifier fun = {
object_apply_global_props, object_initialize_child_with_props,
object_initialize_child_with_propsv, object_property_get,
object_property_get_bool, object_property_parse, object_property_set,
object_property_set_bool, object_property_set_int,
object_property_set_link, object_property_set_qobject,
object_property_set_str, object_property_set_uint, object_set_props,
object_set_propv, user_creatable_add_dict,
user_creatable_complete, user_creatable_del
};
expression list args, args2;
typedef Error;
Error *err;
@@
- fun(args, &err, args2);
- if (err)
+ if (!fun(args, &err, args2))
{
...
}
Fails to convert hw/arm/armsse.c, because Coccinelle gets confused by
ARMSSE being used both as typedef and function-like macro there.
Convert manually.
Line breaks tidied up manually.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20200707160613.848843-29-armbru@redhat.com>
Diffstat (limited to 'hw/s390x')
-rw-r--r-- | hw/s390x/s390-pci-bus.c | 3 | ||||
-rw-r--r-- | hw/s390x/s390-virtio-ccw.c | 3 |
2 files changed, 2 insertions, 4 deletions
diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index a7b2a15a96..24de4edfc6 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -824,8 +824,7 @@ static S390PCIBusDevice *s390_pci_device_new(S390pciState *s, return NULL; } - object_property_set_str(OBJECT(dev), "target", target, &local_err); - if (local_err) { + if (!object_property_set_str(OBJECT(dev), "target", target, &local_err)) { object_unparent(OBJECT(dev)); error_propagate_prepend(errp, local_err, "zPCI device could not be created: "); diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 07609a9a58..1a171f0c96 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -70,8 +70,7 @@ static S390CPU *s390x_new_cpu(const char *typename, uint32_t core_id, S390CPU *cpu = S390_CPU(object_new(typename)); Error *err = NULL; - object_property_set_int(OBJECT(cpu), "core-id", core_id, &err); - if (err != NULL) { + if (!object_property_set_int(OBJECT(cpu), "core-id", core_id, &err)) { goto out; } qdev_realize(DEVICE(cpu), NULL, &err); |