Patchwork [v2,1/2] Avoid asprintf() which is not available on mingw

login
register
mail settings
Submitter Gerd Hoffmann
Date Aug. 13, 2012, 11:05 a.m.
Message ID <1344855944-28250-2-git-send-email-kraxel@redhat.com>
Download mbox | patch
Permalink /patch/176914/
State New
Headers show

Comments

Gerd Hoffmann - Aug. 13, 2012, 11:05 a.m.
Use g_strdup_printf() instead.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/msix.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)
Stefan Weil - Aug. 13, 2012, 7:31 p.m.
Am 13.08.2012 13:05, schrieb Gerd Hoffmann:
> Use g_strdup_printf() instead.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>   hw/msix.c |    8 ++------
>   1 files changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/hw/msix.c b/hw/msix.c
> index 800fc32..aea340b 100644
> --- a/hw/msix.c
> +++ b/hw/msix.c
> @@ -307,13 +307,9 @@ int msix_init_exclusive_bar(PCIDevice *dev, unsigned short nentries,
>           return -EINVAL;
>       }
>   
> -    if (asprintf(&name, "%s-msix", dev->name) == -1) {
> -        return -ENOMEM;
> -    }
> -
> +    name = g_strdup_printf("%s-msix", dev->name);
>       memory_region_init(&dev->msix_exclusive_bar, name, MSIX_EXCLUSIVE_BAR_SIZE);
> -
> -    free(name);
> +    g_free(name);
>   
>       ret = msix_init(dev, nentries, &dev->msix_exclusive_bar, bar_nr,
>                       MSIX_EXCLUSIVE_BAR_TABLE_OFFSET, &dev->msix_exclusive_bar,

Reviewed-by: Stefan Weil <sw@weilnetz.de>

Patch

diff --git a/hw/msix.c b/hw/msix.c
index 800fc32..aea340b 100644
--- a/hw/msix.c
+++ b/hw/msix.c
@@ -307,13 +307,9 @@  int msix_init_exclusive_bar(PCIDevice *dev, unsigned short nentries,
         return -EINVAL;
     }
 
-    if (asprintf(&name, "%s-msix", dev->name) == -1) {
-        return -ENOMEM;
-    }
-
+    name = g_strdup_printf("%s-msix", dev->name);
     memory_region_init(&dev->msix_exclusive_bar, name, MSIX_EXCLUSIVE_BAR_SIZE);
-
-    free(name);
+    g_free(name);
 
     ret = msix_init(dev, nentries, &dev->msix_exclusive_bar, bar_nr,
                     MSIX_EXCLUSIVE_BAR_TABLE_OFFSET, &dev->msix_exclusive_bar,