]> git.proxmox.com Git - mirror_qemu.git/commit
qom: Drop parameter @errp of object_property_add() & friends
authorMarkus Armbruster <armbru@redhat.com>
Tue, 5 May 2020 15:29:22 +0000 (17:29 +0200)
committerMarkus Armbruster <armbru@redhat.com>
Fri, 15 May 2020 05:07:58 +0000 (07:07 +0200)
commitd2623129a7dec1d3041ad1221dda1ca49c667532
tree9bcac33dfaed2361cd536856159b9960135ccd46
parent9f742c28f52d55ff83dc441a0cea365239a4906d
qom: Drop parameter @errp of object_property_add() & friends

The only way object_property_add() can fail is when a property with
the same name already exists.  Since our property names are all
hardcoded, failure is a programming error, and the appropriate way to
handle it is passing &error_abort.

Same for its variants, except for object_property_add_child(), which
additionally fails when the child already has a parent.  Parentage is
also under program control, so this is a programming error, too.

We have a bit over 500 callers.  Almost half of them pass
&error_abort, slightly fewer ignore errors, one test case handles
errors, and the remaining few callers pass them to their own callers.

The previous few commits demonstrated once again that ignoring
programming errors is a bad idea.

Of the few ones that pass on errors, several violate the Error API.
The Error ** argument must be NULL, &error_abort, &error_fatal, or a
pointer to a variable containing NULL.  Passing an argument of the
latter kind twice without clearing it in between is wrong: if the
first call sets an error, it no longer points to NULL for the second
call.  ich9_pm_add_properties(), sparc32_ledma_realize(),
sparc32_dma_realize(), xilinx_axidma_realize(), xilinx_enet_realize()
are wrong that way.

When the one appropriate choice of argument is &error_abort, letting
users pick the argument is a bad idea.

Drop parameter @errp and assert the preconditions instead.

There's one exception to "duplicate property name is a programming
error": the way object_property_add() implements the magic (and
undocumented) "automatic arrayification".  Don't drop @errp there.
Instead, rename object_property_add() to object_property_try_add(),
and add the obvious wrapper object_property_add().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200505152926.18877-15-armbru@redhat.com>
[Two semantic rebase conflicts resolved]
192 files changed:
accel/kvm/kvm-all.c
accel/tcg/tcg-all.c
authz/list.c
authz/listfile.c
authz/pamacct.c
authz/simple.c
backends/cryptodev-vhost-user.c
backends/cryptodev.c
backends/dbus-vmstate.c
backends/hostmem-file.c
backends/hostmem-memfd.c
backends/hostmem.c
backends/rng-egd.c
backends/rng-random.c
backends/rng.c
backends/vhost-user.c
block/throttle-groups.c
bootdevice.c
chardev/char-socket.c
chardev/char.c
crypto/secret.c
crypto/tlscreds.c
crypto/tlscredsanon.c
crypto/tlscredspsk.c
crypto/tlscredsx509.c
hw/acpi/ich9.c
hw/acpi/pcihp.c
hw/acpi/piix4.c
hw/arm/allwinner-a10.c
hw/arm/allwinner-h3.c
hw/arm/armv7m.c
hw/arm/aspeed.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/mcimx6ul-evk.c
hw/arm/mcimx7d-sabre.c
hw/arm/msf2-soc.c
hw/arm/nrf51_soc.c
hw/arm/orangepi.c
hw/arm/raspi.c
hw/arm/sabrelite.c
hw/arm/sbsa-ref.c
hw/arm/vexpress.c
hw/arm/virt.c
hw/arm/xilinx_zynq.c
hw/arm/xlnx-versal-virt.c
hw/arm/xlnx-versal.c
hw/arm/xlnx-zcu102.c
hw/arm/xlnx-zynqmp.c
hw/audio/marvell_88w8618.c
hw/audio/pcspk.c
hw/core/bus.c
hw/core/machine.c
hw/core/qdev-clock.c
hw/core/qdev-properties.c
hw/core/qdev.c
hw/cpu/core.c
hw/display/bochs-display.c
hw/display/sm501.c
hw/display/vga-pci.c
hw/display/vhost-user-gpu-pci.c
hw/display/vhost-user-gpu.c
hw/display/vhost-user-vga.c
hw/display/xlnx_dp.c
hw/dma/sparc32_dma.c
hw/dma/xilinx_axidma.c
hw/dma/xlnx-zdma.c
hw/gpio/aspeed_gpio.c
hw/hyperv/hyperv.c
hw/i386/microvm.c
hw/i386/pc.c
hw/i386/pc_piix.c
hw/i386/pc_q35.c
hw/i386/pc_sysfw.c
hw/i386/x86.c
hw/ide/macio.c
hw/ide/qdev.c
hw/input/vhost-user-input.c
hw/intc/apic_common.c
hw/intc/s390_flic.c
hw/intc/xics.c
hw/intc/xive.c
hw/ipmi/ipmi.c
hw/isa/isa-superio.c
hw/isa/lpc_ich9.c
hw/mem/nvdimm.c
hw/mem/pc-dimm.c
hw/microblaze/petalogix_ml605_mmu.c
hw/misc/aspeed_sdmc.c
hw/misc/edu.c
hw/misc/mac_via.c
hw/misc/macio/gpio.c
hw/misc/macio/macio.c
hw/misc/macio/pmu.c
hw/misc/pca9552.c
hw/misc/tmp105.c
hw/misc/tmp421.c
hw/net/cadence_gem.c
hw/net/can/can_kvaser_pci.c
hw/net/can/can_mioe3680_pci.c
hw/net/can/can_pcm3680_pci.c
hw/net/ne2000-isa.c
hw/net/xilinx_axienet.c
hw/nios2/10m50_devboard.c
hw/nvram/fw_cfg.c
hw/pci-host/grackle.c
hw/pci-host/i440fx.c
hw/pci-host/pnv_phb3_msi.c
hw/pci-host/pnv_phb3_pbcq.c
hw/pci-host/q35.c
hw/pci-host/sabre.c
hw/pci-host/uninorth.c
hw/pcmcia/pxa2xx.c
hw/ppc/e500.c
hw/ppc/mac_newworld.c
hw/ppc/mac_oldworld.c
hw/ppc/pnv.c
hw/ppc/pnv_bmc.c
hw/ppc/pnv_core.c
hw/ppc/pnv_psi.c
hw/ppc/prep.c
hw/ppc/spapr.c
hw/ppc/spapr_caps.c
hw/ppc/spapr_cpu_core.c
hw/ppc/spapr_drc.c
hw/ppc/spapr_iommu.c
hw/ppc/spapr_irq.c
hw/ppc/spapr_rtc.c
hw/riscv/sifive_u.c
hw/riscv/virt.c
hw/rtc/mc146818rtc.c
hw/s390x/ap-bridge.c
hw/s390x/css-bridge.c
hw/s390x/event-facility.c
hw/s390x/s390-skeys.c
hw/s390x/s390-stattrib.c
hw/s390x/s390-virtio-ccw.c
hw/s390x/sclp.c
hw/s390x/tod.c
hw/s390x/virtio-ccw-balloon.c
hw/s390x/virtio-ccw-blk.c
hw/s390x/virtio-ccw-net.c
hw/scsi/scsi-bus.c
hw/sparc/sun4m.c
hw/sparc64/sun4u.c
hw/ssi/xilinx_spips.c
hw/usb/bus.c
hw/usb/dev-storage.c
hw/vfio/pci-quirks.c
hw/virtio/vhost-scsi-pci.c
hw/virtio/vhost-user-blk-pci.c
hw/virtio/vhost-user-input-pci.c
hw/virtio/vhost-user-scsi-pci.c
hw/virtio/virtio-balloon-pci.c
hw/virtio/virtio-balloon.c
hw/virtio/virtio-blk-pci.c
hw/virtio/virtio-net-pci.c
hw/virtio/virtio-rng.c
hw/xen/xen-common.c
include/qom/object.h
iothread.c
memory.c
net/can/can_host.c
net/can/can_socketcan.c
net/colo-compare.c
net/dump.c
net/filter-buffer.c
net/filter-mirror.c
net/filter-rewriter.c
net/filter.c
qdev-monitor.c
qom/container.c
qom/object.c
qom/object_interfaces.c
scsi/pr-manager-helper.c
softmmu/vl.c
target/arm/cpu.c
target/arm/cpu64.c
target/arm/kvm.c
target/i386/cpu.c
target/i386/sev.c
target/ppc/compat.c
target/s390x/cpu.c
target/s390x/cpu_models.c
tests/check-qom-proplist.c
tests/test-qdev-global-props.c
ui/console.c
ui/input-barrier.c
ui/input-linux.c