summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
Diffstat (limited to 'components')
-rw-r--r--components/dfs/dfs_v2/filesystems/tmpfs/dfs_tmpfs.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/components/dfs/dfs_v2/filesystems/tmpfs/dfs_tmpfs.c b/components/dfs/dfs_v2/filesystems/tmpfs/dfs_tmpfs.c
index 8644f51c26..1c2a509475 100644
--- a/components/dfs/dfs_v2/filesystems/tmpfs/dfs_tmpfs.c
+++ b/components/dfs/dfs_v2/filesystems/tmpfs/dfs_tmpfs.c
@@ -294,18 +294,17 @@ find_subpath:
static ssize_t dfs_tmpfs_read(struct dfs_file *file, void *buf, size_t count, off_t *pos)
{
- rt_size_t length;
+ ssize_t length;
struct tmpfs_file *d_file;
-
d_file = (struct tmpfs_file *)file->vnode->data;
RT_ASSERT(d_file != NULL);
rt_mutex_take(&file->vnode->lock, RT_WAITING_FOREVER);
-
- if (count < file->vnode->size - *pos)
+ ssize_t size = (ssize_t)file->vnode->size;
+ if ((ssize_t)count < size - *pos)
length = count;
else
- length = file->vnode->size - *pos;
+ length = size - *pos;
if (length > 0)
memcpy(buf, &(d_file->data[*pos]), length);