Skip to contentSkip to conversation

xen-disk: use g_new0 to fix build

PATCH In review Olaf Hering 5 participants 10 messages Jul 28, 2017

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 xen-disk: use g_new0 to fix build

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")

---
 hw/block/xen_disk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/block/xen_disk.c +1 -1
index d42ed7070d..536e2ee735 100644
@@ -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;
     }
Reviewed-by on v2 1/1
#1 lore raw
Quoted 1 line · Olaf Hering

g_malloc0_n is available since glib-2.24. To allow build with older glib

s/is/is only/

Quoted 9 lines

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")

---
 hw/block/xen_disk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

Reviewed-by on v2 1/1
#2 lore raw
In reply to Olaf Hering
Quoted 1 line · Olaf Hering

g_malloc0_n is available since glib-2.24. To allow build with older glib

s/is/is only/

Quoted 9 lines

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")

---
 hw/block/xen_disk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#3 lore raw
In reply to Olaf Hering

Hi Olaf,

Quoted 3 lines · Olaf Hering

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.

Quoted 14 lines

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

---
  hw/block/xen_disk.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
hw/block/xen_disk.c +0 -0
index d42ed7070d..536e2ee735 100644

hw/block/xen_disk.c static int blk_connect(struct XenDevice *xendev) · line 1238

Quoted 8 lines
hw/block/xen_disk.c +1 -1
@@ -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;
      }

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#4 lore raw
In reply to Olaf Hering

Hi Olaf,

Quoted 3 lines · Olaf Hering

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.

Quoted 22 lines

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

---
  hw/block/xen_disk.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
hw/block/xen_disk.c +1 -1
index d42ed7070d..536e2ee735 100644
@@ -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;
      }
#5 lore raw
Quoted 4 lines · Philippe Mathieu-Daudé

Hi Olaf,

Quoted 1 line · Olaf Hering
Quoted 8 lines
Quoted 3 lines

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

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#6 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 10 lines · Philippe Mathieu-Daudé

Hi Olaf,

Quoted 3 lines · Olaf Hering

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

Quoted 9 lines
Quoted 9 lines

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

---
  hw/block/xen_disk.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 14 lines

hw/block/xen_disk.c static int blk_connect(struct XenDevice *xendev) · line 1238

Quoted 13 lines
hw/block/xen_disk.c +1 -0
index d42ed7070d..536e2ee735 100644
@@ -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;
      }

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#7 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 10 lines · Philippe Mathieu-Daudé

Hi Olaf,

Quoted 3 lines · Olaf Hering

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

Quoted 23 lines
Quoted 22 lines

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

---
  hw/block/xen_disk.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
hw/block/xen_disk.c +1 -0
index d42ed7070d..536e2ee735 100644
@@ -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;
      }
Reviewed-by on v2 1/1
#8 lore raw
In reply to Olaf Hering
Quoted 7 lines · Olaf Hering

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")

I'll add it to my queue

Quoted 10 lines
---
 hw/block/xen_disk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/block/xen_disk.c +0 -0
index d42ed7070d..536e2ee735 100644

hw/block/xen_disk.c static int blk_connect(struct XenDevice *xendev) · line 1238

Quoted 8 lines
hw/block/xen_disk.c +1 -1
@@ -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;
     }

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

Reviewed-by on v2 1/1
#9 lore raw
In reply to Olaf Hering
Quoted 7 lines · Olaf Hering

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")

I'll add it to my queue

Quoted 18 lines
---
 hw/block/xen_disk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/block/xen_disk.c +1 -1
index d42ed7070d..536e2ee735 100644
@@ -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;
     }