Newer gcc compiler (version 16.0.0 20260103 (Red Hat 16.0.0-0) (GCC))
detects an unused variable error:
../hw/ppc/vof.c: In function ‘vof_dt_memory_available’:
../hw/ppc/vof.c:642:12: error: variable ‘n’ set but not used [-Werror=unused-but-set-variable=]
Remove 'n'.
Cc: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
---
hw/ppc/vof.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/hw/ppc/vof.c b/hw/ppc/vof.c
index 5ecfc6891047eb63f498fe286d57f52a54c0a0db..fa7b73159a0b476dfc49326139d75cb87ca487c1 100644
--- a/hw/ppc/vof.c
+++ b/hw/ppc/vof.c
@@ -639,7 +639,7 @@ static gint of_claimed_compare_func(gconstpointer a, gconstpointer b)
static void vof_dt_memory_available(void *fdt, GArray *claimed, uint64_t base)
{
- int i, n, offset, proplen = 0, sc, ac;
+ int i, offset, proplen = 0, sc, ac;
target_ulong mem0_end;
const uint8_t *mem0_reg;
g_autofree uint8_t *avail = NULL;
@@ -677,7 +677,7 @@ static void vof_dt_memory_available(void *fdt, GArray *claimed, uint64_t base)
g_assert(claimed->len && (g_array_index(claimed, OfClaimed, 0).start == 0));
avail = g_malloc0(sizeof(uint32_t) * (ac + sc) * claimed->len);
- for (i = 0, n = 0, availcur = avail; i < claimed->len; ++i) {
+ for (i = 0, availcur = avail; i < claimed->len; ++i) {
OfClaimed c = g_array_index(claimed, OfClaimed, i);
uint64_t start, size;
@@ -705,7 +705,6 @@ static void vof_dt_memory_available(void *fdt, GArray *claimed, uint64_t base)
if (size) {
trace_vof_avail(c.start + c.size, c.start + c.size + size, size);
- ++n;
}
}
_FDT((fdt_setprop(fdt, offset, "available", avail, availcur - avail)));
--
2.52.0
On 1/12/26 13:47, Cédric Le Goater wrote:
> Newer gcc compiler (version 16.0.0 20260103 (Red Hat 16.0.0-0) (GCC))
> detects an unused variable error:
>
> ../hw/ppc/vof.c: In function ‘vof_dt_memory_available’:
> ../hw/ppc/vof.c:642:12: error: variable ‘n’ set but not used [-Werror=unused-but-set-variable=]
>
> Remove 'n'.
>
> Cc: Alexey Kardashevskiy <aik@ozlabs.ru>
> Signed-off-by: Cédric Le Goater <clg@redhat.com>
> ---
> hw/ppc/vof.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/hw/ppc/vof.c b/hw/ppc/vof.c
> index 5ecfc6891047eb63f498fe286d57f52a54c0a0db..fa7b73159a0b476dfc49326139d75cb87ca487c1 100644
> --- a/hw/ppc/vof.c
> +++ b/hw/ppc/vof.c
> @@ -639,7 +639,7 @@ static gint of_claimed_compare_func(gconstpointer a, gconstpointer b)
>
> static void vof_dt_memory_available(void *fdt, GArray *claimed, uint64_t base)
> {
> - int i, n, offset, proplen = 0, sc, ac;
> + int i, offset, proplen = 0, sc, ac;
> target_ulong mem0_end;
> const uint8_t *mem0_reg;
> g_autofree uint8_t *avail = NULL;
> @@ -677,7 +677,7 @@ static void vof_dt_memory_available(void *fdt, GArray *claimed, uint64_t base)
> g_assert(claimed->len && (g_array_index(claimed, OfClaimed, 0).start == 0));
>
> avail = g_malloc0(sizeof(uint32_t) * (ac + sc) * claimed->len);
> - for (i = 0, n = 0, availcur = avail; i < claimed->len; ++i) {
> + for (i = 0, availcur = avail; i < claimed->len; ++i) {
> OfClaimed c = g_array_index(claimed, OfClaimed, i);
> uint64_t start, size;
>
> @@ -705,7 +705,6 @@ static void vof_dt_memory_available(void *fdt, GArray *claimed, uint64_t base)
>
> if (size) {
> trace_vof_avail(c.start + c.size, c.start + c.size + size, size);
> - ++n;
> }
> }
> _FDT((fdt_setprop(fdt, offset, "available", avail, availcur - avail)));
Applied to vfio-next.
Thanks,
C.
On 12/1/26 13:47, Cédric Le Goater wrote: > Newer gcc compiler (version 16.0.0 20260103 (Red Hat 16.0.0-0) (GCC)) > detects an unused variable error: > > ../hw/ppc/vof.c: In function ‘vof_dt_memory_available’: > ../hw/ppc/vof.c:642:12: error: variable ‘n’ set but not used [-Werror=unused-but-set-variable=] > > Remove 'n'. > > Cc: Alexey Kardashevskiy <aik@ozlabs.ru> > Signed-off-by: Cédric Le Goater <clg@redhat.com> > --- > hw/ppc/vof.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
© 2016 - 2026 Red Hat, Inc.