aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2020-07-07 18:05:56 +0200
committerMarkus Armbruster <armbru@redhat.com>2020-07-10 15:18:08 +0200
commit778a2dc59213d789f5bf8409547b529af4eb9ead (patch)
tree5fa10bb05617c2d20de9d7daf5376a85914e3967 /hw
parent6fd5bef10b8f0bf64df4e800bfda1da5fe17ca82 (diff)
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>
Diffstat (limited to 'hw')
-rw-r--r--hw/arm/armsse.c52
-rw-r--r--hw/arm/armv7m.c20
-rw-r--r--hw/arm/aspeed_ast2600.c5
-rw-r--r--hw/arm/aspeed_soc.c5
-rw-r--r--hw/arm/bcm2835_peripherals.c5
-rw-r--r--hw/arm/bcm2836.c12
-rw-r--r--hw/arm/cubieboard.c11
-rw-r--r--hw/arm/digic.c4
-rw-r--r--hw/arm/nrf51_soc.c8
-rw-r--r--hw/arm/stm32f405_soc.c7
-rw-r--r--hw/arm/xlnx-zynqmp.c14
-rw-r--r--hw/block/xen-block.c15
-rw-r--r--hw/core/qdev.c3
-rw-r--r--hw/i386/x86.c3
-rw-r--r--hw/ppc/pnv_psi.c4
-rw-r--r--hw/s390x/s390-pci-bus.c3
-rw-r--r--hw/s390x/s390-virtio-ccw.c3
-rw-r--r--hw/scsi/scsi-bus.c3
-rw-r--r--hw/sd/aspeed_sdhci.c8
-rw-r--r--hw/sd/ssi-sd.c3
-rw-r--r--hw/virtio/virtio-rng.c5
21 files changed, 81 insertions, 112 deletions
diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c
index 1f8ce94ecc..c8604926a3 100644
--- a/hw/arm/armsse.c
+++ b/hw/arm/armsse.c
@@ -534,22 +534,20 @@ static void armsse_realize(DeviceState *dev, Error **errp)
* later if necessary.
*/
if (extract32(info->cpuwait_rst, i, 1)) {
- object_property_set_bool(cpuobj, "start-powered-off", true, &err);
- if (err) {
+ if (!object_property_set_bool(cpuobj, "start-powered-off", true,
+ &err)) {
error_propagate(errp, err);
return;
}
}
if (!s->cpu_fpu[i]) {
- object_property_set_bool(cpuobj, "vfp", false, &err);
- if (err) {
+ if (!object_property_set_bool(cpuobj, "vfp", false, &err)) {
error_propagate(errp, err);
return;
}
}
if (!s->cpu_dsp[i]) {
- object_property_set_bool(cpuobj, "dsp", false, &err);
- if (err) {
+ if (!object_property_set_bool(cpuobj, "dsp", false, &err)) {
error_propagate(errp, err);
return;
}
@@ -604,9 +602,8 @@ static void armsse_realize(DeviceState *dev, Error **errp)
DeviceState *devs = DEVICE(splitter);
int cpunum;
- object_property_set_int(splitter, "num-lines", info->num_cpus,
- &err);
- if (err) {
+ if (!object_property_set_int(splitter, "num-lines",
+ info->num_cpus, &err)) {
error_propagate(errp, err);
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
* that will be an output from the ARMSSE to the system.
*/
- object_property_set_int(OBJECT(&s->sec_resp_splitter), "num-lines", 3,
- &err);
- if (err) {
+ if (!object_property_set_int(OBJECT(&s->sec_resp_splitter),
+ "num-lines", 3, &err)) {
error_propagate(errp, err);
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 */
- object_property_set_int(OBJECT(&s->mpc_irq_orgate), "num-lines",
- IOTS_NUM_EXP_MPC + info->sram_banks, &err);
- if (err) {
+ if (!object_property_set_int(OBJECT(&s->mpc_irq_orgate), "num-lines",
+ IOTS_NUM_EXP_MPC + info->sram_banks,
+ &err)) {
error_propagate(errp, err);
return;
}
@@ -841,9 +837,8 @@ static void armsse_realize(DeviceState *dev, Error **errp)
* ones) are sent individually to the security controller, and also
* 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,
- &err);
- if (err) {
+ if (!object_property_set_int(OBJECT(&s->ppc_irq_orgate),
+ "num-lines", NUM_PPCS, &err)) {
error_propagate(errp, err);
return;
}
@@ -949,15 +944,13 @@ static void armsse_realize(DeviceState *dev, Error **errp)
qdev_get_gpio_in_named(dev_apb_ppc1,
"cfg_sec_resp", 0));
- object_property_set_int(OBJECT(&s->sysinfo), "SYS_VERSION",
- info->sys_version, &err);
- if (err) {
+ if (!object_property_set_int(OBJECT(&s->sysinfo), "SYS_VERSION",
+ info->sys_version, &err)) {
error_propagate(errp, err);
return;
}
- object_property_set_int(OBJECT(&s->sysinfo), "SYS_CONFIG",
- armsse_sys_config_value(s, info), &err);
- if (err) {
+ if (!object_property_set_int(OBJECT(&s->sysinfo), "SYS_CONFIG",
+ armsse_sys_config_value(s, info), &err)) {
error_propagate(errp, err);
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 */
- object_property_set_int(OBJECT(&s->nmi_orgate), "num-lines", 2, &err);
- if (err) {
+ if (!object_property_set_int(OBJECT(&s->nmi_orgate), "num-lines", 2,
+ &err)) {
error_propagate(errp, err);
return;
}
@@ -1049,8 +1042,7 @@ static void armsse_realize(DeviceState *dev, Error **errp)
for (i = 0; i < ARRAY_SIZE(s->ppc_irq_splitter); i++) {
Object *splitter = OBJECT(&s->ppc_irq_splitter[i]);
- object_property_set_int(splitter, "num-lines", 2, &err);
- if (err) {
+ if (!object_property_set_int(splitter, "num-lines", 2, &err)) {
error_propagate(errp, err);
return;
}
@@ -1095,8 +1087,8 @@ static void armsse_realize(DeviceState *dev, Error **errp)
SplitIRQ *splitter = &s->mpc_irq_splitter[i];
DeviceState *dev_splitter = DEVICE(splitter);
- object_property_set_int(OBJECT(splitter), "num-lines", 2, &err);
- if (err) {
+ if (!object_property_set_int(OBJECT(splitter), "num-lines", 2,
+ &err)) {
error_propagate(errp, err);
return;
}
diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c
index 923f7fad40..2e6dabbbaf 100644
--- a/hw/arm/armv7m.c
+++ b/hw/arm/armv7m.c
@@ -174,31 +174,27 @@ static void armv7m_realize(DeviceState *dev, Error **errp)
&error_abort);
}
if (object_property_find(OBJECT(s->cpu), "init-svtor", NULL)) {
- object_property_set_uint(OBJECT(s->cpu), "init-svtor", s->init_svtor,
- &err);
- if (err != NULL) {
+ if (!object_property_set_uint(OBJECT(s->cpu), "init-svtor",
+ s->init_svtor, &err)) {
error_propagate(errp, err);
return;
}
}
if (object_property_find(OBJECT(s->cpu), "start-powered-off", NULL)) {
- object_property_set_bool(OBJECT(s->cpu), "start-powered-off",
- s->start_powered_off, &err);
- if (err != NULL) {
+ if (!object_property_set_bool(OBJECT(s->cpu), "start-powered-off",
+ s->start_powered_off, &err)) {
error_propagate(errp, err);
return;
}
}
if (object_property_find(OBJECT(s->cpu), "vfp", NULL)) {
- object_property_set_bool(OBJECT(s->cpu), "vfp", s->vfp, &err);
- if (err != NULL) {
+ if (!object_property_set_bool(OBJECT(s->cpu), "vfp", s->vfp, &err)) {
error_propagate(errp, err);
return;
}
}
if (object_property_find(OBJECT(s->cpu), "dsp", NULL)) {
- object_property_set_bool(OBJECT(s->cpu), "dsp", s->dsp, &err);
- if (err != NULL) {
+ if (!object_property_set_bool(OBJECT(s->cpu), "dsp", s->dsp, &err)) {
error_propagate(errp, err);
return;
}
@@ -243,8 +239,8 @@ static void armv7m_realize(DeviceState *dev, Error **errp)
Object *obj = OBJECT(&s->bitband[i]);
SysBusDevice *sbd = SYS_BUS_DEVICE(&s->bitband[i]);
- object_property_set_int(obj, "base", bitband_input_addr[i], &err);
- if (err != NULL) {
+ if (!object_property_set_int(obj, "base",
+ bitband_input_addr[i], &err)) {
error_propagate(errp, err);
return;
}
diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c
index e6e2cf0737..22cbe68449 100644
--- a/hw/arm/aspeed_ast2600.c
+++ b/hw/arm/aspeed_ast2600.c
@@ -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 */
object_property_set_link(OBJECT(&s->fmc), "dram", OBJECT(s->dram_mr),
&error_abort);
- object_property_set_int(OBJECT(&s->fmc), "sdram-base",
- sc->memmap[ASPEED_SDRAM], &err);
- if (err) {
+ if (!object_property_set_int(OBJECT(&s->fmc), "sdram-base",
+ sc->memmap[ASPEED_SDRAM], &err)) {
error_propagate(errp, err);
return;
}
diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
index 27704d87ea..ff5f4d6a52 100644
--- a/hw/arm/aspeed_soc.c
+++ b/hw/arm/aspeed_soc.c
@@ -308,9 +308,8 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
/* FMC, The number of CS is set at the board level */
object_property_set_link(OBJECT(&s->fmc), "dram", OBJECT(s->dram_mr),
&error_abort);
- object_property_set_int(OBJECT(&s->fmc), "sdram-base",
- sc->memmap[ASPEED_SDRAM], &err);
- if (err) {
+ if (!object_property_set_int(OBJECT(&s->fmc), "sdram-base",
+ sc->memmap[ASPEED_SDRAM], &err)) {
error_propagate(errp, err);
return;
}
diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c
index a6ccf3b368..cb724c18e8 100644
--- a/hw/arm/bcm2835_peripherals.c
+++ b/hw/arm/bcm2835_peripherals.c
@@ -222,9 +222,8 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
return;
}
- object_property_set_uint(OBJECT(&s->fb), "vcram-base",
- ram_size - vcram_size, &err);
- if (err) {
+ if (!object_property_set_uint(OBJECT(&s->fb), "vcram-base",
+ ram_size - vcram_size, &err)) {
error_propagate(errp, err);
return;
}
diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c
index 91d31a5cb7..0d373af1a1 100644
--- a/hw/arm/bcm2836.c
+++ b/hw/arm/bcm2836.c
@@ -110,17 +110,17 @@ static void bcm2836_realize(DeviceState *dev, Error **errp)
s->cpu[n].core.mp_affinity = (info->clusterid << 8) | n;
/* set periphbase/CBAR value for CPU-local registers */
- object_property_set_int(OBJECT(&s->cpu[n].core), "reset-cbar",
- info->peri_base, &err);
- if (err) {
+ if (!object_property_set_int(OBJECT(&s->cpu[n].core), "reset-cbar",
+ info->peri_base, &err)) {
error_propagate(errp, err);
return;
}
/* start powered off if not enabled */
- object_property_set_bool(OBJECT(&s->cpu[n].core), "start-powered-off",
- n >= s->enabled_cpus, &err);
- if (err) {
+ if (!object_property_set_bool(OBJECT(&s->cpu[n].core),
+ "start-powered-off",
+ n >= s->enabled_cpus,
+ &err)) {
error_propagate(errp, err);
return;
}
diff --git a/hw/arm/cubieboard.c b/hw/arm/cubieboard.c
index 302919246b..1c6c792eb6 100644
--- a/hw/arm/cubieboard.c
+++ b/hw/arm/cubieboard.c
@@ -62,20 +62,19 @@ static void cubieboard_init(MachineState *machine)
object_property_add_child(OBJECT(machine), "soc", OBJECT(a10));
object_unref(OBJECT(a10));
- object_property_set_int(OBJECT(&a10->emac), "phy-addr", 1, &err);
- if (err != NULL) {
+ if (!object_property_set_int(OBJECT(&a10->emac), "phy-addr", 1, &err)) {
error_reportf_err(err, "Couldn't set phy address: ");
exit(1);
}
- object_property_set_int(OBJECT(&a10->timer), "clk0-freq", 32768, &err);
- if (err != NULL) {
+ if (!object_property_set_int(OBJECT(&a10->timer), "clk0-freq", 32768,
+ &err)) {
error_reportf_err(err, "Couldn't set clk0 frequency: ");
exit(1);
}
- object_property_set_int(OBJECT(&a10->timer), "clk1-freq", 24000000, &err);
- if (err != NULL) {
+ if (!object_property_set_int(OBJECT(&a10->timer), "clk1-freq", 24000000,
+ &err)) {
error_reportf_err(err, "Couldn't set clk1 frequency: ");
exit(1);
}
diff --git a/hw/arm/digic.c b/hw/arm/digic.c
index ffc89d86b8..2306034840 100644
--- a/hw/arm/digic.c
+++ b/hw/arm/digic.c
@@ -56,8 +56,8 @@ static void digic_realize(DeviceState *dev, Error **errp)
SysBusDevice *sbd;
int i;
- object_property_set_bool(OBJECT(&s->cpu), "reset-hivecs", true, &err);
- if (err != NULL) {
+ if (!object_property_set_bool(OBJECT(&s->cpu), "reset-hivecs", true,
+ &err)) {
error_propagate(errp, err);
return;
}
diff --git a/hw/arm/nrf51_soc.c b/hw/arm/nrf51_soc.c
index c440cd11e9..7877d2bf60 100644
--- a/hw/arm/nrf51_soc.c
+++ b/hw/arm/nrf51_soc.c
@@ -106,9 +106,8 @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp)
BASE_TO_IRQ(NRF51_RNG_BASE)));
/* UICR, FICR, NVMC, FLASH */
- object_property_set_uint(OBJECT(&s->nvm), "flash-size", s->flash_size,
- &err);
- if (err) {
+ if (!object_property_set_uint(OBJECT(&s->nvm), "flash-size",
+ s->flash_size, &err)) {
error_propagate(errp, err);
return;
}
@@ -141,8 +140,7 @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp)
/* TIMER */
for (i = 0; i < NRF51_NUM_TIMERS; i++) {
- object_property_set_uint(OBJECT(&s->timer[i]), "id", i, &err);
- if (err) {
+ if (!object_property_set_uint(OBJECT(&s->timer[i]), "id", i, &err)) {
error_propagate(errp, err);
return;
}
diff --git a/hw/arm/stm32f405_soc.c b/hw/arm/stm32f405_soc.c
index 07ce323a64..ddc680bfe0 100644
--- a/hw/arm/stm32f405_soc.c
+++ b/hw/arm/stm32f405_soc.c
@@ -160,10 +160,9 @@ static void stm32f405_soc_realize(DeviceState *dev_soc, Error **errp)
}
/* ADC device, the IRQs are ORed together */
- object_initialize_child_with_props(OBJECT(s), "adc-orirq", &s->adc_irqs,
- sizeof(s->adc_irqs), TYPE_OR_IRQ, &err,
- NULL);
- if (err != NULL) {
+ if (!object_initialize_child_with_props(OBJECT(s), "adc-orirq",
+ &s->adc_irqs, sizeof(s->adc_irqs),
+ TYPE_OR_IRQ, &err, NULL)) {
error_propagate(errp, err);
return;
}
diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c
index e7fe85f1d8..055b778d11 100644
--- a/hw/arm/xlnx-zynqmp.c
+++ b/hw/arm/xlnx-zynqmp.c
@@ -507,18 +507,16 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
* - SDIO Specification Version 3.0
* - eMMC Specification Version 4.51
*/
- object_property_set_uint(sdhci, "sd-spec-version", 3, &err);
- if (err) {
+ if (!object_property_set_uint(sdhci, "sd-spec-version", 3, &err)) {
error_propagate(errp, err);
return;
}
- object_property_set_uint(sdhci, "capareg", SDHCI_CAPABILITIES, &err);
- if (err) {
+ if (!object_property_set_uint(sdhci, "capareg", SDHCI_CAPABILITIES,
+ &err)) {
error_propagate(errp, err);
return;
}
- object_property_set_uint(sdhci, "uhs", UHS_I, &err);
- if (err) {
+ if (!object_property_set_uint(sdhci, "uhs", UHS_I, &err)) {
error_propagate(errp, err);
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]);
for (i = 0; i < XLNX_ZYNQMP_NUM_GDMA_CH; i++) {
- object_property_set_uint(OBJECT(&s->gdma[i]), "bus-width", 128, &err);
- if (err) {
+ if (!object_property_set_uint(OBJECT(&s->gdma[i]), "bus-width", 128,
+ &err)) {
error_propagate(errp, err);
return;
}
diff --git a/hw/block/xen-block.c b/hw/block/xen-block.c
index 0e6e6df5fa..89a4d02a1b 100644
--- a/hw/block/xen-block.c
+++ b/hw/block/xen-block.c
@@ -935,22 +935,21 @@ static void xen_block_device_create(XenBackendInstance *backend,
xendev = XEN_DEVICE(qdev_new(type));
blockdev = XEN_BLOCK_DEVICE(xendev);
- object_property_set_str(OBJECT(xendev), "vdev", vdev, &local_err);
- if (local_err) {
+ if (!object_property_set_str(OBJECT(xendev), "vdev", vdev,
+ &local_err)) {
error_propagate_prepend(errp, local_err, "failed to set 'vdev': ");
goto fail;
}
- object_property_set_str(OBJECT(xendev), "drive",
- xen_block_drive_get_node_name(drive), &local_err);
- if (local_err) {
+ if (!object_property_set_str(OBJECT(xendev), "drive",
+ xen_block_drive_get_node_name(drive),
+ &local_err)) {
error_propagate_prepend(errp, local_err, "failed to set 'drive': ");
goto fail;
}
- object_property_set_str(OBJECT(xendev), "iothread", iothread->id,
- &local_err);
- if (local_err) {
+ if (!object_property_set_str(OBJECT(xendev), "iothread", iothread->id,
+ &local_err)) {
error_propagate_prepend(errp, local_err,
"failed to set 'iothread': ");
goto fail;
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 56daa7b456..ae3b006f39 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -398,8 +398,7 @@ bool qdev_realize(DeviceState *dev, BusState *bus, Error **errp)
assert(!DEVICE_GET_CLASS(dev)->bus_type);
}
- object_property_set_bool(OBJECT(dev), "realized", true, &err);
- if (err) {
+ if (!object_property_set_bool(OBJECT(dev), "realized", true, &err)) {
error_propagate(errp, err);
}
return !err;
diff --git a/hw/i386/x86.c b/hw/i386/x86.c
index 54760197cf..22b524e0ab 100644
--- a/hw/i386/x86.c
+++ b/hw/i386/x86.c
@@ -121,8 +121,7 @@ void x86_cpu_new(X86MachineState *x86ms, int64_t apic_id, Error **errp)
Error *local_err = NULL;
Object *cpu = object_new(MACHINE(x86ms)->cpu_type);
- object_property_set_uint(cpu, "apic-id", apic_id, &local_err);
- if (local_err) {
+ if (!object_property_set_uint(cpu, "apic-id", apic_id, &local_err)) {
goto out;
}
qdev_realize(DEVICE(cpu), NULL, &local_err);
diff --git a/hw/ppc/pnv_psi.c b/hw/ppc/pnv_psi.c
index e23276983f..604788a8eb 100644
--- a/hw/ppc/pnv_psi.c
+++ b/hw/ppc/pnv_psi.c
@@ -505,8 +505,8 @@ static void pnv_psi_power8_realize(DeviceState *dev, Error **errp)
unsigned int i;
/* Create PSI interrupt control source */
- object_property_set_int(OBJECT(ics), "nr-irqs", PSI_NUM_INTERRUPTS, &err);
- if (err) {
+ if (!object_property_set_int(OBJECT(ics), "nr-irqs", PSI_NUM_INTERRUPTS,
+ &err)) {
error_propagate(errp, err);
return;
}
diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
index a7b2a15a96..24de4edfc6 100644
--- a/hw/s390x/s390-pci-bus.c
+++ b/hw/s390x/s390-pci-bus.c
@@ -824,8 +824,7 @@ static S390PCIBusDevice *s390_pci_device_new(S390pciState *s,
return NULL;
}
- object_property_set_str(OBJECT(dev), "target", target, &local_err);
- if (local_err) {
+ if (!object_property_set_str(OBJECT(dev), "target", target, &local_err)) {
object_unparent(OBJECT(dev));
error_propagate_prepend(errp, local_err,
"zPCI device could not be created: ");
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 07609a9a58..1a171f0c96 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -70,8 +70,7 @@ static S390CPU *s390x_new_cpu(const char *typename, uint32_t core_id,
S390CPU *cpu = S390_CPU(object_new(typename));
Error *err = NULL;
- object_property_set_int(OBJECT(cpu), "core-id", core_id, &err);
- if (err != NULL) {
+ if (!object_property_set_int(OBJECT(cpu), "core-id", core_id, &err)) {
goto out;
}
qdev_realize(DEVICE(cpu), NULL, &err);
diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
index 4860863f1d..a83939f7d0 100644
--- a/hw/scsi/scsi-bus.c
+++ b/hw/scsi/scsi-bus.c
@@ -283,8 +283,7 @@ SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockBackend *blk,
object_unparent(OBJECT(dev));
return NULL;
}
- object_property_set_bool(OBJECT(dev), "share-rw", share_rw, &err);
- if (err != NULL) {
+ if (!object_property_set_bool(OBJECT(dev), "share-rw", share_rw, &err)) {
error_propagate(errp, err);
object_unparent(OBJECT(dev));
return NULL;
diff --git a/hw/sd/aspeed_sdhci.c b/hw/sd/aspeed_sdhci.c
index 29aa11df66..687b300773 100644
--- a/hw/sd/aspeed_sdhci.c
+++ b/hw/sd/aspeed_sdhci.c
@@ -132,15 +132,13 @@ static void aspeed_sdhci_realize(DeviceState *dev, Error **errp)
Object *sdhci_slot = OBJECT(&sdhci->slots[i]);
SysBusDevice *sbd_slot = SYS_BUS_DEVICE(&sdhci->slots[i]);
- object_property_set_int(sdhci_slot, "sd-spec-version", 2, &err);
- if (err) {
+ if (!object_property_set_int(sdhci_slot, "sd-spec-version", 2, &err)) {
error_propagate(errp, err);
return;
}
- object_property_set_uint(sdhci_slot, "capareg",
- ASPEED_SDHCI_CAPABILITIES, &err);
- if (err) {
+ if (!object_property_set_uint(sdhci_slot, "capareg",
+ ASPEED_SDHCI_CAPABILITIES, &err)) {
error_propagate(errp, err);
return;
}
diff --git a/hw/sd/ssi-sd.c b/hw/sd/ssi-sd.c
index d4b57cda80..ad825220e2 100644
--- a/hw/sd/ssi-sd.c
+++ b/hw/sd/ssi-sd.c
@@ -261,8 +261,7 @@ static void ssi_sd_realize(SSISlave *d, Error **errp)
}
}
- object_property_set_bool(OBJECT(carddev), "spi", true, &err);
- if (err) {
+ if (!object_property_set_bool(OBJECT(carddev), "spi", true, &err)) {
goto fail;
}
diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c
index 85f7163e2d..8d052fbeed 100644
--- a/hw/virtio/virtio-rng.c
+++ b/hw/virtio/virtio-rng.c
@@ -194,9 +194,8 @@ static void virtio_rng_device_realize(DeviceState *dev, Error **errp)
if (vrng->conf.rng == NULL) {
Object *default_backend = object_new(TYPE_RNG_BUILTIN);
- user_creatable_complete(USER_CREATABLE(default_backend),
- &local_err);
- if (local_err) {
+ if (!user_creatable_complete(USER_CREATABLE(default_backend),
+ &local_err)) {
error_propagate(errp, local_err);
object_unref(default_backend);
return;