pthread_conddestroy: Fix return value, if sem_getvalue fails

sem_getvalue returns ERROR and sets errno if it fails, we don't want to
return OK in this case, we want to return the non-negated error number.
This commit is contained in:
Ville Juven 2025-01-16 10:37:09 +02:00 committed by Xiang Xiao
parent c3b2910178
commit 516d1c069a

View File

@ -69,21 +69,18 @@ int pthread_cond_destroy(FAR pthread_cond_t *cond)
else
{
ret = sem_getvalue(&cond->sem, &sval);
ret = nxsem_get_value(&cond->sem, &sval);
if (ret < 0)
{
ret = -ret;
}
else if (sval < 0)
{
ret = EBUSY;
}
else
{
if (sval < 0)
{
ret = EBUSY;
}
else if (sem_destroy(&cond->sem) != OK)
{
ret = get_errno();
}
ret = -nxsem_destroy(&cond->sem);
}
}