libc/getdelim: Remove __KERNEL__ check since it shouldn't be called inside kernel

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2021-11-18 02:10:30 +08:00 committed by Alan Carvalho de Assis
parent 919aeced30
commit b5f6dcb523
1 changed files with 3 additions and 11 deletions

View File

@ -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
}
/****************************************************************************