diff mbox

[v2] hw/vfio/platform: replace g_malloc0_n by g_new0

Message ID 1434012280-23556-1-git-send-email-eric.auger@linaro.org
State Accepted
Commit 0b70743d4f4f260b2fe6ed53fecc6bc6cda13910
Headers show

Commit Message

Auger Eric June 11, 2015, 8:44 a.m. UTC
g_malloc0_n() is introduced since glib-2.24 while QEMU currently
requires glib-2.22. This may cause a link error on some distributions.

Signed-off-by: Eric Auger <eric.auger@linaro.org>

---

v1 -> v2:
- replace g_malloc0 by g_new0
---
 hw/vfio/platform.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Peter Maydell June 11, 2015, 1 p.m. UTC | #1
On 11 June 2015 at 09:44, Eric Auger <eric.auger@linaro.org> wrote:
> g_malloc0_n() is introduced since glib-2.24 while QEMU currently
> requires glib-2.22. This may cause a link error on some distributions.
>
> Signed-off-by: Eric Auger <eric.auger@linaro.org>
>
> ---
>
> v1 -> v2:
> - replace g_malloc0 by g_new0
> ---
>  hw/vfio/platform.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c
> index 35266a8..9382bb7 100644
> --- a/hw/vfio/platform.c
> +++ b/hw/vfio/platform.c
> @@ -346,8 +346,7 @@ static int vfio_populate_device(VFIODevice *vbasedev)
>          return ret;
>      }
>
> -    vdev->regions = g_malloc0_n(vbasedev->num_regions,
> -                                sizeof(VFIORegion *));
> +    vdev->regions = g_new0(VFIORegion *, vbasedev->num_regions);
>
>      for (i = 0; i < vbasedev->num_regions; i++) {
>          struct vfio_region_info reg_info = { .argsz = sizeof(reg_info) };
> --
> 1.8.3.2

This looks like the right fix to me -- if somebody would like to
give it a reviewed-by tag I can apply it to master as a buildfix...

thanks
-- PMM
Peter Maydell June 11, 2015, 1:40 p.m. UTC | #2
On 11 June 2015 at 14:21, Alex Williamson <alex.williamson@redhat.com> wrote:
> On Thu, 2015-06-11 at 14:00 +0100, Peter Maydell wrote:
>> On 11 June 2015 at 09:44, Eric Auger <eric.auger@linaro.org> wrote:
>> > g_malloc0_n() is introduced since glib-2.24 while QEMU currently
>> > requires glib-2.22. This may cause a link error on some distributions.
>> >
>> > Signed-off-by: Eric Auger <eric.auger@linaro.org>
>> >
>> > ---
>> >
>> > v1 -> v2:
>> > - replace g_malloc0 by g_new0
>> > ---
>> >  hw/vfio/platform.c | 3 +--
>> >  1 file changed, 1 insertion(+), 2 deletions(-)
>> >
>> > diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c
>> > index 35266a8..9382bb7 100644
>> > --- a/hw/vfio/platform.c
>> > +++ b/hw/vfio/platform.c
>> > @@ -346,8 +346,7 @@ static int vfio_populate_device(VFIODevice *vbasedev)
>> >          return ret;
>> >      }
>> >
>> > -    vdev->regions = g_malloc0_n(vbasedev->num_regions,
>> > -                                sizeof(VFIORegion *));
>> > +    vdev->regions = g_new0(VFIORegion *, vbasedev->num_regions);
>> >
>> >      for (i = 0; i < vbasedev->num_regions; i++) {
>> >          struct vfio_region_info reg_info = { .argsz = sizeof(reg_info) };
>> > --
>> > 1.8.3.2
>>
>> This looks like the right fix to me -- if somebody would like to
>> give it a reviewed-by tag I can apply it to master as a buildfix...
>
> Thanks Peter
>
> Acked-by: Alex Williamson <alex.williamson@redhat.com>

Applied, thanks.

-- PMM
diff mbox

Patch

diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c
index 35266a8..9382bb7 100644
--- a/hw/vfio/platform.c
+++ b/hw/vfio/platform.c
@@ -346,8 +346,7 @@  static int vfio_populate_device(VFIODevice *vbasedev)
         return ret;
     }
 
-    vdev->regions = g_malloc0_n(vbasedev->num_regions,
-                                sizeof(VFIORegion *));
+    vdev->regions = g_new0(VFIORegion *, vbasedev->num_regions);
 
     for (i = 0; i < vbasedev->num_regions; i++) {
         struct vfio_region_info reg_info = { .argsz = sizeof(reg_info) };