This is an automated email from the ASF dual-hosted git repository.
linguini pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 20c9ff679c3 fs/mmap/fs_mmap.c: fix errno when fd is not valid
20c9ff679c3 is described below
commit 20c9ff679c394024d4173287e24144d5cc26bcf3
Author: p-szafonimateusz <[email protected]>
AuthorDate: Thu Sep 25 13:24:36 2025 +0200
fs/mmap/fs_mmap.c: fix errno when fd is not valid
mmap() should return EBADF errno when fd is not valid.
We can just return error code from file_get().
Signed-off-by: p-szafonimateusz <[email protected]>
---
fs/mmap/fs_mmap.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/fs/mmap/fs_mmap.c b/fs/mmap/fs_mmap.c
index d58ea4cfdb2..65e757749ea 100644
--- a/fs/mmap/fs_mmap.c
+++ b/fs/mmap/fs_mmap.c
@@ -287,10 +287,9 @@ FAR void *mmap(FAR void *start, size_t length, int prot,
int flags,
FAR void *mapped = NULL;
int ret;
- if (fd != -1 && file_get(fd, &filep) < 0)
+ if (fd != -1 && (ret = file_get(fd, &filep)) < 0)
{
- ferr("ERROR: fd:%d referred file whose type is not supported\n", fd);
- ret = -ENODEV;
+ ferr("ERROR: fd:%d referred file is not valid\n", fd);
goto errout;
}