From 6f4f50e2fe09ab9292a4133a39f7d1cbf44e80bc Mon Sep 17 00:00:00 2001 From: chenrun1 Date: Fri, 11 Oct 2024 12:23:24 +0800 Subject: [PATCH] v9fs/client.c:Use int ret as the return value to avoid uint32_t not supporting negative values Summary: iModify the return variable in the v9fs_client_walk Signed-off-by: chenrun1 --- fs/v9fs/client.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/fs/v9fs/client.c b/fs/v9fs/client.c index a93f3ecf38..b6823d1b83 100644 --- a/fs/v9fs/client.c +++ b/fs/v9fs/client.c @@ -1465,7 +1465,7 @@ int v9fs_client_walk(FAR struct v9fs_client_s *client, FAR const char *path, struct iovec wiov[2]; struct iovec riov[2]; uint16_t nwname = 0; - uint32_t newfid; + uint32_t newfid = V9FS_NOFID; size_t total_len = 0; size_t offset = 0; size_t name_len; @@ -1526,12 +1526,13 @@ int v9fs_client_walk(FAR struct v9fs_client_s *client, FAR const char *path, return -ENOMEM; } - newfid = v9fs_fid_create(client, path); - if (newfid < 0) + ret = v9fs_fid_create(client, path); + if (ret < 0) { goto err; } + newfid = ret; request.header.size = V9FS_HDRSZ + V9FS_BIT32SZ * 2 + V9FS_BIT16SZ + total_len; request.header.type = V9FS_TWALK; @@ -1586,7 +1587,7 @@ int v9fs_client_walk(FAR struct v9fs_client_s *client, FAR const char *path, if (ret < 0) { v9fs_fid_destroy(client, newfid); - newfid = ret; + goto err; } /* There are differences in different server implementations, so it is @@ -1596,13 +1597,13 @@ int v9fs_client_walk(FAR struct v9fs_client_s *client, FAR const char *path, if (response.nwqid != nwname) { - newfid = -ENOENT; + ret = -ENOENT; } err: lib_put_pathbuffer(request_payload); lib_put_pathbuffer(response_payload); - return newfid; + return ret == 0 ? newfid : ret; } /****************************************************************************