hw/arm/raspi4b.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-)
The if (acells == 0 || scells == 0) check is redundant in
raspi_add_memory_node, since it is already checked in the call
chain, arm_load_dtb. Also the return value of the function is
not checked/used so it's removed.
Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
---
hw/arm/raspi4b.c | 22 +++++++++-------------
1 file changed, 9 insertions(+), 13 deletions(-)
diff --git a/hw/arm/raspi4b.c b/hw/arm/raspi4b.c
index 20082d5266..4df951a0d8 100644
--- a/hw/arm/raspi4b.c
+++ b/hw/arm/raspi4b.c
@@ -36,9 +36,8 @@ struct Raspi4bMachineState {
* (see https://datasheets.raspberrypi.com/bcm2711/bcm2711-peripherals.pdf
* 1.2 Address Map)
*/
-static int raspi_add_memory_node(void *fdt, hwaddr mem_base, hwaddr mem_len)
+static void raspi_add_memory_node(void *fdt, hwaddr mem_base, hwaddr mem_len)
{
- int ret;
uint32_t acells, scells;
char *nodename = g_strdup_printf("/memory@%" PRIx64, mem_base);
@@ -46,19 +45,16 @@ static int raspi_add_memory_node(void *fdt, hwaddr mem_base, hwaddr mem_len)
NULL, &error_fatal);
scells = qemu_fdt_getprop_cell(fdt, "/", "#size-cells",
NULL, &error_fatal);
- if (acells == 0 || scells == 0) {
- fprintf(stderr, "dtb file invalid (#address-cells or #size-cells 0)\n");
- ret = -1;
- } else {
- qemu_fdt_add_subnode(fdt, nodename);
- qemu_fdt_setprop_string(fdt, nodename, "device_type", "memory");
- ret = qemu_fdt_setprop_sized_cells(fdt, nodename, "reg",
- acells, mem_base,
- scells, mem_len);
- }
+ /* validated by arm_load_dtb */
+ g_assert(acells && scells);
+
+ qemu_fdt_add_subnode(fdt, nodename);
+ qemu_fdt_setprop_string(fdt, nodename, "device_type", "memory");
+ qemu_fdt_setprop_sized_cells(fdt, nodename, "reg",
+ acells, mem_base,
+ scells, mem_len);
g_free(nodename);
- return ret;
}
static void raspi4_modify_dtb(const struct arm_boot_info *info, void *fdt)
--
2.43.0
On Tue, 2 Sept 2025 at 21:08, Osama Abdelkader <osama.abdelkader@gmail.com> wrote: > > The if (acells == 0 || scells == 0) check is redundant in > raspi_add_memory_node, since it is already checked in the call > chain, arm_load_dtb. Also the return value of the function is > not checked/used so it's removed. > > Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com> Applied to target-arm.next, thanks. -- PMM
Osama Abdelkader <osama.abdelkader@gmail.com> writes: > The if (acells == 0 || scells == 0) check is redundant in > raspi_add_memory_node, since it is already checked in the call > chain, arm_load_dtb. Also the return value of the function is > not checked/used so it's removed. > > Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Tested-by: Alex Bennée <alex.bennee@linaro.org> -- Alex Bennée Virtualisation Tech Lead @ Linaro
© 2016 - 2025 Red Hat, Inc.