kernel: POSIX: Fixing return value of POSIX APIs on error.

As per IEEE 1003.1 POSIX APIs should return ERROR_CODE on error.
But currently these are returning -ERROR_CODE instead of ERROR_CODE.
So fixing the return value.

Signed-off-by: Youvedeep Singh <youvedeep.singh@intel.com>
This commit is contained in:
Youvedeep Singh 2018-02-08 08:50:06 +05:30 committed by Anas Nashif
parent f31245d365
commit 325abfbcf4
3 changed files with 3 additions and 3 deletions

View file

@ -193,7 +193,7 @@ static inline int pthread_mutex_timedlock(pthread_mutex_t *m,
{
int ret = k_sem_take(m->sem, _ts_to_ms(to));
return ret == -EAGAIN ? -ETIMEDOUT : ret;
return ret == 0 ? ret : ETIMEDOUT;
}
/**

View file

@ -34,7 +34,7 @@ static int cond_wait(pthread_cond_t *cv, pthread_mutex_t *mut, int timeout)
*/
pthread_mutex_lock(mut);
return ret == -EAGAIN ? -ETIMEDOUT : ret;
return ret == -EAGAIN ? ETIMEDOUT : ret;
}
/* This implements a "fair" scheduling policy: at the end of a POSIX

View file

@ -11,7 +11,7 @@
int pthread_mutex_trylock(pthread_mutex_t *m)
{
int key = irq_lock(), ret = -EBUSY;
int key = irq_lock(), ret = EBUSY;
if (m->sem->count) {
m->sem->count = 0;