diff options
author | Markus Armbruster <armbru@redhat.com> | 2020-07-07 18:05:32 +0200 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2020-07-10 15:01:06 +0200 |
commit | 118bfd76c9c604588cb3f97811710576f58e5a76 (patch) | |
tree | 0b3c83772d214c827e2aa87581e2b9126052d612 /hw/intc | |
parent | e3fe3988d7851cac30abffae06d2f555ff7bee62 (diff) |
qdev: Use returned bool to check for qdev_realize() etc. failure
Convert
foo(..., &err);
if (err) {
...
}
to
if (!foo(..., &err)) {
...
}
for qdev_realize(), qdev_realize_and_unref(), qbus_realize() and their
wrappers isa_realize_and_unref(), pci_realize_and_unref(),
sysbus_realize(), sysbus_realize_and_unref(), usb_realize_and_unref().
Coccinelle script:
@@
identifier fun = {
isa_realize_and_unref, pci_realize_and_unref, qbus_realize,
qdev_realize, qdev_realize_and_unref, sysbus_realize,
sysbus_realize_and_unref, usb_realize_and_unref
};
expression list args, args2;
typedef Error;
Error *err;
@@
- fun(args, &err, args2);
- if (err)
+ if (!fun(args, &err, args2))
{
...
}
Chokes on hw/arm/musicpal.c's lcd_refresh() with the unhelpful error
message "no position information". Nothing to convert there; skipped.
Fails to convert hw/arm/armsse.c, because Coccinelle gets confused by
ARMSSE being used both as typedef and function-like macro there.
Converted manually.
A few 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>
Reviewed-by: Greg Kurz <groug@kaod.org>
Message-Id: <20200707160613.848843-5-armbru@redhat.com>
Diffstat (limited to 'hw/intc')
-rw-r--r-- | hw/intc/armv7m_nvic.c | 6 | ||||
-rw-r--r-- | hw/intc/pnv_xive.c | 6 | ||||
-rw-r--r-- | hw/intc/realview_gic.c | 3 | ||||
-rw-r--r-- | hw/intc/spapr_xive.c | 6 | ||||
-rw-r--r-- | hw/intc/xics.c | 3 | ||||
-rw-r--r-- | hw/intc/xive.c | 3 |
6 files changed, 9 insertions, 18 deletions
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c index af9f4c5a85..80a915e922 100644 --- a/hw/intc/armv7m_nvic.c +++ b/hw/intc/armv7m_nvic.c @@ -2640,8 +2640,7 @@ static void armv7m_nvic_realize(DeviceState *dev, Error **errp) s->num_prio_bits = arm_feature(&s->cpu->env, ARM_FEATURE_V7) ? 8 : 2; - sysbus_realize(SYS_BUS_DEVICE(&s->systick[M_REG_NS]), &err); - if (err != NULL) { + if (!sysbus_realize(SYS_BUS_DEVICE(&s->systick[M_REG_NS]), &err)) { error_propagate(errp, err); return; } @@ -2657,8 +2656,7 @@ static void armv7m_nvic_realize(DeviceState *dev, Error **errp) object_initialize_child(OBJECT(dev), "systick-reg-s", &s->systick[M_REG_S], TYPE_SYSTICK); - sysbus_realize(SYS_BUS_DEVICE(&s->systick[M_REG_S]), &err); - if (err != NULL) { + if (!sysbus_realize(SYS_BUS_DEVICE(&s->systick[M_REG_S]), &err)) { error_propagate(errp, err); return; } diff --git a/hw/intc/pnv_xive.c b/hw/intc/pnv_xive.c index 85ba0b4655..3b2e87334d 100644 --- a/hw/intc/pnv_xive.c +++ b/hw/intc/pnv_xive.c @@ -1833,8 +1833,7 @@ static void pnv_xive_realize(DeviceState *dev, Error **errp) &error_fatal); object_property_set_link(OBJECT(xsrc), OBJECT(xive), "xive", &error_abort); - qdev_realize(DEVICE(xsrc), NULL, &local_err); - if (local_err) { + if (!qdev_realize(DEVICE(xsrc), NULL, &local_err)) { error_propagate(errp, local_err); return; } @@ -1843,8 +1842,7 @@ static void pnv_xive_realize(DeviceState *dev, Error **errp) &error_fatal); object_property_set_link(OBJECT(end_xsrc), OBJECT(xive), "xive", &error_abort); - qdev_realize(DEVICE(end_xsrc), NULL, &local_err); - if (local_err) { + if (!qdev_realize(DEVICE(end_xsrc), NULL, &local_err)) { error_propagate(errp, local_err); return; } diff --git a/hw/intc/realview_gic.c b/hw/intc/realview_gic.c index f11fb5259a..aa0010e91f 100644 --- a/hw/intc/realview_gic.c +++ b/hw/intc/realview_gic.c @@ -34,8 +34,7 @@ static void realview_gic_realize(DeviceState *dev, Error **errp) int numirq = 96; qdev_prop_set_uint32(DEVICE(&s->gic), "num-irq", numirq); - sysbus_realize(SYS_BUS_DEVICE(&s->gic), &err); - if (err != NULL) { + if (!sysbus_realize(SYS_BUS_DEVICE(&s->gic), &err)) { error_propagate(errp, err); return; } diff --git a/hw/intc/spapr_xive.c b/hw/intc/spapr_xive.c index b7fc8dde7a..615abf5462 100644 --- a/hw/intc/spapr_xive.c +++ b/hw/intc/spapr_xive.c @@ -312,8 +312,7 @@ static void spapr_xive_realize(DeviceState *dev, Error **errp) &error_fatal); object_property_set_link(OBJECT(xsrc), OBJECT(xive), "xive", &error_abort); - qdev_realize(DEVICE(xsrc), NULL, &local_err); - if (local_err) { + if (!qdev_realize(DEVICE(xsrc), NULL, &local_err)) { error_propagate(errp, local_err); return; } @@ -326,8 +325,7 @@ static void spapr_xive_realize(DeviceState *dev, Error **errp) &error_fatal); object_property_set_link(OBJECT(end_xsrc), OBJECT(xive), "xive", &error_abort); - qdev_realize(DEVICE(end_xsrc), NULL, &local_err); - if (local_err) { + if (!qdev_realize(DEVICE(end_xsrc), NULL, &local_err)) { error_propagate(errp, local_err); return; } diff --git a/hw/intc/xics.c b/hw/intc/xics.c index d365eeca66..811b0346e1 100644 --- a/hw/intc/xics.c +++ b/hw/intc/xics.c @@ -384,8 +384,7 @@ Object *icp_create(Object *cpu, const char *type, XICSFabric *xi, Error **errp) object_unref(obj); object_property_set_link(obj, OBJECT(xi), ICP_PROP_XICS, &error_abort); object_property_set_link(obj, cpu, ICP_PROP_CPU, &error_abort); - qdev_realize(DEVICE(obj), NULL, &local_err); - if (local_err) { + if (!qdev_realize(DEVICE(obj), NULL, &local_err)) { object_unparent(obj); error_propagate(errp, local_err); obj = NULL; diff --git a/hw/intc/xive.c b/hw/intc/xive.c index 2c30dc53d8..8e167306e7 100644 --- a/hw/intc/xive.c +++ b/hw/intc/xive.c @@ -765,8 +765,7 @@ Object *xive_tctx_create(Object *cpu, XivePresenter *xptr, Error **errp) object_unref(obj); object_property_set_link(obj, cpu, "cpu", &error_abort); object_property_set_link(obj, OBJECT(xptr), "presenter", &error_abort); - qdev_realize(DEVICE(obj), NULL, &local_err); - if (local_err) { + if (!qdev_realize(DEVICE(obj), NULL, &local_err)) { goto error; } |