All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christian Schoenebeck <qemu_oss@crudebyte.com>
To: qemu-devel@nongnu.org, Peter Maydell <peter.maydell@linaro.org>
Cc: Greg Kurz <groug@kaod.org>
Subject: [PULL 8/8] 9pfs: use P9Array in v9fs_walk()
Date: Wed, 27 Oct 2021 15:18:33 +0200	[thread overview]
Message-ID: <7e985780aaab93d2c5be9b62d8d386568dfb071e.1635340713.git.qemu_oss@crudebyte.com> (raw)
In-Reply-To: <cover.1635340713.git.qemu_oss@crudebyte.com>

Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Message-Id: <90c65d1c1ca11c1b434bb981b1fc7966f7711c8f.1633097129.git.qemu_oss@crudebyte.com>
---
 hw/9pfs/9p.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
index 15bb16f466..15b3f4d385 100644
--- a/hw/9pfs/9p.c
+++ b/hw/9pfs/9p.c
@@ -1738,13 +1738,14 @@ static void coroutine_fn v9fs_walk(void *opaque)
     int name_idx;
     g_autofree V9fsQID *qids = NULL;
     int i, err = 0;
-    V9fsPath dpath, path, *pathes = NULL;
+    V9fsPath dpath, path;
+    P9ARRAY_REF(V9fsPath) pathes = NULL;
     uint16_t nwnames;
     struct stat stbuf, fidst;
     g_autofree struct stat *stbufs = NULL;
     size_t offset = 7;
     int32_t fid, newfid;
-    V9fsString *wnames = NULL;
+    P9ARRAY_REF(V9fsString) wnames = NULL;
     V9fsFidState *fidp;
     V9fsFidState *newfidp = NULL;
     V9fsPDU *pdu = opaque;
@@ -1765,10 +1766,10 @@ static void coroutine_fn v9fs_walk(void *opaque)
         goto out_nofid;
     }
     if (nwnames) {
-        wnames = g_new0(V9fsString, nwnames);
+        P9ARRAY_NEW(V9fsString, wnames, nwnames);
         qids   = g_new0(V9fsQID, nwnames);
         stbufs = g_new0(struct stat, nwnames);
-        pathes = g_new0(V9fsPath, nwnames);
+        P9ARRAY_NEW(V9fsPath, pathes, nwnames);
         for (i = 0; i < nwnames; i++) {
             err = pdu_unmarshal(pdu, offset, "s", &wnames[i]);
             if (err < 0) {
@@ -1900,14 +1901,6 @@ out:
     v9fs_path_free(&path);
 out_nofid:
     pdu_complete(pdu, err);
-    if (nwnames && nwnames <= P9_MAXWELEM) {
-        for (name_idx = 0; name_idx < nwnames; name_idx++) {
-            v9fs_string_free(&wnames[name_idx]);
-            v9fs_path_free(&pathes[name_idx]);
-        }
-        g_free(wnames);
-        g_free(pathes);
-    }
 }
 
 static int32_t coroutine_fn get_iounit(V9fsPDU *pdu, V9fsPath *path)
-- 
2.20.1



  parent reply	other threads:[~2021-10-27 14:23 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-27 13:18 [PULL 0/8] 9p queue 2021-10-27 Christian Schoenebeck
2021-10-27 13:18 ` [PULL 4/8] 9pfs: introduce P9Array Christian Schoenebeck
2021-10-27 13:18 ` [PULL 2/8] 9pfs: deduplicate iounit code Christian Schoenebeck
2021-10-27 13:18 ` [PULL 5/8] fsdev/p9array.h: check scalar type in P9ARRAY_NEW() Christian Schoenebeck
2021-10-27 13:18 ` [PULL 7/8] 9pfs: make V9fsPath usable via P9Array API Christian Schoenebeck
2021-10-27 13:18 ` [PULL 3/8] 9pfs: simplify blksize_to_iounit() Christian Schoenebeck
2021-10-27 13:18 ` [PULL 6/8] 9pfs: make V9fsString usable via P9Array API Christian Schoenebeck
2021-10-27 13:18 ` [PULL 1/8] 9pfs: fix wrong I/O block size in Rgetattr Christian Schoenebeck
2021-10-27 13:18 ` Christian Schoenebeck [this message]
2021-10-27 14:05 ` [PULL 0/8] 9p queue 2021-10-27 Christian Schoenebeck
2021-10-27 15:36   ` Philippe Mathieu-Daudé
2021-10-27 16:21     ` Christian Schoenebeck
2021-10-27 16:48       ` Philippe Mathieu-Daudé
2021-10-27 17:29         ` Christian Schoenebeck
2021-10-27 18:11           ` Philippe Mathieu-Daudé
2021-10-27 18:44           ` Richard Henderson
2021-10-28 12:03             ` Christian Schoenebeck
2021-10-27 16:01   ` Greg Kurz
2021-10-27 21:03 ` Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7e985780aaab93d2c5be9b62d8d386568dfb071e.1635340713.git.qemu_oss@crudebyte.com \
    --to=qemu_oss@crudebyte.com \
    --cc=groug@kaod.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.