diff mbox series

[for,4.0,1/2] 9p: use g_new(T, n) instead of g_malloc(sizeof(T) * n)

Message ID 154350643288.788685.710801848628732800.stgit@bahia.lan
State New
Headers show
Series [for,4.0,1/2] 9p: use g_new(T, n) instead of g_malloc(sizeof(T) * n) | expand

Commit Message

Greg Kurz Nov. 29, 2018, 3:47 p.m. UTC
Because it is a recommended coding practice (see HACKING).

Signed-off-by: Greg Kurz <groug@kaod.org>
---
 hw/9pfs/9p.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Anthony PERARD Nov. 29, 2018, 4:26 p.m. UTC | #1
On Thu, Nov 29, 2018 at 04:47:12PM +0100, Greg Kurz wrote:
> Because it is a recommended coding practice (see HACKING).
> 
> Signed-off-by: Greg Kurz <groug@kaod.org>

Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>

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 ;-).
Greg Kurz Nov. 29, 2018, 4:38 p.m. UTC | #2
On Thu, 29 Nov 2018 16:26:48 +0000
Anthony PERARD <anthony.perard@citrix.com> wrote:

> On Thu, Nov 29, 2018 at 04:47:12PM +0100, Greg Kurz wrote:
> > Because it is a recommended coding practice (see HACKING).
> > 
> > Signed-off-by: Greg Kurz <groug@kaod.org>  
> 
> Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
> 
> 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
diff mbox series

Patch

diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
index bdf7919abfc5..55821343e594 100644
--- a/hw/9pfs/9p.c
+++ b/hw/9pfs/9p.c
@@ -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) {