[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 4/7] 9pfs: refactor 'name_idx' -> 'nwalked' in v9fs_walk()
From: |
Christian Schoenebeck |
Subject: |
[PATCH v4 4/7] 9pfs: refactor 'name_idx' -> 'nwalked' in v9fs_walk() |
Date: |
Tue, 15 Mar 2022 11:08:37 +0100 |
The local variable 'name_idx' is used in two loops in function v9fs_walk().
Let the first loop use its own variable 'nwalked' instead, which we will
use in subsequent patch as the number of (requested) path components
successfully walked by background I/O thread.
Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
---
hw/9pfs/9p.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
index a6d6b3f835..298f4e6548 100644
--- a/hw/9pfs/9p.c
+++ b/hw/9pfs/9p.c
@@ -1764,7 +1764,7 @@ static bool same_stat_id(const struct stat *a, const
struct stat *b)
static void coroutine_fn v9fs_walk(void *opaque)
{
- int name_idx;
+ int name_idx, nwalked;
g_autofree V9fsQID *qids = NULL;
int i, err = 0;
V9fsPath dpath, path;
@@ -1842,17 +1842,17 @@ static void coroutine_fn v9fs_walk(void *opaque)
break;
}
stbuf = fidst;
- for (name_idx = 0; name_idx < nwnames; name_idx++) {
+ for (nwalked = 0; nwalked < nwnames; nwalked++) {
if (v9fs_request_cancelled(pdu)) {
err = -EINTR;
break;
}
if (!same_stat_id(&pdu->s->root_st, &stbuf) ||
- strcmp("..", wnames[name_idx].data))
+ strcmp("..", wnames[nwalked].data))
{
err = s->ops->name_to_path(&s->ctx, &dpath,
- wnames[name_idx].data,
- &pathes[name_idx]);
+ wnames[nwalked].data,
+ &pathes[nwalked]);
if (err < 0) {
err = -errno;
break;
@@ -1861,13 +1861,13 @@ static void coroutine_fn v9fs_walk(void *opaque)
err = -EINTR;
break;
}
- err = s->ops->lstat(&s->ctx, &pathes[name_idx], &stbuf);
+ err = s->ops->lstat(&s->ctx, &pathes[nwalked], &stbuf);
if (err < 0) {
err = -errno;
break;
}
- stbufs[name_idx] = stbuf;
- v9fs_path_copy(&dpath, &pathes[name_idx]);
+ stbufs[nwalked] = stbuf;
+ v9fs_path_copy(&dpath, &pathes[nwalked]);
}
}
});
--
2.30.2
- [PATCH v4 0/7] 9pfs: fix 'Twalk' protocol violation, Christian Schoenebeck, 2022/03/15
- [PATCH v4 1/7] tests/9pfs: walk to non-existent dir, Christian Schoenebeck, 2022/03/15
- [PATCH v4 2/7] tests/9pfs: Twalk with nwname=0, Christian Schoenebeck, 2022/03/15
- [PATCH v4 3/7] tests/9pfs: compare QIDs in fs_walk_none() test, Christian Schoenebeck, 2022/03/15
- [PATCH v4 4/7] 9pfs: refactor 'name_idx' -> 'nwalked' in v9fs_walk(),
Christian Schoenebeck <=
- [PATCH v4 5/7] 9pfs: fix 'Twalk' to only send error if no component walked, Christian Schoenebeck, 2022/03/15
- [PATCH v4 7/7] tests/9pfs: check fid being unaffected in fs_walk_2nd_nonexistent, Christian Schoenebeck, 2022/03/15
- [PATCH v4 6/7] tests/9pfs: guard recent 'Twalk' behaviour fix, Christian Schoenebeck, 2022/03/15
- Re: [PATCH v4 0/7] 9pfs: fix 'Twalk' protocol violation, Christian Schoenebeck, 2022/03/29