Skip to content

Commit

Permalink
v9fs/client.c:Use int ret as the return value to avoid uint32_t not s…
Browse files Browse the repository at this point in the history
…upporting negative values

Summary:
 iModify the return variable in the v9fs_client_walk

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
  • Loading branch information
crafcat7 authored and xiaoxiang781216 committed Jan 2, 2025
1 parent 1f540a9 commit 6f4f50e
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions fs/v9fs/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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;
}

/****************************************************************************
Expand Down

0 comments on commit 6f4f50e

Please sign in to comment.