diff mbox series

[v2,08/17] hw/vfio/pci: Replace deprecated sprintf() with g_strdup_printf()

Message ID 20261105125203.40320-9-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
host address, silencing -Wdeprecated-declarations produced
by Apple clang 17.0.0.

Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
 hw/vfio/pci.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Comments

Cédric Le Goater Nov. 5, 2026, 1:25 p.m. UTC | #1
On 11/5/26 13:51, Philippe Mathieu-Daudé wrote:
> Replace sprintf() by safer g_strdup_printf() to format the
> host address, silencing -Wdeprecated-declarations produced
> by Apple clang 17.0.0.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
> ---
>   hw/vfio/pci.c | 7 +++----
>   1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
> index 0da2e143b88a..eea96240b7c9 100644
> --- a/hw/vfio/pci.c
> +++ b/hw/vfio/pci.c
> @@ -2857,10 +2857,9 @@ void vfio_pci_post_reset(VFIOPCIDevice *vdev)
>   
>   bool vfio_pci_host_match(PCIHostDeviceAddress *addr, const char *name)
>   {
> -    char tmp[36];
> -
> -    sprintf(tmp, "%04x:%02x:%02x.%1x", addr->domain,
> -            addr->bus, addr->slot, addr->function);
> +    g_autofree char *tmp = g_strdup_printf("%04x:%02x:%02x.%1x",
> +                                           addr->domain, addr->bus, addr->slot,
> +                                           addr->function);
>   
>       return (strcmp(tmp, name) == 0);
>   }

Reviewed-by: Cédric Le Goater <clg@redhat.com>

Thanks,

C.
diff mbox series

Patch

diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 0da2e143b88a..eea96240b7c9 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -2857,10 +2857,9 @@  void vfio_pci_post_reset(VFIOPCIDevice *vdev)
 
 bool vfio_pci_host_match(PCIHostDeviceAddress *addr, const char *name)
 {
-    char tmp[36];
-
-    sprintf(tmp, "%04x:%02x:%02x.%1x", addr->domain,
-            addr->bus, addr->slot, addr->function);
+    g_autofree char *tmp = g_strdup_printf("%04x:%02x:%02x.%1x",
+                                           addr->domain, addr->bus, addr->slot,
+                                           addr->function);
 
     return (strcmp(tmp, name) == 0);
 }