diff mbox series

[v2,09/17] hw/ppc/spapr: Replace deprecated sprintf() with g_strdup_printf()

Message ID 20261105125203.40320-10-philmd@oss.qualcomm.com
State New
Headers show
Series buildsys: Replace some deprecated sprintf() | expand

Commit Message

Philippe Mathieu-Daudé Nov. 5, 2026, 12:51 p.m. UTC
Replace sprintf() by safer g_strdup_printf() to format the
node name, silencing -Wdeprecated-declarations produced
by Apple clang 17.0.0.

Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
 hw/ppc/spapr.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Alex Bennée Nov. 5, 2026, 4:08 p.m. UTC | #1
Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> writes:

> Replace sprintf() by safer g_strdup_printf() to format the
> node name, silencing -Wdeprecated-declarations produced
> by Apple clang 17.0.0.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
> ---
>  hw/ppc/spapr.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index 54e3cc3cbe42..6f1a046a425d 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -352,14 +352,13 @@ static void add_str(GString *s, const gchar *s1)
>  static int spapr_dt_memory_node(SpaprMachineState *spapr, void *fdt, int nodeid,
>                                  hwaddr start, hwaddr size)
>  {
> -    char mem_name[32];
> +    g_autofree char *mem_name = g_strdup_printf("memory@%" HWADDR_PRIx, start);
>      uint64_t mem_reg_property[2];
>      int off;
>  
>      mem_reg_property[0] = cpu_to_be64(start);
>      mem_reg_property[1] = cpu_to_be64(size);
>  
> -    sprintf(mem_name, "memory@%" HWADDR_PRIx, start);

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

>      off = fdt_add_subnode(fdt, 0, mem_name);

fun fact, ppc seems to be one of the arches that mixes fdt_add_subnode
with qemu_fdt_add_subnode.

>      _FDT(off);
>      _FDT((fdt_setprop_string(fdt, off, "device_type", "memory")));
diff mbox series

Patch

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 54e3cc3cbe42..6f1a046a425d 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -352,14 +352,13 @@  static void add_str(GString *s, const gchar *s1)
 static int spapr_dt_memory_node(SpaprMachineState *spapr, void *fdt, int nodeid,
                                 hwaddr start, hwaddr size)
 {
-    char mem_name[32];
+    g_autofree char *mem_name = g_strdup_printf("memory@%" HWADDR_PRIx, start);
     uint64_t mem_reg_property[2];
     int off;
 
     mem_reg_property[0] = cpu_to_be64(start);
     mem_reg_property[1] = cpu_to_be64(size);
 
-    sprintf(mem_name, "memory@%" HWADDR_PRIx, start);
     off = fdt_add_subnode(fdt, 0, mem_name);
     _FDT(off);
     _FDT((fdt_setprop_string(fdt, off, "device_type", "memory")));