* [Qemu-devel] [PATCH] xen_disk: avoid use of g_malloc0_n()
@ 2017-09-12 14:24 Jan Beulich
2017-09-12 14:33 ` Paul Durrant
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Jan Beulich @ 2017-09-12 14:24 UTC (permalink / raw)
To: qemu-devel; +Cc: Paul Durrant, Stefano Stabellini, xen-devel
Prefer g_new() / g_new0() to be farther backwards compatible with older
glib versions. As there's no point in zeroing the allocation here (the
loop right afterwards fully initializes the memory), use the former.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/hw/block/xen_disk.c
+++ b/hw/block/xen_disk.c
@@ -1232,7 +1232,7 @@ static int blk_connect(struct XenDevice
return -1;
}
- domids = g_malloc0_n(blkdev->nr_ring_ref, sizeof(uint32_t));
+ domids = g_new(uint32_t, blkdev->nr_ring_ref);
for (i = 0; i < blkdev->nr_ring_ref; i++) {
domids[i] = blkdev->xendev.dom;
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] xen_disk: avoid use of g_malloc0_n()
2017-09-12 14:24 [Qemu-devel] [PATCH] xen_disk: avoid use of g_malloc0_n() Jan Beulich
@ 2017-09-12 14:33 ` Paul Durrant
2017-09-14 16:23 ` Anthony PERARD
2017-09-14 16:56 ` Philippe Mathieu-Daudé
2 siblings, 0 replies; 4+ messages in thread
From: Paul Durrant @ 2017-09-12 14:33 UTC (permalink / raw)
To: 'Jan Beulich', qemu-devel@nongnu.org
Cc: Stefano Stabellini, xen-devel
> -----Original Message-----
> From: Jan Beulich [mailto:JBeulich@suse.com]
> Sent: 12 September 2017 07:24
> To: qemu-devel@nongnu.org
> Cc: Paul Durrant <Paul.Durrant@citrix.com>; Stefano Stabellini
> <sstabellini@kernel.org>; xen-devel <xen-devel@lists.xenproject.org>
> Subject: [PATCH] xen_disk: avoid use of g_malloc0_n()
>
> Prefer g_new() / g_new0() to be farther backwards compatible with older
> glib versions. As there's no point in zeroing the allocation here (the
> loop right afterwards fully initializes the memory), use the former.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
>
> --- a/hw/block/xen_disk.c
> +++ b/hw/block/xen_disk.c
> @@ -1232,7 +1232,7 @@ static int blk_connect(struct XenDevice
> return -1;
> }
>
> - domids = g_malloc0_n(blkdev->nr_ring_ref, sizeof(uint32_t));
> + domids = g_new(uint32_t, blkdev->nr_ring_ref);
> for (i = 0; i < blkdev->nr_ring_ref; i++) {
> domids[i] = blkdev->xendev.dom;
> }
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] xen_disk: avoid use of g_malloc0_n()
2017-09-12 14:24 [Qemu-devel] [PATCH] xen_disk: avoid use of g_malloc0_n() Jan Beulich
2017-09-12 14:33 ` Paul Durrant
@ 2017-09-14 16:23 ` Anthony PERARD
2017-09-14 16:56 ` Philippe Mathieu-Daudé
2 siblings, 0 replies; 4+ messages in thread
From: Anthony PERARD @ 2017-09-14 16:23 UTC (permalink / raw)
To: Jan Beulich; +Cc: qemu-devel, xen-devel, Paul Durrant, Stefano Stabellini
On Tue, Sep 12, 2017 at 08:24:21AM -0600, Jan Beulich wrote:
> Prefer g_new() / g_new0() to be farther backwards compatible with older
> glib versions. As there's no point in zeroing the allocation here (the
> loop right afterwards fully initializes the memory), use the former.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Anthony PERARD <anthony.perard@citrix.com>
> --- a/hw/block/xen_disk.c
> +++ b/hw/block/xen_disk.c
> @@ -1232,7 +1232,7 @@ static int blk_connect(struct XenDevice
> return -1;
> }
>
> - domids = g_malloc0_n(blkdev->nr_ring_ref, sizeof(uint32_t));
> + domids = g_new(uint32_t, blkdev->nr_ring_ref);
> for (i = 0; i < blkdev->nr_ring_ref; i++) {
> domids[i] = blkdev->xendev.dom;
> }
>
>
>
>
--
Anthony PERARD
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] xen_disk: avoid use of g_malloc0_n()
2017-09-12 14:24 [Qemu-devel] [PATCH] xen_disk: avoid use of g_malloc0_n() Jan Beulich
2017-09-12 14:33 ` Paul Durrant
2017-09-14 16:23 ` Anthony PERARD
@ 2017-09-14 16:56 ` Philippe Mathieu-Daudé
2 siblings, 0 replies; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2017-09-14 16:56 UTC (permalink / raw)
To: Jan Beulich, qemu-devel, Marc-André Lureau
Cc: xen-devel, Paul Durrant, Stefano Stabellini
Marc-André can you queue this patch in your gnew series?
On 09/12/2017 11:24 AM, Jan Beulich wrote:
> Prefer g_new() / g_new0() to be farther backwards compatible with older
> glib versions. As there's no point in zeroing the allocation here (the
> loop right afterwards fully initializes the memory), use the former.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>
> --- a/hw/block/xen_disk.c
> +++ b/hw/block/xen_disk.c
> @@ -1232,7 +1232,7 @@ static int blk_connect(struct XenDevice
> return -1;
> }
>
> - domids = g_malloc0_n(blkdev->nr_ring_ref, sizeof(uint32_t));
> + domids = g_new(uint32_t, blkdev->nr_ring_ref);
> for (i = 0; i < blkdev->nr_ring_ref; i++) {
> domids[i] = blkdev->xendev.dom;
> }
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-09-14 16:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-12 14:24 [Qemu-devel] [PATCH] xen_disk: avoid use of g_malloc0_n() Jan Beulich
2017-09-12 14:33 ` Paul Durrant
2017-09-14 16:23 ` Anthony PERARD
2017-09-14 16:56 ` Philippe Mathieu-Daudé
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).