[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 63/71] hw: Simplify memory_region_init_ram() calls
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 63/71] hw: Simplify memory_region_init_ram() calls |
Date: |
Fri, 5 Jan 2024 16:42:56 +0100 |
Mechanical change using the following coccinelle script:
@@
expression mr, owner, arg3, arg4, errp;
@@
- memory_region_init_ram(mr, owner, arg3, arg4, &errp);
if (
- errp
+ !memory_region_init_ram(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: Andrew Jeffery <andrew@codeconstruct.com.au> # aspeed
Reviewed-by: Gavin Shan <gshan@redhat.com>
Message-Id: <20231120213301.24349-21-philmd@linaro.org>
---
hw/arm/aspeed_ast2400.c | 6 ++----
hw/arm/aspeed_ast2600.c | 6 ++----
hw/arm/fsl-imx25.c | 6 ++----
hw/arm/fsl-imx31.c | 6 ++----
hw/arm/fsl-imx6.c | 6 ++----
hw/arm/integratorcp.c | 7 ++-----
hw/arm/nrf51_soc.c | 7 ++-----
hw/ppc/rs6000_mc.c | 7 ++-----
8 files changed, 16 insertions(+), 35 deletions(-)
diff --git a/hw/arm/aspeed_ast2400.c b/hw/arm/aspeed_ast2400.c
index a4334c81b8..0baa2ff96e 100644
--- a/hw/arm/aspeed_ast2400.c
+++ b/hw/arm/aspeed_ast2400.c
@@ -247,7 +247,6 @@ static void aspeed_ast2400_soc_realize(DeviceState *dev,
Error **errp)
Aspeed2400SoCState *a = ASPEED2400_SOC(dev);
AspeedSoCState *s = ASPEED_SOC(dev);
AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s);
- Error *err = NULL;
g_autofree char *sram_name = NULL;
/* Default boot region (SPI memory or ROMs) */
@@ -276,9 +275,8 @@ static void aspeed_ast2400_soc_realize(DeviceState *dev,
Error **errp)
/* SRAM */
sram_name = g_strdup_printf("aspeed.sram.%d", CPU(&a->cpu[0])->cpu_index);
- memory_region_init_ram(&s->sram, OBJECT(s), sram_name, sc->sram_size,
&err);
- if (err) {
- error_propagate(errp, err);
+ if (!memory_region_init_ram(&s->sram, OBJECT(s), sram_name, sc->sram_size,
+ errp)) {
return;
}
memory_region_add_subregion(s->memory,
diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c
index b965fbab5e..3a9a303ab8 100644
--- a/hw/arm/aspeed_ast2600.c
+++ b/hw/arm/aspeed_ast2600.c
@@ -282,7 +282,6 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev,
Error **errp)
Aspeed2600SoCState *a = ASPEED2600_SOC(dev);
AspeedSoCState *s = ASPEED_SOC(dev);
AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s);
- Error *err = NULL;
qemu_irq irq;
g_autofree char *sram_name = NULL;
@@ -355,9 +354,8 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev,
Error **errp)
/* SRAM */
sram_name = g_strdup_printf("aspeed.sram.%d", CPU(&a->cpu[0])->cpu_index);
- memory_region_init_ram(&s->sram, OBJECT(s), sram_name, sc->sram_size,
&err);
- if (err) {
- error_propagate(errp, err);
+ if (!memory_region_init_ram(&s->sram, OBJECT(s), sram_name, sc->sram_size,
+ errp)) {
return;
}
memory_region_add_subregion(s->memory,
diff --git a/hw/arm/fsl-imx25.c b/hw/arm/fsl-imx25.c
index 9aabbf7f58..b15435ccaf 100644
--- a/hw/arm/fsl-imx25.c
+++ b/hw/arm/fsl-imx25.c
@@ -299,10 +299,8 @@ static void fsl_imx25_realize(DeviceState *dev, Error
**errp)
&s->rom[1]);
/* initialize internal RAM (128 KB) */
- memory_region_init_ram(&s->iram, NULL, "imx25.iram", FSL_IMX25_IRAM_SIZE,
- &err);
- if (err) {
- error_propagate(errp, err);
+ if (!memory_region_init_ram(&s->iram, NULL, "imx25.iram",
+ FSL_IMX25_IRAM_SIZE, errp)) {
return;
}
memory_region_add_subregion(get_system_memory(), FSL_IMX25_IRAM_ADDR,
diff --git a/hw/arm/fsl-imx31.c b/hw/arm/fsl-imx31.c
index def27bb913..1d5dcd51e8 100644
--- a/hw/arm/fsl-imx31.c
+++ b/hw/arm/fsl-imx31.c
@@ -208,10 +208,8 @@ static void fsl_imx31_realize(DeviceState *dev, Error
**errp)
&s->rom);
/* initialize internal RAM (16 KB) */
- memory_region_init_ram(&s->iram, NULL, "imx31.iram", FSL_IMX31_IRAM_SIZE,
- &err);
- if (err) {
- error_propagate(errp, err);
+ if (!memory_region_init_ram(&s->iram, NULL, "imx31.iram",
+ FSL_IMX31_IRAM_SIZE, errp)) {
return;
}
memory_region_add_subregion(get_system_memory(), FSL_IMX31_IRAM_ADDR,
diff --git a/hw/arm/fsl-imx6.c b/hw/arm/fsl-imx6.c
index 7dc42cbfe6..58f37e7c11 100644
--- a/hw/arm/fsl-imx6.c
+++ b/hw/arm/fsl-imx6.c
@@ -443,10 +443,8 @@ static void fsl_imx6_realize(DeviceState *dev, Error
**errp)
&s->caam);
/* OCRAM memory */
- memory_region_init_ram(&s->ocram, NULL, "imx6.ocram", FSL_IMX6_OCRAM_SIZE,
- &err);
- if (err) {
- error_propagate(errp, err);
+ if (!memory_region_init_ram(&s->ocram, NULL, "imx6.ocram",
+ FSL_IMX6_OCRAM_SIZE, errp)) {
return;
}
memory_region_add_subregion(get_system_memory(), FSL_IMX6_OCRAM_ADDR,
diff --git a/hw/arm/integratorcp.c b/hw/arm/integratorcp.c
index e602ca5e14..1830e1d785 100644
--- a/hw/arm/integratorcp.c
+++ b/hw/arm/integratorcp.c
@@ -291,12 +291,9 @@ static void integratorcm_realize(DeviceState *d, Error
**errp)
{
IntegratorCMState *s = INTEGRATOR_CM(d);
SysBusDevice *dev = SYS_BUS_DEVICE(d);
- Error *local_err = NULL;
- memory_region_init_ram(&s->flash, OBJECT(d), "integrator.flash", 0x100000,
- &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!memory_region_init_ram(&s->flash, OBJECT(d), "integrator.flash",
+ 0x100000, errp)) {
return;
}
diff --git a/hw/arm/nrf51_soc.c b/hw/arm/nrf51_soc.c
index 34da0d62f0..ac53441630 100644
--- a/hw/arm/nrf51_soc.c
+++ b/hw/arm/nrf51_soc.c
@@ -58,7 +58,6 @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error
**errp)
{
NRF51State *s = NRF51_SOC(dev_soc);
MemoryRegion *mr;
- Error *err = NULL;
uint8_t i = 0;
hwaddr base_addr = 0;
@@ -92,10 +91,8 @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error
**errp)
memory_region_add_subregion_overlap(&s->container, 0, s->board_memory, -1);
- memory_region_init_ram(&s->sram, OBJECT(s), "nrf51.sram", s->sram_size,
- &err);
- if (err) {
- error_propagate(errp, err);
+ if (!memory_region_init_ram(&s->sram, OBJECT(s), "nrf51.sram",
s->sram_size,
+ errp)) {
return;
}
memory_region_add_subregion(&s->container, NRF51_SRAM_BASE, &s->sram);
diff --git a/hw/ppc/rs6000_mc.c b/hw/ppc/rs6000_mc.c
index b35f8ba112..e6ec4b4c40 100644
--- a/hw/ppc/rs6000_mc.c
+++ b/hw/ppc/rs6000_mc.c
@@ -143,7 +143,6 @@ static void rs6000mc_realize(DeviceState *dev, Error **errp)
RS6000MCState *s = RS6000MC(dev);
int socket = 0;
unsigned int ram_size = s->ram_size / MiB;
- Error *local_err = NULL;
while (socket < 6) {
if (ram_size >= 64) {
@@ -165,10 +164,8 @@ static void rs6000mc_realize(DeviceState *dev, Error
**errp)
if (s->simm_size[socket]) {
char name[] = "simm.?";
name[5] = socket + '0';
- memory_region_init_ram(&s->simm[socket], OBJECT(dev), name,
- s->simm_size[socket] * MiB, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!memory_region_init_ram(&s->simm[socket], OBJECT(dev), name,
+ s->simm_size[socket] * MiB, errp)) {
return;
}
memory_region_add_subregion_overlap(get_system_memory(), 0,
--
2.41.0
- [PULL 53/71] memory: Have memory_region_init_rom_device() handler return a boolean, (continued)
- [PULL 53/71] memory: Have memory_region_init_rom_device() handler return a boolean, Philippe Mathieu-Daudé, 2024/01/05
- [PULL 54/71] memory: Have memory_region_init_resizeable_ram() return a boolean, Philippe Mathieu-Daudé, 2024/01/05
- [PULL 55/71] memory: Have memory_region_init_ram_from_file() handler return a boolean, Philippe Mathieu-Daudé, 2024/01/05
- [PULL 56/71] memory: Have memory_region_init_ram_from_fd() handler return a boolean, Philippe Mathieu-Daudé, 2024/01/05
- [PULL 57/71] backends: Use g_autofree in HostMemoryBackendClass::alloc() handlers, Philippe Mathieu-Daudé, 2024/01/05
- [PULL 58/71] backends: Simplify host_memory_backend_memory_complete(), Philippe Mathieu-Daudé, 2024/01/05
- [PULL 60/71] backends: Reduce variable scope in host_memory_backend_memory_complete, Philippe Mathieu-Daudé, 2024/01/05
- [PULL 59/71] backends: Have HostMemoryBackendClass::alloc() handler return a boolean, Philippe Mathieu-Daudé, 2024/01/05
- [PULL 61/71] util/oslib: Have qemu_prealloc_mem() handler return a boolean, Philippe Mathieu-Daudé, 2024/01/05
- [PULL 62/71] misc: Simplify qemu_prealloc_mem() calls, Philippe Mathieu-Daudé, 2024/01/05
- [PULL 63/71] hw: Simplify memory_region_init_ram() calls,
Philippe Mathieu-Daudé <=
- [PULL 64/71] hw/arm: Simplify memory_region_init_rom() calls, Philippe Mathieu-Daudé, 2024/01/05
- [PULL 66/71] hw/misc: Simplify memory_region_init_ram_from_fd() calls, Philippe Mathieu-Daudé, 2024/01/05
- [PULL 67/71] hw/nvram: Simplify memory_region_init_rom_device() calls, Philippe Mathieu-Daudé, 2024/01/05
- [PULL 65/71] hw/sparc: Simplify memory_region_init_ram_nomigrate() calls, Philippe Mathieu-Daudé, 2024/01/05
- [PULL 68/71] hw/pci-host/raven: Propagate error in raven_realize(), Philippe Mathieu-Daudé, 2024/01/05
- [PULL 69/71] hw/m68k/mcf5206: Embed m5206_timer_state in m5206_mbar_state, Philippe Mathieu-Daudé, 2024/01/05
- [PULL 70/71] hw/net/can/sja1000: fix bug for single acceptance filter and standard frame, Philippe Mathieu-Daudé, 2024/01/05
- [PULL 71/71] target/sparc: Simplify qemu_irq_ack, Philippe Mathieu-Daudé, 2024/01/05
- Re: [PULL 00/71] HW core patches for 2024-01-05, Philippe Mathieu-Daudé, 2024/01/05