You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2021/11/27 19:07:47 UTC
[incubator-nuttx] 01/02: libc/getdelim: Remove __KERNEL__ check since it shouldn't be called inside kernel
This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit b5f6dcb5237dcb1abefb559f8f35dc07b6d2aa72
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Thu Nov 18 02:10:30 2021 +0800
libc/getdelim: Remove __KERNEL__ check since it shouldn't be called inside kernel
Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
libs/libc/stdio/lib_getdelim.c | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)
diff --git a/libs/libc/stdio/lib_getdelim.c b/libs/libc/stdio/lib_getdelim.c
index 2da53d2..2704955 100644
--- a/libs/libc/stdio/lib_getdelim.c
+++ b/libs/libc/stdio/lib_getdelim.c
@@ -107,7 +107,7 @@ ssize_t getdelim(FAR char **lineptr, size_t *n, int delimiter,
if (lineptr == NULL || n == NULL || stream == NULL)
{
- ret = -EINVAL;
+ ret = EINVAL;
goto errout;
}
@@ -138,7 +138,7 @@ ssize_t getdelim(FAR char **lineptr, size_t *n, int delimiter,
dest = (FAR char *)lib_malloc(bufsize);
if (dest == NULL)
{
- ret = -ENOMEM;
+ ret = ENOMEM;
goto errout;
}
@@ -188,13 +188,9 @@ ssize_t getdelim(FAR char **lineptr, size_t *n, int delimiter,
ch = fgetc(stream);
if (ch == EOF)
{
-#ifdef __KERNEL_
- return -ENODATA;
-#else
/* errno is not set in this case */
return -1;
-#endif
}
/* Save the character in the user buffer and increment the number of
@@ -218,12 +214,8 @@ ssize_t getdelim(FAR char **lineptr, size_t *n, int delimiter,
return ncopied;
errout:
-#ifdef __KERNEL_
- return ret;
-#else
- set_errno(-ret);
+ set_errno(ret);
return -1;
-#endif
}
/****************************************************************************