Mechanical change using the following coccinelle script:
@@
expression mr, owner, arg3, arg4, errp;
@@
- memory_region_init_rom(mr, owner, arg3, arg4, &errp);
if (
- errp
+ !memory_region_init_rom(mr, owner, arg3, arg4, &errp)
) {
...
return;
}
and removing the local Error variable.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Reviewed-by: Gavin Shan <gshan@redhat.com>
Message-Id: <20231120213301.24349-22-philmd@linaro.org>
---
hw/arm/fsl-imx25.c | 13 ++++---------
hw/arm/fsl-imx31.c | 13 ++++---------
hw/arm/fsl-imx6.c | 13 ++++---------
3 files changed, 12 insertions(+), 27 deletions(-)
diff --git a/hw/arm/fsl-imx25.c b/hw/arm/fsl-imx25.c
index b15435ccaf..9d2fb75a68 100644
--- a/hw/arm/fsl-imx25.c
+++ b/hw/arm/fsl-imx25.c
@@ -81,7 +81,6 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp)
{
FslIMX25State *s = FSL_IMX25(dev);
uint8_t i;
- Error *err = NULL;
if (!qdev_realize(DEVICE(&s->cpu), NULL, errp)) {
return;
@@ -281,18 +280,14 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp)
FSL_IMX25_WDT_IRQ));
/* initialize 2 x 16 KB ROM */
- memory_region_init_rom(&s->rom[0], OBJECT(dev), "imx25.rom0",
- FSL_IMX25_ROM0_SIZE, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!memory_region_init_rom(&s->rom[0], OBJECT(dev), "imx25.rom0",
+ FSL_IMX25_ROM0_SIZE, errp)) {
return;
}
memory_region_add_subregion(get_system_memory(), FSL_IMX25_ROM0_ADDR,
&s->rom[0]);
- memory_region_init_rom(&s->rom[1], OBJECT(dev), "imx25.rom1",
- FSL_IMX25_ROM1_SIZE, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!memory_region_init_rom(&s->rom[1], OBJECT(dev), "imx25.rom1",
+ FSL_IMX25_ROM1_SIZE, errp)) {
return;
}
memory_region_add_subregion(get_system_memory(), FSL_IMX25_ROM1_ADDR,
diff --git a/hw/arm/fsl-imx31.c b/hw/arm/fsl-imx31.c
index 1d5dcd51e8..c0584e4dfc 100644
--- a/hw/arm/fsl-imx31.c
+++ b/hw/arm/fsl-imx31.c
@@ -63,7 +63,6 @@ static void fsl_imx31_realize(DeviceState *dev, Error **errp)
{
FslIMX31State *s = FSL_IMX31(dev);
uint16_t i;
- Error *err = NULL;
if (!qdev_realize(DEVICE(&s->cpu), NULL, errp)) {
return;
@@ -188,20 +187,16 @@ static void fsl_imx31_realize(DeviceState *dev, Error **errp)
sysbus_mmio_map(SYS_BUS_DEVICE(&s->wdt), 0, FSL_IMX31_WDT_ADDR);
/* On a real system, the first 16k is a `secure boot rom' */
- memory_region_init_rom(&s->secure_rom, OBJECT(dev), "imx31.secure_rom",
- FSL_IMX31_SECURE_ROM_SIZE, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!memory_region_init_rom(&s->secure_rom, OBJECT(dev), "imx31.secure_rom",
+ FSL_IMX31_SECURE_ROM_SIZE, errp)) {
return;
}
memory_region_add_subregion(get_system_memory(), FSL_IMX31_SECURE_ROM_ADDR,
&s->secure_rom);
/* There is also a 16k ROM */
- memory_region_init_rom(&s->rom, OBJECT(dev), "imx31.rom",
- FSL_IMX31_ROM_SIZE, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!memory_region_init_rom(&s->rom, OBJECT(dev), "imx31.rom",
+ FSL_IMX31_ROM_SIZE, errp)) {
return;
}
memory_region_add_subregion(get_system_memory(), FSL_IMX31_ROM_ADDR,
diff --git a/hw/arm/fsl-imx6.c b/hw/arm/fsl-imx6.c
index 58f37e7c11..b2153022c0 100644
--- a/hw/arm/fsl-imx6.c
+++ b/hw/arm/fsl-imx6.c
@@ -109,7 +109,6 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
MachineState *ms = MACHINE(qdev_get_machine());
FslIMX6State *s = FSL_IMX6(dev);
uint16_t i;
- Error *err = NULL;
unsigned int smp_cpus = ms->smp.cpus;
if (smp_cpus > FSL_IMX6_NUM_CPUS) {
@@ -423,20 +422,16 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
}
/* ROM memory */
- memory_region_init_rom(&s->rom, OBJECT(dev), "imx6.rom",
- FSL_IMX6_ROM_SIZE, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!memory_region_init_rom(&s->rom, OBJECT(dev), "imx6.rom",
+ FSL_IMX6_ROM_SIZE, errp)) {
return;
}
memory_region_add_subregion(get_system_memory(), FSL_IMX6_ROM_ADDR,
&s->rom);
/* CAAM memory */
- memory_region_init_rom(&s->caam, OBJECT(dev), "imx6.caam",
- FSL_IMX6_CAAM_MEM_SIZE, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!memory_region_init_rom(&s->caam, OBJECT(dev), "imx6.caam",
+ FSL_IMX6_CAAM_MEM_SIZE, errp)) {
return;
}
memory_region_add_subregion(get_system_memory(), FSL_IMX6_CAAM_MEM_ADDR,
--
2.41.0