9p: use g_new(T, n) instead of g_malloc(sizeof(T) * n)
PATCH 1/2 9p: use g_new(T, n) instead of g_malloc(sizeof(T) * n)
Because it is a recommended coding practice (see HACKING).
--- hw/9pfs/9p.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/9pfs/9p.c +2 -2
@@ -1331,8 +1331,8 @@ static void coroutine_fn v9fs_walk(void *opaque)trace_v9fs_walk (pdu->tag, pdu->id, fid, newfid, nwnames);if (nwnames && nwnames <=P9_MAXWELEM ) { - wnames =g_malloc0 (sizeof (wnames[0 ]) * nwnames); - qids =g_malloc0 (sizeof (qids[0 ]) * nwnames); + wnames =g_new0 (V9fsString, nwnames); + qids =g_new0 (V9fsQID, nwnames);for (i =0 ; i < nwnames; i++) { err =pdu_unmarshal (pdu, offset,"s" , &wnames[i]);if (err <0 ) {
PATCH 2/2 xen/9pfs: use g_new(T, n) instead of g_malloc(sizeof(T) * n)
Because it is a recommended coding practice (see HACKING).
--- hw/9pfs/xen-9p-backend.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
hw/9pfs/xen-9p-backend.c +3 -3
@@ -178,7 +178,7 @@ static void xen_9pfs_init_out_iov_from_pdu(V9fsPDU *pdu,g_free (ring->sg); - ring->sg =g_malloc0 (sizeof (*ring->sg) *2 ); + ring->sg = g_new0(struct iovec, 2);xen_9pfs_out_sg (ring, ring->sg, &num, pdu->idx); *piov = ring->sg; *pniov = num;
@@ -196,7 +196,7 @@ static void xen_9pfs_init_in_iov_from_pdu(V9fsPDU *pdu,g_free (ring->sg); - ring->sg =g_malloc0 (sizeof (*ring->sg) *2 ); + ring->sg = g_new0(struct iovec, 2);xen_9pfs_in_sg (ring, ring->sg, &num, pdu->idx, size); buf_size =iov_size (ring->sg, num);
@@ -368,7 +368,7 @@ static int xen_9pfs_connect(struct XenDevice *xendev)return -1 ; } - xen_9pdev->rings =g_malloc0 (xen_9pdev->num_rings *sizeof (Xen9pfsRing)); + xen_9pdev->rings =g_new0 (Xen9pfsRing, xen_9pdev->num_rings);for (i =0 ; i < xen_9pdev->num_rings; i++) {char *str;int ring_order;
Re: [Qemu-devel] [PATCH for 4.0 2/2] xen/9pfs: use g_new(T, n) instead of g_malloc(sizeof(T) * n)
Quoted 3 lines · Greg Kurz
Because it is a recommended coding practice (see HACKING).
Signed-off-by Greg Kurz <[email protected]>
Signature · 1 line
Anthony PERARD
Quoted 3 lines · Greg Kurz
Because it is a recommended coding practice (see HACKING).
Signed-off-by Greg Kurz <[email protected]>
It would have been nice if there were a cover letter for these two patches, as we would had automatic build test and coding style test ;-).
Signature · 1 line
Anthony PERARD
Quoted 10 lines · On Thu, 29 Nov 2018 16:26:48 +0000 Anthony PERARD <[email protected]>…
Quoted 3 lines · Greg Kurz
Because it is a recommended coding practice (see HACKING).
Signed-off-by Greg Kurz <[email protected]>Reviewed-by Anthony PERARD <[email protected]>It would have been nice if there were a cover letter for these two patches, as we would had automatic build test and coding style test ;-).
Yeah... I had it ready and I simply forgot to pass it to stg mail :-\
I've pushed them to my 9p-next branch, which automatically triggers travis, so I'll have the build test covered at least :)
Thanks for the review !
Cheers,
--
Greg