diff mbox

[v2] xen-disk: use g_new0 to fix build

Message ID 20170728131151.4802-1-olaf@aepfle.de (mailing list archive)
State New, archived
Headers show

Commit Message

Olaf Hering July 28, 2017, 1:11 p.m. UTC
g_malloc0_n is available since glib-2.24. To allow build with older glib
versions use the generic g_new0, which is already used in many other
places in the code.

Fixes commit 3284fad728 ("xen-disk: add support for multi-page shared rings")

Signed-off-by: Olaf Hering <olaf@aepfle.de>
---
 hw/block/xen_disk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Eric Blake July 28, 2017, 7:19 p.m. UTC | #1
On 07/28/2017 08:11 AM, Olaf Hering wrote:
> g_malloc0_n is available since glib-2.24. To allow build with older glib

s/is/is only/

> versions use the generic g_new0, which is already used in many other
> places in the code.
> 
> Fixes commit 3284fad728 ("xen-disk: add support for multi-page shared rings")
> 
> Signed-off-by: Olaf Hering <olaf@aepfle.de>
> ---
>  hw/block/xen_disk.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Eric Blake <eblake@redhat.com>
Philippe Mathieu-Daudé July 28, 2017, 8:49 p.m. UTC | #2
Hi Olaf,

On 07/28/2017 10:11 AM, Olaf Hering wrote:
> g_malloc0_n is available since glib-2.24. To allow build with older glib
> versions use the generic g_new0, which is already used in many other
> places in the code.

Can you provide information about which 
distrib/release/version/[packages?] you used? So we might add the same 
setup in QEMU continuous integration system.

Thank,

Phil.

> 
> Fixes commit 3284fad728 ("xen-disk: add support for multi-page shared rings")
> 
> Signed-off-by: Olaf Hering <olaf@aepfle.de>
> ---
>   hw/block/xen_disk.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/block/xen_disk.c b/hw/block/xen_disk.c
> index d42ed7070d..536e2ee735 100644
> --- a/hw/block/xen_disk.c
> +++ b/hw/block/xen_disk.c
> @@ -1232,7 +1232,7 @@ static int blk_connect(struct XenDevice *xendev)
>           return -1;
>       }
>   
> -    domids = g_malloc0_n(blkdev->nr_ring_ref, sizeof(uint32_t));
> +    domids = g_new0(uint32_t, blkdev->nr_ring_ref);
>       for (i = 0; i < blkdev->nr_ring_ref; i++) {
>           domids[i] = blkdev->xendev.dom;
>       }
>
Peter Maydell July 28, 2017, 9 p.m. UTC | #3
On 28 July 2017 at 21:49, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
> Hi Olaf,
>
> On 07/28/2017 10:11 AM, Olaf Hering wrote:
>>
>> g_malloc0_n is available since glib-2.24. To allow build with older glib
>> versions use the generic g_new0, which is already used in many other
>> places in the code.
>
>
> Can you provide information about which distrib/release/version/[packages?]
> you used? So we might add the same setup in QEMU continuous integration
> system.

I do have a build system with our oldest supported glib
version (it's my OSX box), and I have a feeling one of the
patchew centos configs does this too, but I guess neither
of them have the Xen headers to enable the Xen code,
which is why this one slipped through.

thanks
-- PMM
Stefano Stabellini July 28, 2017, 10:29 p.m. UTC | #4
On Fri, 28 Jul 2017, Philippe Mathieu-Daudé wrote:
> Hi Olaf,
> 
> On 07/28/2017 10:11 AM, Olaf Hering wrote:
> > g_malloc0_n is available since glib-2.24. To allow build with older glib
> > versions use the generic g_new0, which is already used in many other
> > places in the code.
> 
> Can you provide information about which distrib/release/version/[packages?]
> you used? So we might add the same setup in QEMU continuous integration
> system.

FYI http://marc.info/?l=qemu-devel&m=150113545516942&w=2



> > 
> > Fixes commit 3284fad728 ("xen-disk: add support for multi-page shared
> > rings")
> > 
> > Signed-off-by: Olaf Hering <olaf@aepfle.de>
> > ---
> >   hw/block/xen_disk.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/hw/block/xen_disk.c b/hw/block/xen_disk.c
> > index d42ed7070d..536e2ee735 100644
> > --- a/hw/block/xen_disk.c
> > +++ b/hw/block/xen_disk.c
> > @@ -1232,7 +1232,7 @@ static int blk_connect(struct XenDevice *xendev)
> >           return -1;
> >       }
> >   -    domids = g_malloc0_n(blkdev->nr_ring_ref, sizeof(uint32_t));
> > +    domids = g_new0(uint32_t, blkdev->nr_ring_ref);
> >       for (i = 0; i < blkdev->nr_ring_ref; i++) {
> >           domids[i] = blkdev->xendev.dom;
> >       }
> > 
>
Stefano Stabellini July 28, 2017, 10:32 p.m. UTC | #5
On Fri, 28 Jul 2017, Olaf Hering wrote:
> g_malloc0_n is available since glib-2.24. To allow build with older glib
> versions use the generic g_new0, which is already used in many other
> places in the code.
> 
> Fixes commit 3284fad728 ("xen-disk: add support for multi-page shared rings")
> 
> Signed-off-by: Olaf Hering <olaf@aepfle.de>

Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>

I'll add it to my queue


> ---
>  hw/block/xen_disk.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/block/xen_disk.c b/hw/block/xen_disk.c
> index d42ed7070d..536e2ee735 100644
> --- a/hw/block/xen_disk.c
> +++ b/hw/block/xen_disk.c
> @@ -1232,7 +1232,7 @@ static int blk_connect(struct XenDevice *xendev)
>          return -1;
>      }
>  
> -    domids = g_malloc0_n(blkdev->nr_ring_ref, sizeof(uint32_t));
> +    domids = g_new0(uint32_t, blkdev->nr_ring_ref);
>      for (i = 0; i < blkdev->nr_ring_ref; i++) {
>          domids[i] = blkdev->xendev.dom;
>      }
>
diff mbox

Patch

diff --git a/hw/block/xen_disk.c b/hw/block/xen_disk.c
index d42ed7070d..536e2ee735 100644
--- a/hw/block/xen_disk.c
+++ b/hw/block/xen_disk.c
@@ -1232,7 +1232,7 @@  static int blk_connect(struct XenDevice *xendev)
         return -1;
     }
 
-    domids = g_malloc0_n(blkdev->nr_ring_ref, sizeof(uint32_t));
+    domids = g_new0(uint32_t, blkdev->nr_ring_ref);
     for (i = 0; i < blkdev->nr_ring_ref; i++) {
         domids[i] = blkdev->xendev.dom;
     }