[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 32/32] hw/sparc/leon3: Fix wrong usage of DO_UPCAST macro
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 32/32] hw/sparc/leon3: Fix wrong usage of DO_UPCAST macro |
Date: |
Thu, 22 Feb 2024 13:55:16 +0100 |
From: Thomas Huth <thuth@redhat.com>
leon3.c currently fails to compile with some compilers when the -Wvla
option has been enabled:
../hw/sparc/leon3.c: In function ‘leon3_cpu_reset’:
../hw/sparc/leon3.c:153:5: error: ISO C90 forbids variable length array
‘offset_must_be_zero’ [-Werror=vla]
153 | ResetData *s = (ResetData *)DO_UPCAST(ResetData, info[id], info);
| ^~~~~~~~~
cc1: all warnings being treated as errors
Looking at this code, the DO_UPCAST macro is indeed used in a wrong way
here: DO_UPCAST is supposed to check that the second parameter is the
first entry of the struct that the first parameter indicates, but since
we use and index into the info[] array, this of course cannot work.
The intention here was likely rather to use the container_of() macro
instead, so switch the code accordingly.
Fixes: d65aba8286 ("hw/sparc/leon3: implement multiprocessor")
Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20240221180751.190489-1-thuth@redhat.com>
Tested-by: Clément Chigot <chigot@adacore.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/sparc/leon3.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/sparc/leon3.c b/hw/sparc/leon3.c
index 4873b59b6c..6aaa04cb19 100644
--- a/hw/sparc/leon3.c
+++ b/hw/sparc/leon3.c
@@ -150,7 +150,7 @@ static void leon3_cpu_reset(void *opaque)
{
struct CPUResetData *info = (struct CPUResetData *) opaque;
int id = info->id;
- ResetData *s = (ResetData *)DO_UPCAST(ResetData, info[id], info);
+ ResetData *s = container_of(info, ResetData, info[id]);
CPUState *cpu = CPU(s->info[id].cpu);
CPUSPARCState *env = cpu_env(cpu);
--
2.41.0
- [PULL 02/32] hw/sysbus: Inline and remove sysbus_add_io(), Philippe Mathieu-Daudé, 2024/02/22
- [PULL 07/32] hw/ppc/spapr_cpu: Use qdev_is_realized() instead of QOM API, Philippe Mathieu-Daudé, 2024/02/22
- [PULL 08/32] hw/ppc/pnv_bmc: Use qdev_new() instead of QOM API, Philippe Mathieu-Daudé, 2024/02/22
- [PULL 19/32] hw/i386/pc_sysfw: Use qdev_is_realized() instead of QOM API, Philippe Mathieu-Daudé, 2024/02/22
- [PULL 22/32] hw/acpi: Include missing 'qapi/qapi-types-acpi.h' generated header, Philippe Mathieu-Daudé, 2024/02/22
- [PULL 09/32] hw/tricore/testboard: Use qdev_new() instead of QOM basic API, Philippe Mathieu-Daudé, 2024/02/22
- [PULL 23/32] hw/acpi/cpu: Use CPUState typedef, Philippe Mathieu-Daudé, 2024/02/22
- [PULL 24/32] hw/acpi/ich9_tco: Include missing 'migration/vmstate.h' header, Philippe Mathieu-Daudé, 2024/02/22
- [PULL 32/32] hw/sparc/leon3: Fix wrong usage of DO_UPCAST macro,
Philippe Mathieu-Daudé <=
- [PULL v2 00/32] Misc HW patches for 2024-02-22, Philippe Mathieu-Daudé, 2024/02/22