From: Christian Schoenebeck <qemu_oss@crudebyte.com>
To: qemu-devel@nongnu.org
Cc: Greg Kurz <groug@kaod.org>,
Richard Henderson <richard.henderson@linaro.org>,
Markus Armbruster <armbru@redhat.com>
Subject: [PATCH v3 5/5] 9pfs: use QArray in v9fs_walk()
Date: Thu, 26 Aug 2021 14:32:09 +0200 [thread overview]
Message-ID: <62f08c3c6e1e4f669b034af831dd898aed9a902c.1629982046.git.qemu_oss@crudebyte.com> (raw)
In-Reply-To: <cover.1629982046.git.qemu_oss@crudebyte.com>
Signed-off-by: Christian Schoenebeck <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 b59572fa79..9275c23df0 100644
--- a/hw/9pfs/9p.c
+++ b/hw/9pfs/9p.c
@@ -1707,13 +1707,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;
+ QARRAY_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;
+ QARRAY_REF(V9fsString) wnames = NULL;
V9fsFidState *fidp;
V9fsFidState *newfidp = NULL;
V9fsPDU *pdu = opaque;
@@ -1734,10 +1735,10 @@ static void coroutine_fn v9fs_walk(void *opaque)
goto out_nofid;
}
if (nwnames) {
- wnames = g_new0(V9fsString, nwnames);
+ QARRAY_CREATE(V9fsString, wnames, nwnames);
qids = g_new0(V9fsQID, nwnames);
stbufs = g_new0(struct stat, nwnames);
- pathes = g_new0(V9fsPath, nwnames);
+ QARRAY_CREATE(V9fsPath, pathes, nwnames);
for (i = 0; i < nwnames; i++) {
err = pdu_unmarshal(pdu, offset, "s", &wnames[i]);
if (err < 0) {
@@ -1869,14 +1870,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
next prev parent reply other threads:[~2021-08-26 13:20 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-26 12:47 [PATCH v3 0/5] introduce QArray Christian Schoenebeck
2021-08-26 12:30 ` [PATCH v3 1/5] qemu/qarray.h: " Christian Schoenebeck
2021-08-26 12:31 ` [PATCH v3 2/5] qemu/qarray.h: check scalar type in QARRAY_CREATE() Christian Schoenebeck
2021-08-26 12:31 ` [PATCH v3 3/5] 9pfs: make V9fsString usable via QArray API Christian Schoenebeck
2021-08-26 12:31 ` [PATCH v3 4/5] 9pfs: make V9fsPath " Christian Schoenebeck
2021-08-26 12:32 ` Christian Schoenebeck [this message]
2021-08-31 11:58 ` [PATCH v3 0/5] introduce QArray Greg Kurz
2021-08-31 12:25 ` Christian Schoenebeck
2021-09-27 10:35 ` Christian Schoenebeck
2021-09-27 10:59 ` Greg Kurz
2021-09-28 12:25 ` Christian Schoenebeck
2021-09-28 13:37 ` Alex Bennée
2021-09-28 16:37 ` Christian Schoenebeck
2021-09-28 14:17 ` Daniel P. Berrangé
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=62f08c3c6e1e4f669b034af831dd898aed9a902c.1629982046.git.qemu_oss@crudebyte.com \
--to=qemu_oss@crudebyte.com \
--cc=armbru@redhat.com \
--cc=groug@kaod.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.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 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).