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/ppc | |
parent | e3fe3988d7851cac30abffae06d2f555ff7bee62 (diff) | |
download | qemu-118bfd76c9c604588cb3f97811710576f58e5a76.zip qemu-118bfd76c9c604588cb3f97811710576f58e5a76.tar.gz qemu-118bfd76c9c604588cb3f97811710576f58e5a76.tar.bz2 |
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/ppc')
-rw-r--r-- | hw/ppc/e500.c | 3 | ||||
-rw-r--r-- | hw/ppc/pnv.c | 39 | ||||
-rw-r--r-- | hw/ppc/pnv_core.c | 3 | ||||
-rw-r--r-- | hw/ppc/pnv_psi.c | 6 | ||||
-rw-r--r-- | hw/ppc/spapr_cpu_core.c | 3 | ||||
-rw-r--r-- | hw/ppc/spapr_irq.c | 3 |
6 files changed, 19 insertions, 38 deletions
diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index 51bf95b..97fa970 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -771,8 +771,7 @@ static DeviceState *ppce500_init_mpic_kvm(const PPCE500MachineClass *pmc, dev = qdev_new(TYPE_KVM_OPENPIC); qdev_prop_set_uint32(dev, "model", pmc->mpic_version); - sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &err); - if (err) { + if (!sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &err)) { error_propagate(errp, err); object_unparent(OBJECT(dev)); return NULL; diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index 643098a..f2d70c3 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -1140,8 +1140,7 @@ static void pnv_chip_power8_realize(DeviceState *dev, Error **errp) "bar", &error_fatal); object_property_set_link(OBJECT(&chip8->psi), OBJECT(chip8->xics), ICS_PROP_XICS, &error_abort); - qdev_realize(DEVICE(&chip8->psi), NULL, &local_err); - if (local_err) { + if (!qdev_realize(DEVICE(&chip8->psi), NULL, &local_err)) { error_propagate(errp, local_err); return; } @@ -1171,8 +1170,7 @@ static void pnv_chip_power8_realize(DeviceState *dev, Error **errp) /* Create the simplified OCC model */ object_property_set_link(OBJECT(&chip8->occ), OBJECT(&chip8->psi), "psi", &error_abort); - qdev_realize(DEVICE(&chip8->occ), NULL, &local_err); - if (local_err) { + if (!qdev_realize(DEVICE(&chip8->occ), NULL, &local_err)) { error_propagate(errp, local_err); return; } @@ -1185,8 +1183,7 @@ static void pnv_chip_power8_realize(DeviceState *dev, Error **errp) /* HOMER */ object_property_set_link(OBJECT(&chip8->homer), OBJECT(chip), "chip", &error_abort); - qdev_realize(DEVICE(&chip8->homer), NULL, &local_err); - if (local_err) { + if (!qdev_realize(DEVICE(&chip8->homer), NULL, &local_err)) { error_propagate(errp, local_err); return; } @@ -1205,8 +1202,7 @@ static void pnv_chip_power8_realize(DeviceState *dev, Error **errp) object_property_set_int(OBJECT(phb), i, "index", &error_fatal); object_property_set_int(OBJECT(phb), chip->chip_id, "chip-id", &error_fatal); - sysbus_realize(SYS_BUS_DEVICE(phb), &local_err); - if (local_err) { + if (!sysbus_realize(SYS_BUS_DEVICE(phb), &local_err)) { error_propagate(errp, local_err); return; } @@ -1384,8 +1380,7 @@ static void pnv_chip_power9_phb_realize(PnvChip *chip, Error **errp) &error_fatal); object_property_set_link(OBJECT(pec), OBJECT(get_system_memory()), "system-memory", &error_abort); - qdev_realize(DEVICE(pec), NULL, &local_err); - if (local_err) { + if (!qdev_realize(DEVICE(pec), NULL, &local_err)) { error_propagate(errp, local_err); return; } @@ -1409,8 +1404,7 @@ static void pnv_chip_power9_phb_realize(PnvChip *chip, Error **errp) object_property_set_int(obj, PNV_PHB4_DEVICE_ID, "device-id", &error_fatal); object_property_set_link(obj, OBJECT(stack), "stack", &error_abort); - sysbus_realize(SYS_BUS_DEVICE(obj), &local_err); - if (local_err) { + if (!sysbus_realize(SYS_BUS_DEVICE(obj), &local_err)) { error_propagate(errp, local_err); return; } @@ -1469,8 +1463,7 @@ static void pnv_chip_power9_realize(DeviceState *dev, Error **errp) "tm-bar", &error_fatal); object_property_set_link(OBJECT(&chip9->xive), OBJECT(chip), "chip", &error_abort); - sysbus_realize(SYS_BUS_DEVICE(&chip9->xive), &local_err); - if (local_err) { + if (!sysbus_realize(SYS_BUS_DEVICE(&chip9->xive), &local_err)) { error_propagate(errp, local_err); return; } @@ -1480,8 +1473,7 @@ static void pnv_chip_power9_realize(DeviceState *dev, Error **errp) /* Processor Service Interface (PSI) Host Bridge */ object_property_set_int(OBJECT(&chip9->psi), PNV9_PSIHB_BASE(chip), "bar", &error_fatal); - qdev_realize(DEVICE(&chip9->psi), NULL, &local_err); - if (local_err) { + if (!qdev_realize(DEVICE(&chip9->psi), NULL, &local_err)) { error_propagate(errp, local_err); return; } @@ -1491,8 +1483,7 @@ static void pnv_chip_power9_realize(DeviceState *dev, Error **errp) /* LPC */ object_property_set_link(OBJECT(&chip9->lpc), OBJECT(&chip9->psi), "psi", &error_abort); - qdev_realize(DEVICE(&chip9->lpc), NULL, &local_err); - if (local_err) { + if (!qdev_realize(DEVICE(&chip9->lpc), NULL, &local_err)) { error_propagate(errp, local_err); return; } @@ -1505,8 +1496,7 @@ static void pnv_chip_power9_realize(DeviceState *dev, Error **errp) /* Create the simplified OCC model */ object_property_set_link(OBJECT(&chip9->occ), OBJECT(&chip9->psi), "psi", &error_abort); - qdev_realize(DEVICE(&chip9->occ), NULL, &local_err); - if (local_err) { + if (!qdev_realize(DEVICE(&chip9->occ), NULL, &local_err)) { error_propagate(errp, local_err); return; } @@ -1519,8 +1509,7 @@ static void pnv_chip_power9_realize(DeviceState *dev, Error **errp) /* HOMER */ object_property_set_link(OBJECT(&chip9->homer), OBJECT(chip), "chip", &error_abort); - qdev_realize(DEVICE(&chip9->homer), NULL, &local_err); - if (local_err) { + if (!qdev_realize(DEVICE(&chip9->homer), NULL, &local_err)) { error_propagate(errp, local_err); return; } @@ -1601,8 +1590,7 @@ static void pnv_chip_power10_realize(DeviceState *dev, Error **errp) /* Processor Service Interface (PSI) Host Bridge */ object_property_set_int(OBJECT(&chip10->psi), PNV10_PSIHB_BASE(chip), "bar", &error_fatal); - qdev_realize(DEVICE(&chip10->psi), NULL, &local_err); - if (local_err) { + if (!qdev_realize(DEVICE(&chip10->psi), NULL, &local_err)) { error_propagate(errp, local_err); return; } @@ -1612,8 +1600,7 @@ static void pnv_chip_power10_realize(DeviceState *dev, Error **errp) /* LPC */ object_property_set_link(OBJECT(&chip10->lpc), OBJECT(&chip10->psi), "psi", &error_abort); - qdev_realize(DEVICE(&chip10->lpc), NULL, &local_err); - if (local_err) { + if (!qdev_realize(DEVICE(&chip10->lpc), NULL, &local_err)) { error_propagate(errp, local_err); return; } diff --git a/hw/ppc/pnv_core.c b/hw/ppc/pnv_core.c index c986c16..d699f07 100644 --- a/hw/ppc/pnv_core.c +++ b/hw/ppc/pnv_core.c @@ -173,8 +173,7 @@ static void pnv_core_cpu_realize(PnvCore *pc, PowerPCCPU *cpu, Error **errp) Error *local_err = NULL; PnvChipClass *pcc = PNV_CHIP_GET_CLASS(pc->chip); - qdev_realize(DEVICE(cpu), NULL, &local_err); - if (local_err) { + if (!qdev_realize(DEVICE(cpu), NULL, &local_err)) { error_propagate(errp, local_err); return; } diff --git a/hw/ppc/pnv_psi.c b/hw/ppc/pnv_psi.c index 75b8ae9..7efe6e1 100644 --- a/hw/ppc/pnv_psi.c +++ b/hw/ppc/pnv_psi.c @@ -510,8 +510,7 @@ static void pnv_psi_power8_realize(DeviceState *dev, Error **errp) error_propagate(errp, err); return; } - qdev_realize(DEVICE(ics), NULL, &err); - if (err) { + if (!qdev_realize(DEVICE(ics), NULL, &err)) { error_propagate(errp, err); return; } @@ -851,8 +850,7 @@ static void pnv_psi_power9_realize(DeviceState *dev, Error **errp) object_property_set_int(OBJECT(xsrc), PSIHB9_NUM_IRQS, "nr-irqs", &error_fatal); object_property_set_link(OBJECT(xsrc), OBJECT(psi), "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; } diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c index 26ad566..85330d0 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -239,8 +239,7 @@ static void spapr_realize_vcpu(PowerPCCPU *cpu, SpaprMachineState *spapr, CPUState *cs = CPU(cpu); Error *local_err = NULL; - qdev_realize(DEVICE(cpu), NULL, &local_err); - if (local_err) { + if (!qdev_realize(DEVICE(cpu), NULL, &local_err)) { goto error; } diff --git a/hw/ppc/spapr_irq.c b/hw/ppc/spapr_irq.c index 897bf98..1d0db57 100644 --- a/hw/ppc/spapr_irq.c +++ b/hw/ppc/spapr_irq.c @@ -311,8 +311,7 @@ void spapr_irq_init(SpaprMachineState *spapr, Error **errp) object_property_set_link(obj, OBJECT(spapr), ICS_PROP_XICS, &error_abort); object_property_set_int(obj, smc->nr_xirqs, "nr-irqs", &error_abort); - qdev_realize(DEVICE(obj), NULL, &local_err); - if (local_err) { + if (!qdev_realize(DEVICE(obj), NULL, &local_err)) { error_propagate(errp, local_err); return; } |