mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 09:43:56 -06:00
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>
This commit is contained in:
parent
e3fe3988d7
commit
118bfd76c9
65 changed files with 248 additions and 495 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue