From b5f6dcb5237dcb1abefb559f8f35dc07b6d2aa72 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Thu, 18 Nov 2021 02:10:30 +0800 Subject: [PATCH] libc/getdelim: Remove __KERNEL__ check since it shouldn't be called inside kernel Signed-off-by: Xiang Xiao --- 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 2da53d245e..2704955f1e 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 } /****************************************************************************