qemu-e2k/hw/core
Markus Armbruster d2623129a7 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]
2020-05-15 07:07:58 +02:00
..
Kconfig hw/core: Add a config switch for the generic loader device 2019-08-20 09:11:17 +02:00
Makefile.objs qdev: add clock input&output support to devices. 2020-04-30 15:35:40 +01:00
bus.c qom: Drop parameter @errp of object_property_add() & friends 2020-05-15 07:07:58 +02:00
clock-vmstate.c hw/core/clock-vmstate: define a vmstate entry for clock state 2020-04-30 15:35:40 +01:00
clock.c hw/core/clock: introduce clock object 2020-04-30 11:52:28 +01:00
cpu.c x86 and machine queue for 5.0 soft freeze 2020-03-19 14:22:46 +00:00
empty_slot.c Include hw/hw.h exactly where needed 2019-08-16 13:31:52 +02:00
fw-path-provider.c Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
generic-loader.c hw/core/loader: Let load_elf() populate a field with CPU-specific flags 2020-01-29 19:28:52 +01:00
hotplug.c call HotplugHandler->plug() as the last step in device realization 2018-10-19 13:44:12 +02:00
irq.c Revert "irq: introduce qemu_irq_proxy()" 2019-11-05 23:33:12 +01:00
loader-fit.c hw/core: Fix fit_load_fdt() error API violations 2019-12-18 08:36:15 +01:00
loader.c hw/core: properly terminate loading .hex on EOF record 2020-04-07 16:19:49 +01:00
machine-hmp-cmds.c qapi: Only input visitors can actually fail 2020-04-30 07:26:40 +02:00
machine-qmp-cmds.c qom: Drop convenience method object_property_get_uint16List() 2020-05-15 06:26:02 +02:00
machine.c qom: Drop parameter @errp of object_property_add() & friends 2020-05-15 07:07:58 +02:00
nmi.c Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
null-machine.c null-machine: use memdev for RAM 2020-02-19 16:49:57 +00:00
numa.c remove no longer used memory_region_allocate_system_memory() 2020-02-19 16:50:01 +00:00
or-irq.c hw/core/or-irq: Fix incorrect assert forbidding num-lines == MAX_OR_LINES 2020-01-30 16:02:01 +00:00
platform-bus.c hw/core: Let devices own the MemoryRegion they create 2020-03-17 15:18:48 +01:00
ptimer.c ptimer: Remove old ptimer_init_with_bh() API 2019-11-11 13:44:16 +00:00
qdev-clock.c qom: Drop parameter @errp of object_property_add() & friends 2020-05-15 07:07:58 +02:00
qdev-fw.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
qdev-properties-system.c audio: add audiodev properties to frontends 2019-08-21 09:13:37 +02:00
qdev-properties.c qom: Drop parameter @errp of object_property_add() & friends 2020-05-15 07:07:58 +02:00
qdev.c qom: Drop parameter @errp of object_property_add() & friends 2020-05-15 07:07:58 +02:00
register.c hw/core/register: Add register_init_block8 helper. 2020-05-05 13:37:51 -07:00
reset.c qemu/queue.h: leave head structs anonymous unless necessary 2019-01-11 15:46:55 +01:00
resettable.c hw/core: deprecate old reset functions and introduce new ones 2020-01-30 16:02:04 +00:00
split-irq.c qdev: set properties with device_class_set_props() 2020-01-24 20:59:15 +01:00
stream.c hw/core: stream: Add an end-of-packet flag 2020-05-14 13:44:35 +02:00
sysbus.c sysbus: remove unused sysbus_try_create* 2020-01-07 16:06:59 +04:00
trace-events hw/core/clock: introduce clock object 2020-04-30 11:52:28 +01:00
uboot_image.h Support u-boot noload images for arm as used by, NetBSD/evbarm GENERIC kernel. 2019-01-07 15:46:20 +00:00
vm-change-state-handler.c sysemu: Split sysemu/runstate.h off sysemu/sysemu.h 2019-08-16 13:37:36 +02:00
vmstate-if.c vmstate: add qom interface to get id 2020-01-06 18:41:32 +04:00