]> git.proxmox.com Git - mirror_qemu.git/commit
qdev: Use returned bool to check for qdev_realize() etc. failure
authorMarkus Armbruster <armbru@redhat.com>
Tue, 7 Jul 2020 16:05:32 +0000 (18:05 +0200)
committerMarkus Armbruster <armbru@redhat.com>
Fri, 10 Jul 2020 13:01:06 +0000 (15:01 +0200)
commit118bfd76c9c604588cb3f97811710576f58e5a76
tree0b3c83772d214c827e2aa87581e2b9126052d612
parente3fe3988d7851cac30abffae06d2f555ff7bee62
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>
65 files changed:
hw/arm/allwinner-a10.c
hw/arm/armsse.c
hw/arm/armv7m.c
hw/arm/aspeed_ast2600.c
hw/arm/aspeed_soc.c
hw/arm/bcm2835_peripherals.c
hw/arm/bcm2836.c
hw/arm/cubieboard.c
hw/arm/digic.c
hw/arm/digic_boards.c
hw/arm/fsl-imx25.c
hw/arm/fsl-imx31.c
hw/arm/fsl-imx6.c
hw/arm/msf2-soc.c
hw/arm/nrf51_soc.c
hw/arm/stm32f205_soc.c
hw/arm/stm32f405_soc.c
hw/arm/xlnx-zynqmp.c
hw/block/fdc.c
hw/block/xen-block.c
hw/char/serial-pci-multi.c
hw/char/serial-pci.c
hw/char/serial.c
hw/core/cpu.c
hw/cpu/a15mpcore.c
hw/cpu/a9mpcore.c
hw/cpu/arm11mpcore.c
hw/cpu/realview_mpcore.c
hw/display/virtio-gpu-pci.c
hw/display/virtio-vga.c
hw/intc/armv7m_nvic.c
hw/intc/pnv_xive.c
hw/intc/realview_gic.c
hw/intc/spapr_xive.c
hw/intc/xics.c
hw/intc/xive.c
hw/isa/piix4.c
hw/microblaze/xlnx-zynqmp-pmu.c
hw/mips/cps.c
hw/misc/macio/cuda.c
hw/misc/macio/macio.c
hw/misc/macio/pmu.c
hw/pci-host/pnv_phb3.c
hw/pci-host/pnv_phb4.c
hw/pci-host/pnv_phb4_pec.c
hw/ppc/e500.c
hw/ppc/pnv.c
hw/ppc/pnv_core.c
hw/ppc/pnv_psi.c
hw/ppc/spapr_cpu_core.c
hw/ppc/spapr_irq.c
hw/riscv/opentitan.c
hw/riscv/sifive_e.c
hw/riscv/sifive_u.c
hw/s390x/event-facility.c
hw/s390x/s390-pci-bus.c
hw/s390x/sclp.c
hw/s390x/virtio-ccw-crypto.c
hw/s390x/virtio-ccw-rng.c
hw/scsi/scsi-bus.c
hw/sd/aspeed_sdhci.c
hw/sd/ssi-sd.c
hw/usb/bus.c
hw/virtio/virtio-rng-pci.c
qdev-monitor.c