libc: Change errno to set_errno and get_errno
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
f911d3a1c3
commit
7aad7eebff
@ -96,8 +96,8 @@ ssize_t aio_return(FAR struct aiocb *aiocbp)
|
||||
DEBUGASSERT(aiocbp);
|
||||
if (aiocbp->aio_result < 0)
|
||||
{
|
||||
set_errno((int)-aiocbp->aio_result);
|
||||
return (ssize_t)ERROR;
|
||||
set_errno(-aiocbp->aio_result);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
ret = aiocbp->aio_result;
|
||||
|
@ -616,10 +616,10 @@ static ssize_t gdb_hex2bin(FAR void *buf, size_t buf_len,
|
||||
};
|
||||
|
||||
out[pos / 2] = strtoul(ch, NULL, 16); /* Decode high nibble */
|
||||
if (out[pos / 2] == 0 && errno)
|
||||
if (out[pos / 2] == 0 && get_errno())
|
||||
{
|
||||
GDB_ASSERT();
|
||||
return -errno; /* Buffer contained junk. */
|
||||
return -get_errno(); /* Buffer contained junk. */
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -337,7 +337,7 @@ iconv_t iconv_open(FAR const char *to, FAR const char *from)
|
||||
if ((t = find_charmap(to)) == -1 || (f = find_charmap(from)) == -1 ||
|
||||
(g_charmaps[t] >= 0330))
|
||||
{
|
||||
errno = EINVAL;
|
||||
set_errno(EINVAL);
|
||||
return (iconv_t)-1;
|
||||
}
|
||||
|
||||
@ -354,7 +354,7 @@ iconv_t iconv_open(FAR const char *to, FAR const char *from)
|
||||
scd = lib_malloc(sizeof(*scd));
|
||||
if (scd == NULL)
|
||||
{
|
||||
errno = ENOMEM;
|
||||
set_errno(ENOMEM);
|
||||
return (iconv_t)-1;
|
||||
}
|
||||
|
||||
@ -1435,7 +1435,7 @@ starved:
|
||||
err = EINVAL;
|
||||
x = -1;
|
||||
end:
|
||||
errno = err;
|
||||
set_errno(err);
|
||||
return x;
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ do \
|
||||
|
||||
void vwarn(FAR const char *fmt, va_list ap)
|
||||
{
|
||||
int error = errno;
|
||||
int error = get_errno();
|
||||
struct va_format vaf;
|
||||
|
||||
#ifdef va_copy
|
||||
|
@ -136,7 +136,7 @@ int android_fdsan_close_with_tag(int fd, uint64_t expected_tag)
|
||||
* If we were expecting to close with a tag, abort on EBADF.
|
||||
**************************************************************************/
|
||||
|
||||
if (expected_tag && ret == -1 && errno == EBADF)
|
||||
if (expected_tag && ret == -1 && get_errno() == EBADF)
|
||||
{
|
||||
ferr("double-close of file descriptor %d detected\n", fd);
|
||||
PANIC();
|
||||
|
@ -247,7 +247,8 @@ static int do_glob(FAR char *buf, size_t pos, int type, FAR char *pat,
|
||||
|
||||
if (!type && lstat(buf, &st))
|
||||
{
|
||||
if (errno != ENOENT && (errfunc(buf, errno) || (flags & GLOB_ERR)))
|
||||
if (get_errno() != ENOENT &&
|
||||
(errfunc(buf, get_errno()) || (flags & GLOB_ERR) != 0))
|
||||
{
|
||||
return GLOB_ABORTED;
|
||||
}
|
||||
@ -287,7 +288,7 @@ static int do_glob(FAR char *buf, size_t pos, int type, FAR char *pat,
|
||||
dir = opendir(pos ? buf : ".");
|
||||
if (!dir)
|
||||
{
|
||||
if (errfunc(buf, errno) || (flags & GLOB_ERR))
|
||||
if (errfunc(buf, get_errno()) || (flags & GLOB_ERR) != 0)
|
||||
{
|
||||
return GLOB_ABORTED;
|
||||
}
|
||||
@ -295,8 +296,8 @@ static int do_glob(FAR char *buf, size_t pos, int type, FAR char *pat,
|
||||
return 0;
|
||||
}
|
||||
|
||||
old_errno = errno;
|
||||
while (errno = 0, de = readdir(dir))
|
||||
old_errno = get_errno();
|
||||
while (get_errno() = 0, de = readdir(dir))
|
||||
{
|
||||
size_t l;
|
||||
int fnm_flags;
|
||||
@ -344,19 +345,19 @@ static int do_glob(FAR char *buf, size_t pos, int type, FAR char *pat,
|
||||
}
|
||||
}
|
||||
|
||||
readerr = errno;
|
||||
readerr = get_errno();
|
||||
if (p2)
|
||||
{
|
||||
*p2 = saved_sep;
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
if (readerr && (errfunc(buf, errno) || (flags & GLOB_ERR)))
|
||||
if (readerr && (errfunc(buf, get_errno()) || (flags & GLOB_ERR) != 0))
|
||||
{
|
||||
return GLOB_ABORTED;
|
||||
}
|
||||
|
||||
errno = old_errno;
|
||||
set_errno(old_errno);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -55,9 +55,9 @@ int remove(FAR const char *path)
|
||||
* more frequently the necessary action.
|
||||
*/
|
||||
|
||||
if (unlink(path) != 0 /* If it is indeed a directory... */
|
||||
&& (errno != EPERM /* ...try to remove it. */
|
||||
|| rmdir(path) != 0))
|
||||
if (unlink(path) != 0 && /* If it is indeed a directory... */
|
||||
(get_errno() != EPERM || /* ...try to remove it. */
|
||||
rmdir(path) != 0))
|
||||
{
|
||||
/* Cannot remove the object for whatever reason. */
|
||||
|
||||
|
@ -399,11 +399,11 @@ static long_double decfloat(FAR char *ptr, FAR char **endptr)
|
||||
}
|
||||
else if (num_digit + num_decimal > ldbl_max_10_exp)
|
||||
{
|
||||
errno = ERANGE;
|
||||
set_errno(ERANGE);
|
||||
}
|
||||
else if (num_digit + num_decimal < ldbl_min_10_exp)
|
||||
{
|
||||
errno = ERANGE;
|
||||
set_errno(ERANGE);
|
||||
}
|
||||
|
||||
if (k % 9)
|
||||
@ -561,13 +561,13 @@ static long_double hexfloat(FAR char *ptr,
|
||||
|
||||
if (e2 > -emin)
|
||||
{
|
||||
errno = ERANGE;
|
||||
set_errno(ERANGE);
|
||||
return ldbl_max * ldbl_max;
|
||||
}
|
||||
|
||||
if (e2 < emin - 2 * ldbl_mant_dig)
|
||||
{
|
||||
errno = ERANGE;
|
||||
set_errno(ERANGE);
|
||||
return ldbl_min * ldbl_min;
|
||||
}
|
||||
|
||||
@ -613,7 +613,7 @@ static long_double hexfloat(FAR char *ptr,
|
||||
|
||||
if (!y)
|
||||
{
|
||||
errno = ERANGE;
|
||||
set_errno(ERANGE);
|
||||
}
|
||||
|
||||
return scalbnx(y, 2., e2);
|
||||
|
@ -2171,7 +2171,7 @@ static FAR struct tm *timesub(FAR const time_t *timep,
|
||||
}
|
||||
else
|
||||
{
|
||||
errno = EOVERFLOW;
|
||||
set_errno(EOVERFLOW);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ int getentropy(FAR void *buffer, size_t length)
|
||||
|
||||
if (length > 256)
|
||||
{
|
||||
errno = EIO;
|
||||
set_errno(EIO);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ int getentropy(FAR void *buffer, size_t length)
|
||||
int ret = getrandom(pos, length, 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
if (errno == EINTR)
|
||||
if (get_errno() == EINTR)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ static int uuid_getrandom(FAR void *buf, size_t size, int flags)
|
||||
ssize_t ret = getrandom(tmp, size, flags);
|
||||
if (ret < 0)
|
||||
{
|
||||
if (errno == EINTR)
|
||||
if (get_errno() == EINTR)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user