qom: Use returned bool to check for failure, Coccinelle part

The previous commit enables conversion of

    foo(..., &err);
    if (err) {
        ...
    }

to

    if (!foo(..., errp)) {
        ...
    }

for QOM functions that now return true / false on success / error.
Coccinelle script:

    @@
    identifier fun = {
        object_apply_global_props, object_initialize_child_with_props,
        object_initialize_child_with_propsv, object_property_get,
        object_property_get_bool, object_property_parse, object_property_set,
        object_property_set_bool, object_property_set_int,
        object_property_set_link, object_property_set_qobject,
        object_property_set_str, object_property_set_uint, object_set_props,
        object_set_propv, user_creatable_add_dict,
        user_creatable_complete, user_creatable_del
    };
    expression list args, args2;
    typedef Error;
    Error *err;
    @@
    -    fun(args, &err, args2);
    -    if (err)
    +    if (!fun(args, &err, args2))
         {
             ...
         }

Fails to convert hw/arm/armsse.c, because Coccinelle gets confused by
ARMSSE being used both as typedef and function-like macro there.
Convert manually.

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>
Message-Id: <20200707160613.848843-29-armbru@redhat.com>
This commit is contained in:
Markus Armbruster 2020-07-07 18:05:56 +02:00
parent 6fd5bef10b
commit 778a2dc592
28 changed files with 96 additions and 142 deletions

View File

@ -534,22 +534,20 @@ static void armsse_realize(DeviceState *dev, Error **errp)
* later if necessary. * later if necessary.
*/ */
if (extract32(info->cpuwait_rst, i, 1)) { if (extract32(info->cpuwait_rst, i, 1)) {
object_property_set_bool(cpuobj, "start-powered-off", true, &err); if (!object_property_set_bool(cpuobj, "start-powered-off", true,
if (err) { &err)) {
error_propagate(errp, err); error_propagate(errp, err);
return; return;
} }
} }
if (!s->cpu_fpu[i]) { if (!s->cpu_fpu[i]) {
object_property_set_bool(cpuobj, "vfp", false, &err); if (!object_property_set_bool(cpuobj, "vfp", false, &err)) {
if (err) {
error_propagate(errp, err); error_propagate(errp, err);
return; return;
} }
} }
if (!s->cpu_dsp[i]) { if (!s->cpu_dsp[i]) {
object_property_set_bool(cpuobj, "dsp", false, &err); if (!object_property_set_bool(cpuobj, "dsp", false, &err)) {
if (err) {
error_propagate(errp, err); error_propagate(errp, err);
return; return;
} }
@ -604,9 +602,8 @@ static void armsse_realize(DeviceState *dev, Error **errp)
DeviceState *devs = DEVICE(splitter); DeviceState *devs = DEVICE(splitter);
int cpunum; int cpunum;
object_property_set_int(splitter, "num-lines", info->num_cpus, if (!object_property_set_int(splitter, "num-lines",
&err); info->num_cpus, &err)) {
if (err) {
error_propagate(errp, err); error_propagate(errp, err);
return; return;
} }
@ -658,9 +655,8 @@ static void armsse_realize(DeviceState *dev, Error **errp)
* multiple lines, one for each of the PPCs within the ARMSSE and one * multiple lines, one for each of the PPCs within the ARMSSE and one
* that will be an output from the ARMSSE to the system. * that will be an output from the ARMSSE to the system.
*/ */
object_property_set_int(OBJECT(&s->sec_resp_splitter), "num-lines", 3, if (!object_property_set_int(OBJECT(&s->sec_resp_splitter),
&err); "num-lines", 3, &err)) {
if (err) {
error_propagate(errp, err); error_propagate(errp, err);
return; return;
} }
@ -702,9 +698,9 @@ static void armsse_realize(DeviceState *dev, Error **errp)
} }
/* We must OR together lines from the MPC splitters to go to the NVIC */ /* We must OR together lines from the MPC splitters to go to the NVIC */
object_property_set_int(OBJECT(&s->mpc_irq_orgate), "num-lines", if (!object_property_set_int(OBJECT(&s->mpc_irq_orgate), "num-lines",
IOTS_NUM_EXP_MPC + info->sram_banks, &err); IOTS_NUM_EXP_MPC + info->sram_banks,
if (err) { &err)) {
error_propagate(errp, err); error_propagate(errp, err);
return; return;
} }
@ -841,9 +837,8 @@ static void armsse_realize(DeviceState *dev, Error **errp)
* ones) are sent individually to the security controller, and also * ones) are sent individually to the security controller, and also
* ORed together to give a single combined PPC interrupt to the NVIC. * ORed together to give a single combined PPC interrupt to the NVIC.
*/ */
object_property_set_int(OBJECT(&s->ppc_irq_orgate), "num-lines", NUM_PPCS, if (!object_property_set_int(OBJECT(&s->ppc_irq_orgate),
&err); "num-lines", NUM_PPCS, &err)) {
if (err) {
error_propagate(errp, err); error_propagate(errp, err);
return; return;
} }
@ -949,15 +944,13 @@ static void armsse_realize(DeviceState *dev, Error **errp)
qdev_get_gpio_in_named(dev_apb_ppc1, qdev_get_gpio_in_named(dev_apb_ppc1,
"cfg_sec_resp", 0)); "cfg_sec_resp", 0));
object_property_set_int(OBJECT(&s->sysinfo), "SYS_VERSION", if (!object_property_set_int(OBJECT(&s->sysinfo), "SYS_VERSION",
info->sys_version, &err); info->sys_version, &err)) {
if (err) {
error_propagate(errp, err); error_propagate(errp, err);
return; return;
} }
object_property_set_int(OBJECT(&s->sysinfo), "SYS_CONFIG", if (!object_property_set_int(OBJECT(&s->sysinfo), "SYS_CONFIG",
armsse_sys_config_value(s, info), &err); armsse_sys_config_value(s, info), &err)) {
if (err) {
error_propagate(errp, err); error_propagate(errp, err);
return; return;
} }
@ -1005,8 +998,8 @@ static void armsse_realize(DeviceState *dev, Error **errp)
} }
/* This OR gate wires together outputs from the secure watchdogs to NMI */ /* This OR gate wires together outputs from the secure watchdogs to NMI */
object_property_set_int(OBJECT(&s->nmi_orgate), "num-lines", 2, &err); if (!object_property_set_int(OBJECT(&s->nmi_orgate), "num-lines", 2,
if (err) { &err)) {
error_propagate(errp, err); error_propagate(errp, err);
return; return;
} }
@ -1049,8 +1042,7 @@ static void armsse_realize(DeviceState *dev, Error **errp)
for (i = 0; i < ARRAY_SIZE(s->ppc_irq_splitter); i++) { for (i = 0; i < ARRAY_SIZE(s->ppc_irq_splitter); i++) {
Object *splitter = OBJECT(&s->ppc_irq_splitter[i]); Object *splitter = OBJECT(&s->ppc_irq_splitter[i]);
object_property_set_int(splitter, "num-lines", 2, &err); if (!object_property_set_int(splitter, "num-lines", 2, &err)) {
if (err) {
error_propagate(errp, err); error_propagate(errp, err);
return; return;
} }
@ -1095,8 +1087,8 @@ static void armsse_realize(DeviceState *dev, Error **errp)
SplitIRQ *splitter = &s->mpc_irq_splitter[i]; SplitIRQ *splitter = &s->mpc_irq_splitter[i];
DeviceState *dev_splitter = DEVICE(splitter); DeviceState *dev_splitter = DEVICE(splitter);
object_property_set_int(OBJECT(splitter), "num-lines", 2, &err); if (!object_property_set_int(OBJECT(splitter), "num-lines", 2,
if (err) { &err)) {
error_propagate(errp, err); error_propagate(errp, err);
return; return;
} }

View File

@ -174,31 +174,27 @@ static void armv7m_realize(DeviceState *dev, Error **errp)
&error_abort); &error_abort);
} }
if (object_property_find(OBJECT(s->cpu), "init-svtor", NULL)) { if (object_property_find(OBJECT(s->cpu), "init-svtor", NULL)) {
object_property_set_uint(OBJECT(s->cpu), "init-svtor", s->init_svtor, if (!object_property_set_uint(OBJECT(s->cpu), "init-svtor",
&err); s->init_svtor, &err)) {
if (err != NULL) {
error_propagate(errp, err); error_propagate(errp, err);
return; return;
} }
} }
if (object_property_find(OBJECT(s->cpu), "start-powered-off", NULL)) { if (object_property_find(OBJECT(s->cpu), "start-powered-off", NULL)) {
object_property_set_bool(OBJECT(s->cpu), "start-powered-off", if (!object_property_set_bool(OBJECT(s->cpu), "start-powered-off",
s->start_powered_off, &err); s->start_powered_off, &err)) {
if (err != NULL) {
error_propagate(errp, err); error_propagate(errp, err);
return; return;
} }
} }
if (object_property_find(OBJECT(s->cpu), "vfp", NULL)) { if (object_property_find(OBJECT(s->cpu), "vfp", NULL)) {
object_property_set_bool(OBJECT(s->cpu), "vfp", s->vfp, &err); if (!object_property_set_bool(OBJECT(s->cpu), "vfp", s->vfp, &err)) {
if (err != NULL) {
error_propagate(errp, err); error_propagate(errp, err);
return; return;
} }
} }
if (object_property_find(OBJECT(s->cpu), "dsp", NULL)) { if (object_property_find(OBJECT(s->cpu), "dsp", NULL)) {
object_property_set_bool(OBJECT(s->cpu), "dsp", s->dsp, &err); if (!object_property_set_bool(OBJECT(s->cpu), "dsp", s->dsp, &err)) {
if (err != NULL) {
error_propagate(errp, err); error_propagate(errp, err);
return; return;
} }
@ -243,8 +239,8 @@ static void armv7m_realize(DeviceState *dev, Error **errp)
Object *obj = OBJECT(&s->bitband[i]); Object *obj = OBJECT(&s->bitband[i]);
SysBusDevice *sbd = SYS_BUS_DEVICE(&s->bitband[i]); SysBusDevice *sbd = SYS_BUS_DEVICE(&s->bitband[i]);
object_property_set_int(obj, "base", bitband_input_addr[i], &err); if (!object_property_set_int(obj, "base",
if (err != NULL) { bitband_input_addr[i], &err)) {
error_propagate(errp, err); error_propagate(errp, err);
return; return;
} }

View File

@ -356,9 +356,8 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
/* FMC, The number of CS is set at the board level */ /* FMC, The number of CS is set at the board level */
object_property_set_link(OBJECT(&s->fmc), "dram", OBJECT(s->dram_mr), object_property_set_link(OBJECT(&s->fmc), "dram", OBJECT(s->dram_mr),
&error_abort); &error_abort);
object_property_set_int(OBJECT(&s->fmc), "sdram-base", if (!object_property_set_int(OBJECT(&s->fmc), "sdram-base",
sc->memmap[ASPEED_SDRAM], &err); sc->memmap[ASPEED_SDRAM], &err)) {
if (err) {
error_propagate(errp, err); error_propagate(errp, err);
return; return;
} }

View File

@ -308,9 +308,8 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
/* FMC, The number of CS is set at the board level */ /* FMC, The number of CS is set at the board level */
object_property_set_link(OBJECT(&s->fmc), "dram", OBJECT(s->dram_mr), object_property_set_link(OBJECT(&s->fmc), "dram", OBJECT(s->dram_mr),
&error_abort); &error_abort);
object_property_set_int(OBJECT(&s->fmc), "sdram-base", if (!object_property_set_int(OBJECT(&s->fmc), "sdram-base",
sc->memmap[ASPEED_SDRAM], &err); sc->memmap[ASPEED_SDRAM], &err)) {
if (err) {
error_propagate(errp, err); error_propagate(errp, err);
return; return;
} }

View File

@ -222,9 +222,8 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
return; return;
} }
object_property_set_uint(OBJECT(&s->fb), "vcram-base", if (!object_property_set_uint(OBJECT(&s->fb), "vcram-base",
ram_size - vcram_size, &err); ram_size - vcram_size, &err)) {
if (err) {
error_propagate(errp, err); error_propagate(errp, err);
return; return;
} }

View File

@ -110,17 +110,17 @@ static void bcm2836_realize(DeviceState *dev, Error **errp)
s->cpu[n].core.mp_affinity = (info->clusterid << 8) | n; s->cpu[n].core.mp_affinity = (info->clusterid << 8) | n;
/* set periphbase/CBAR value for CPU-local registers */ /* set periphbase/CBAR value for CPU-local registers */
object_property_set_int(OBJECT(&s->cpu[n].core), "reset-cbar", if (!object_property_set_int(OBJECT(&s->cpu[n].core), "reset-cbar",
info->peri_base, &err); info->peri_base, &err)) {
if (err) {
error_propagate(errp, err); error_propagate(errp, err);
return; return;
} }
/* start powered off if not enabled */ /* start powered off if not enabled */
object_property_set_bool(OBJECT(&s->cpu[n].core), "start-powered-off", if (!object_property_set_bool(OBJECT(&s->cpu[n].core),
n >= s->enabled_cpus, &err); "start-powered-off",
if (err) { n >= s->enabled_cpus,
&err)) {
error_propagate(errp, err); error_propagate(errp, err);
return; return;
} }

View File

@ -62,20 +62,19 @@ static void cubieboard_init(MachineState *machine)
object_property_add_child(OBJECT(machine), "soc", OBJECT(a10)); object_property_add_child(OBJECT(machine), "soc", OBJECT(a10));
object_unref(OBJECT(a10)); object_unref(OBJECT(a10));
object_property_set_int(OBJECT(&a10->emac), "phy-addr", 1, &err); if (!object_property_set_int(OBJECT(&a10->emac), "phy-addr", 1, &err)) {
if (err != NULL) {
error_reportf_err(err, "Couldn't set phy address: "); error_reportf_err(err, "Couldn't set phy address: ");
exit(1); exit(1);
} }
object_property_set_int(OBJECT(&a10->timer), "clk0-freq", 32768, &err); if (!object_property_set_int(OBJECT(&a10->timer), "clk0-freq", 32768,
if (err != NULL) { &err)) {
error_reportf_err(err, "Couldn't set clk0 frequency: "); error_reportf_err(err, "Couldn't set clk0 frequency: ");
exit(1); exit(1);
} }
object_property_set_int(OBJECT(&a10->timer), "clk1-freq", 24000000, &err); if (!object_property_set_int(OBJECT(&a10->timer), "clk1-freq", 24000000,
if (err != NULL) { &err)) {
error_reportf_err(err, "Couldn't set clk1 frequency: "); error_reportf_err(err, "Couldn't set clk1 frequency: ");
exit(1); exit(1);
} }

View File

@ -56,8 +56,8 @@ static void digic_realize(DeviceState *dev, Error **errp)
SysBusDevice *sbd; SysBusDevice *sbd;
int i; int i;
object_property_set_bool(OBJECT(&s->cpu), "reset-hivecs", true, &err); if (!object_property_set_bool(OBJECT(&s->cpu), "reset-hivecs", true,
if (err != NULL) { &err)) {
error_propagate(errp, err); error_propagate(errp, err);
return; return;
} }

View File

@ -106,9 +106,8 @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp)
BASE_TO_IRQ(NRF51_RNG_BASE))); BASE_TO_IRQ(NRF51_RNG_BASE)));
/* UICR, FICR, NVMC, FLASH */ /* UICR, FICR, NVMC, FLASH */
object_property_set_uint(OBJECT(&s->nvm), "flash-size", s->flash_size, if (!object_property_set_uint(OBJECT(&s->nvm), "flash-size",
&err); s->flash_size, &err)) {
if (err) {
error_propagate(errp, err); error_propagate(errp, err);
return; return;
} }
@ -141,8 +140,7 @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp)
/* TIMER */ /* TIMER */
for (i = 0; i < NRF51_NUM_TIMERS; i++) { for (i = 0; i < NRF51_NUM_TIMERS; i++) {
object_property_set_uint(OBJECT(&s->timer[i]), "id", i, &err); if (!object_property_set_uint(OBJECT(&s->timer[i]), "id", i, &err)) {
if (err) {
error_propagate(errp, err); error_propagate(errp, err);
return; return;
} }

View File

@ -160,10 +160,9 @@ static void stm32f405_soc_realize(DeviceState *dev_soc, Error **errp)
} }
/* ADC device, the IRQs are ORed together */ /* ADC device, the IRQs are ORed together */
object_initialize_child_with_props(OBJECT(s), "adc-orirq", &s->adc_irqs, if (!object_initialize_child_with_props(OBJECT(s), "adc-orirq",
sizeof(s->adc_irqs), TYPE_OR_IRQ, &err, &s->adc_irqs, sizeof(s->adc_irqs),
NULL); TYPE_OR_IRQ, &err, NULL)) {
if (err != NULL) {
error_propagate(errp, err); error_propagate(errp, err);
return; return;
} }

View File

@ -507,18 +507,16 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
* - SDIO Specification Version 3.0 * - SDIO Specification Version 3.0
* - eMMC Specification Version 4.51 * - eMMC Specification Version 4.51
*/ */
object_property_set_uint(sdhci, "sd-spec-version", 3, &err); if (!object_property_set_uint(sdhci, "sd-spec-version", 3, &err)) {
if (err) {
error_propagate(errp, err); error_propagate(errp, err);
return; return;
} }
object_property_set_uint(sdhci, "capareg", SDHCI_CAPABILITIES, &err); if (!object_property_set_uint(sdhci, "capareg", SDHCI_CAPABILITIES,
if (err) { &err)) {
error_propagate(errp, err); error_propagate(errp, err);
return; return;
} }
object_property_set_uint(sdhci, "uhs", UHS_I, &err); if (!object_property_set_uint(sdhci, "uhs", UHS_I, &err)) {
if (err) {
error_propagate(errp, err); error_propagate(errp, err);
return; return;
} }
@ -606,8 +604,8 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
sysbus_connect_irq(SYS_BUS_DEVICE(&s->rtc), 0, gic_spi[RTC_IRQ]); sysbus_connect_irq(SYS_BUS_DEVICE(&s->rtc), 0, gic_spi[RTC_IRQ]);
for (i = 0; i < XLNX_ZYNQMP_NUM_GDMA_CH; i++) { for (i = 0; i < XLNX_ZYNQMP_NUM_GDMA_CH; i++) {
object_property_set_uint(OBJECT(&s->gdma[i]), "bus-width", 128, &err); if (!object_property_set_uint(OBJECT(&s->gdma[i]), "bus-width", 128,
if (err) { &err)) {
error_propagate(errp, err); error_propagate(errp, err);
return; return;
} }

View File

@ -935,22 +935,21 @@ static void xen_block_device_create(XenBackendInstance *backend,
xendev = XEN_DEVICE(qdev_new(type)); xendev = XEN_DEVICE(qdev_new(type));
blockdev = XEN_BLOCK_DEVICE(xendev); blockdev = XEN_BLOCK_DEVICE(xendev);
object_property_set_str(OBJECT(xendev), "vdev", vdev, &local_err); if (!object_property_set_str(OBJECT(xendev), "vdev", vdev,
if (local_err) { &local_err)) {
error_propagate_prepend(errp, local_err, "failed to set 'vdev': "); error_propagate_prepend(errp, local_err, "failed to set 'vdev': ");
goto fail; goto fail;
} }
object_property_set_str(OBJECT(xendev), "drive", if (!object_property_set_str(OBJECT(xendev), "drive",
xen_block_drive_get_node_name(drive), &local_err); xen_block_drive_get_node_name(drive),
if (local_err) { &local_err)) {
error_propagate_prepend(errp, local_err, "failed to set 'drive': "); error_propagate_prepend(errp, local_err, "failed to set 'drive': ");
goto fail; goto fail;
} }
object_property_set_str(OBJECT(xendev), "iothread", iothread->id, if (!object_property_set_str(OBJECT(xendev), "iothread", iothread->id,
&local_err); &local_err)) {
if (local_err) {
error_propagate_prepend(errp, local_err, error_propagate_prepend(errp, local_err,
"failed to set 'iothread': "); "failed to set 'iothread': ");
goto fail; goto fail;

View File

@ -398,8 +398,7 @@ bool qdev_realize(DeviceState *dev, BusState *bus, Error **errp)
assert(!DEVICE_GET_CLASS(dev)->bus_type); assert(!DEVICE_GET_CLASS(dev)->bus_type);
} }
object_property_set_bool(OBJECT(dev), "realized", true, &err); if (!object_property_set_bool(OBJECT(dev), "realized", true, &err)) {
if (err) {
error_propagate(errp, err); error_propagate(errp, err);
} }
return !err; return !err;

View File

@ -121,8 +121,7 @@ void x86_cpu_new(X86MachineState *x86ms, int64_t apic_id, Error **errp)
Error *local_err = NULL; Error *local_err = NULL;
Object *cpu = object_new(MACHINE(x86ms)->cpu_type); Object *cpu = object_new(MACHINE(x86ms)->cpu_type);
object_property_set_uint(cpu, "apic-id", apic_id, &local_err); if (!object_property_set_uint(cpu, "apic-id", apic_id, &local_err)) {
if (local_err) {
goto out; goto out;
} }
qdev_realize(DEVICE(cpu), NULL, &local_err); qdev_realize(DEVICE(cpu), NULL, &local_err);

View File

@ -505,8 +505,8 @@ static void pnv_psi_power8_realize(DeviceState *dev, Error **errp)
unsigned int i; unsigned int i;
/* Create PSI interrupt control source */ /* Create PSI interrupt control source */
object_property_set_int(OBJECT(ics), "nr-irqs", PSI_NUM_INTERRUPTS, &err); if (!object_property_set_int(OBJECT(ics), "nr-irqs", PSI_NUM_INTERRUPTS,
if (err) { &err)) {
error_propagate(errp, err); error_propagate(errp, err);
return; return;
} }

View File

@ -824,8 +824,7 @@ static S390PCIBusDevice *s390_pci_device_new(S390pciState *s,
return NULL; return NULL;
} }
object_property_set_str(OBJECT(dev), "target", target, &local_err); if (!object_property_set_str(OBJECT(dev), "target", target, &local_err)) {
if (local_err) {
object_unparent(OBJECT(dev)); object_unparent(OBJECT(dev));
error_propagate_prepend(errp, local_err, error_propagate_prepend(errp, local_err,
"zPCI device could not be created: "); "zPCI device could not be created: ");

View File

@ -70,8 +70,7 @@ static S390CPU *s390x_new_cpu(const char *typename, uint32_t core_id,
S390CPU *cpu = S390_CPU(object_new(typename)); S390CPU *cpu = S390_CPU(object_new(typename));
Error *err = NULL; Error *err = NULL;
object_property_set_int(OBJECT(cpu), "core-id", core_id, &err); if (!object_property_set_int(OBJECT(cpu), "core-id", core_id, &err)) {
if (err != NULL) {
goto out; goto out;
} }
qdev_realize(DEVICE(cpu), NULL, &err); qdev_realize(DEVICE(cpu), NULL, &err);

View File

@ -283,8 +283,7 @@ SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockBackend *blk,
object_unparent(OBJECT(dev)); object_unparent(OBJECT(dev));
return NULL; return NULL;
} }
object_property_set_bool(OBJECT(dev), "share-rw", share_rw, &err); if (!object_property_set_bool(OBJECT(dev), "share-rw", share_rw, &err)) {
if (err != NULL) {
error_propagate(errp, err); error_propagate(errp, err);
object_unparent(OBJECT(dev)); object_unparent(OBJECT(dev));
return NULL; return NULL;

View File

@ -132,15 +132,13 @@ static void aspeed_sdhci_realize(DeviceState *dev, Error **errp)
Object *sdhci_slot = OBJECT(&sdhci->slots[i]); Object *sdhci_slot = OBJECT(&sdhci->slots[i]);
SysBusDevice *sbd_slot = SYS_BUS_DEVICE(&sdhci->slots[i]); SysBusDevice *sbd_slot = SYS_BUS_DEVICE(&sdhci->slots[i]);
object_property_set_int(sdhci_slot, "sd-spec-version", 2, &err); if (!object_property_set_int(sdhci_slot, "sd-spec-version", 2, &err)) {
if (err) {
error_propagate(errp, err); error_propagate(errp, err);
return; return;
} }
object_property_set_uint(sdhci_slot, "capareg", if (!object_property_set_uint(sdhci_slot, "capareg",
ASPEED_SDHCI_CAPABILITIES, &err); ASPEED_SDHCI_CAPABILITIES, &err)) {
if (err) {
error_propagate(errp, err); error_propagate(errp, err);
return; return;
} }

View File

@ -261,8 +261,7 @@ static void ssi_sd_realize(SSISlave *d, Error **errp)
} }
} }
object_property_set_bool(OBJECT(carddev), "spi", true, &err); if (!object_property_set_bool(OBJECT(carddev), "spi", true, &err)) {
if (err) {
goto fail; goto fail;
} }

View File

@ -194,9 +194,8 @@ static void virtio_rng_device_realize(DeviceState *dev, Error **errp)
if (vrng->conf.rng == NULL) { if (vrng->conf.rng == NULL) {
Object *default_backend = object_new(TYPE_RNG_BUILTIN); Object *default_backend = object_new(TYPE_RNG_BUILTIN);
user_creatable_complete(USER_CREATABLE(default_backend), if (!user_creatable_complete(USER_CREATABLE(default_backend),
&local_err); &local_err)) {
if (local_err) {
error_propagate(errp, local_err); error_propagate(errp, local_err);
object_unref(default_backend); object_unref(default_backend);
return; return;

View File

@ -186,8 +186,7 @@ static int set_property(void *opaque, const char *name, const char *value,
if (strcmp(name, "bus") == 0) if (strcmp(name, "bus") == 0)
return 0; return 0;
object_property_parse(obj, name, value, &err); if (!object_property_parse(obj, name, value, &err)) {
if (err != NULL) {
error_propagate(errp, err); error_propagate(errp, err);
return -1; return -1;
} }

View File

@ -405,8 +405,7 @@ bool object_apply_global_props(Object *obj, const GPtrArray *props,
continue; continue;
} }
p->used = true; p->used = true;
object_property_parse(obj, p->property, p->value, &err); if (!object_property_parse(obj, p->property, p->value, &err)) {
if (err != NULL) {
error_prepend(&err, "can't apply global %s.%s=%s: ", error_prepend(&err, "can't apply global %s.%s=%s: ",
p->driver, p->property, p->value); p->driver, p->property, p->value);
/* /*
@ -566,8 +565,7 @@ bool object_initialize_child_with_propsv(Object *parentobj,
uc = (UserCreatable *)object_dynamic_cast(obj, TYPE_USER_CREATABLE); uc = (UserCreatable *)object_dynamic_cast(obj, TYPE_USER_CREATABLE);
if (uc) { if (uc) {
user_creatable_complete(uc, &local_err); if (!user_creatable_complete(uc, &local_err)) {
if (local_err) {
object_unparent(obj); object_unparent(obj);
goto out; goto out;
} }
@ -764,8 +762,7 @@ Object *object_new_with_propv(const char *typename,
uc = (UserCreatable *)object_dynamic_cast(obj, TYPE_USER_CREATABLE); uc = (UserCreatable *)object_dynamic_cast(obj, TYPE_USER_CREATABLE);
if (uc) { if (uc) {
user_creatable_complete(uc, &local_err); if (!user_creatable_complete(uc, &local_err)) {
if (local_err) {
if (id != NULL) { if (id != NULL) {
object_unparent(obj); object_unparent(obj);
} }
@ -810,8 +807,7 @@ int object_set_propv(Object *obj,
const char *value = va_arg(vargs, char *); const char *value = va_arg(vargs, char *);
g_assert(value != NULL); g_assert(value != NULL);
object_property_parse(obj, propname, value, &local_err); if (!object_property_parse(obj, propname, value, &local_err)) {
if (local_err) {
error_propagate(errp, local_err); error_propagate(errp, local_err);
return -1; return -1;
} }
@ -1608,8 +1604,7 @@ char *object_property_print(Object *obj, const char *name, bool human,
Error *local_err = NULL; Error *local_err = NULL;
v = string_output_visitor_new(human, &string); v = string_output_visitor_new(human, &string);
object_property_get(obj, name, v, &local_err); if (!object_property_get(obj, name, v, &local_err)) {
if (local_err) {
error_propagate(errp, local_err); error_propagate(errp, local_err);
goto out; goto out;
} }

View File

@ -70,8 +70,7 @@ Object *user_creatable_add_type(const char *type, const char *id,
goto out; goto out;
} }
for (e = qdict_first(qdict); e; e = qdict_next(qdict, e)) { for (e = qdict_first(qdict); e; e = qdict_next(qdict, e)) {
object_property_set(obj, e->key, v, &local_err); if (!object_property_set(obj, e->key, v, &local_err)) {
if (local_err) {
break; break;
} }
} }
@ -88,8 +87,7 @@ Object *user_creatable_add_type(const char *type, const char *id,
id, obj); id, obj);
} }
user_creatable_complete(USER_CREATABLE(obj), &local_err); if (!user_creatable_complete(USER_CREATABLE(obj), &local_err)) {
if (local_err) {
if (id != NULL) { if (id != NULL) {
object_property_del(object_get_objects_root(), id); object_property_del(object_get_objects_root(), id);
} }

View File

@ -2469,9 +2469,7 @@ static int object_parse_property_opt(Object *obj,
return 0; return 0;
} }
object_property_parse(obj, name, value, &local_err); if (!object_property_parse(obj, name, value, &local_err)) {
if (local_err) {
error_propagate(errp, local_err); error_propagate(errp, local_err);
return -1; return -1;
} }

View File

@ -184,8 +184,7 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type,
i = 0; i = 0;
while ((name = cpu_model_advertised_features[i++]) != NULL) { while ((name = cpu_model_advertised_features[i++]) != NULL) {
if (qdict_get(qdict_in, name)) { if (qdict_get(qdict_in, name)) {
object_property_set(obj, name, visitor, &err); if (!object_property_set(obj, name, visitor, &err)) {
if (err) {
break; break;
} }
} }

View File

@ -5271,9 +5271,8 @@ static void object_apply_props(Object *obj, QDict *props, Error **errp)
Error *err = NULL; Error *err = NULL;
for (prop = qdict_first(props); prop; prop = qdict_next(props, prop)) { for (prop = qdict_first(props); prop; prop = qdict_next(props, prop)) {
object_property_set_qobject(obj, qdict_entry_key(prop), if (!object_property_set_qobject(obj, qdict_entry_key(prop),
qdict_entry_value(prop), &err); qdict_entry_value(prop), &err)) {
if (err) {
break; break;
} }
} }
@ -6340,16 +6339,14 @@ static void x86_cpu_expand_features(X86CPU *cpu, Error **errp)
for (l = plus_features; l; l = l->next) { for (l = plus_features; l; l = l->next) {
const char *prop = l->data; const char *prop = l->data;
object_property_set_bool(OBJECT(cpu), prop, true, &local_err); if (!object_property_set_bool(OBJECT(cpu), prop, true, &local_err)) {
if (local_err) {
goto out; goto out;
} }
} }
for (l = minus_features; l; l = l->next) { for (l = minus_features; l; l = l->next) {
const char *prop = l->data; const char *prop = l->data;
object_property_set_bool(OBJECT(cpu), prop, false, &local_err); if (!object_property_set_bool(OBJECT(cpu), prop, false, &local_err)) {
if (local_err) {
goto out; goto out;
} }
} }

View File

@ -517,8 +517,7 @@ static void cpu_model_from_info(S390CPUModel *model, const CpuModelInfo *info,
return; return;
} }
for (e = qdict_first(qdict); e; e = qdict_next(qdict, e)) { for (e = qdict_first(qdict); e; e = qdict_next(qdict, e)) {
object_property_set(obj, e->key, visitor, &err); if (!object_property_set(obj, e->key, visitor, &err)) {
if (err) {
break; break;
} }
} }