lib/atexit: correct return value of exitfunc lock

Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
chao an 2022-11-07 16:12:02 +08:00 committed by Xiang Xiao
parent df55f0137a
commit 80a2d058b8

View file

@ -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;