You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/11/07 10:14:38 UTC
[incubator-nuttx] 02/02: lib/atexit: correct return value of exitfunc lock
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 80a2d058b8a182a357a9bdb5bc1bad864fbb6568
Author: chao an <an...@xiaomi.com>
AuthorDate: Mon Nov 7 16:12:02 2022 +0800
lib/atexit: correct return value of exitfunc lock
Signed-off-by: chao an <an...@xiaomi.com>
---
libs/libc/stdlib/lib_atexit.c | 46 ++++---------------------------------------
1 file changed, 4 insertions(+), 42 deletions(-)
diff --git a/libs/libc/stdlib/lib_atexit.c b/libs/libc/stdlib/lib_atexit.c
index 74f831e3bc..0486cdf63b 100644
--- a/libs/libc/stdlib/lib_atexit.c
+++ b/libs/libc/stdlib/lib_atexit.c
@@ -58,45 +58,6 @@ static FAR struct atexit_list_s * get_exitfuncs(void)
return &info->ta_exit;
}
-/****************************************************************************
- * Name: exitfunc_lock
- *
- * Description:
- * Obtain the exit function lock.
- *
- * Returned Value:
- * OK on success, or negated errno on failure
- *
- ****************************************************************************/
-
-static int exitfunc_lock(void)
-{
- FAR struct task_info_s *info = task_get_info();
- int ret = nxmutex_lock(&info->ta_lock);
-
- if (ret < 0)
- {
- ret = -ret;
- }
-
- return ret;
-}
-
-/****************************************************************************
- * Name: exitfunc_unlock
- *
- * Description:
- * Release exit function lock .
- *
- ****************************************************************************/
-
-static void exitfunc_unlock(void)
-{
- FAR struct task_info_s *info = task_get_info();
-
- nxmutex_unlock(&info->ta_lock);
-}
-
/****************************************************************************
* Public Functions
****************************************************************************/
@@ -104,6 +65,7 @@ static void exitfunc_unlock(void)
int atexit_register(int type, CODE void (*func)(void), FAR void *arg,
FAR void *dso)
{
+ FAR struct task_info_s *info = task_get_info();
FAR struct atexit_list_s *aehead;
int idx;
int ret = ERROR;
@@ -118,10 +80,10 @@ int atexit_register(int type, CODE void (*func)(void), FAR void *arg,
if (func)
{
- ret = exitfunc_lock();
+ ret = nxmutex_lock(&info->ta_lock);
if (ret < 0)
{
- return ret;
+ return -ret;
}
if ((idx = aehead->nfuncs) < ATEXIT_MAX)
@@ -137,7 +99,7 @@ int atexit_register(int type, CODE void (*func)(void), FAR void *arg,
ret = ERROR;
}
- exitfunc_unlock();
+ nxmutex_unlock(&info->ta_lock);
}
return ret;