[PATCH] ppc/vof: Fix build error

Cédric Le Goater posted 1 patch 3 weeks, 4 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260112124722.1029212-1-clg@redhat.com
Maintainers: Alexey Kardashevskiy <aik@ozlabs.ru>
hw/ppc/vof.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
[PATCH] ppc/vof: Fix build error
Posted by Cédric Le Goater 3 weeks, 4 days ago
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


Re: [PATCH] ppc/vof: Fix build error
Posted by Cédric Le Goater 3 weeks, 4 days ago
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.


Re: [PATCH] ppc/vof: Fix build error
Posted by Philippe Mathieu-Daudé 3 weeks, 4 days ago
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>