diff --git a/src/thread/n3ds/SDL_syscond.c b/src/thread/n3ds/SDL_syscond.c index 9c671f554e..eb56eea0e2 100644 --- a/src/thread/n3ds/SDL_syscond.c +++ b/src/thread/n3ds/SDL_syscond.c @@ -58,7 +58,7 @@ int SDL_CondSignal(SDL_cond *cond) { if (!cond) { - return SDL_SetError("Passed a NULL condition variable"); + return SDL_InvalidParamError("cond"); } CondVar_Signal(&cond->cond_variable); @@ -70,7 +70,7 @@ int SDL_CondBroadcast(SDL_cond *cond) { if (!cond) { - return SDL_SetError("Passed a NULL condition variable"); + return SDL_InvalidParamError("cond"); } CondVar_Broadcast(&cond->cond_variable); @@ -104,10 +104,10 @@ SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms) Result res; if (!cond) { - return SDL_SetError("Passed a NULL condition variable"); + return SDL_InvalidParamError("cond"); } if (!mutex) { - return SDL_SetError("Passed a NULL mutex"); + return SDL_InvalidParamError("mutex"); } res = 0; diff --git a/src/thread/n3ds/SDL_sysmutex.c b/src/thread/n3ds/SDL_sysmutex.c index 59fa8a801a..4c091de022 100644 --- a/src/thread/n3ds/SDL_sysmutex.c +++ b/src/thread/n3ds/SDL_sysmutex.c @@ -56,7 +56,7 @@ int SDL_LockMutex(SDL_mutex *mutex) { if (mutex == NULL) { - return SDL_SetError("Passed a NULL mutex"); + return SDL_InvalidParamError("mutex"); } RecursiveLock_Lock(&mutex->lock); @@ -69,7 +69,7 @@ int SDL_TryLockMutex(SDL_mutex *mutex) { if (mutex == NULL) { - return SDL_SetError("Passed a NULL mutex"); + return SDL_InvalidParamError("mutex"); } return RecursiveLock_TryLock(&mutex->lock); @@ -80,7 +80,7 @@ int SDL_mutexV(SDL_mutex *mutex) { if (mutex == NULL) { - return SDL_SetError("Passed a NULL mutex"); + return SDL_InvalidParamError("mutex"); } RecursiveLock_Unlock(&mutex->lock); diff --git a/src/thread/n3ds/SDL_syssem.c b/src/thread/n3ds/SDL_syssem.c index 08fbb6f42e..29d3415aa2 100644 --- a/src/thread/n3ds/SDL_syssem.c +++ b/src/thread/n3ds/SDL_syssem.c @@ -69,7 +69,7 @@ int SDL_SemTryWait(SDL_sem *sem) { if (!sem) { - return SDL_SetError("Passed a NULL semaphore"); + return SDL_InvalidParamError("sem"); } return SDL_SemWaitTimeout(sem, 0); @@ -81,7 +81,7 @@ SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) int retval; if (!sem) { - return SDL_SetError("Passed a NULL semaphore"); + return SDL_InvalidParamError("sem"); } if (timeout == SDL_MUTEX_MAXWAIT) { @@ -114,7 +114,7 @@ Uint32 SDL_SemValue(SDL_sem *sem) { if (!sem) { - return SDL_SetError("Passed a NULL semaphore"); + return SDL_InvalidParamError("sem"); } return sem->semaphore.current_count; } @@ -123,7 +123,7 @@ int SDL_SemPost(SDL_sem *sem) { if (!sem) { - return SDL_SetError("Passed a NULL semaphore"); + return SDL_InvalidParamError("sem"); } LightSemaphore_Release(&sem->semaphore, 1); return 0; diff --git a/src/thread/ngage/SDL_sysmutex.cpp b/src/thread/ngage/SDL_sysmutex.cpp index 6893fc6283..f7ec1bbb11 100644 --- a/src/thread/ngage/SDL_sysmutex.cpp +++ b/src/thread/ngage/SDL_sysmutex.cpp @@ -77,8 +77,7 @@ SDL_TryLockMutex(SDL_mutex * mutex) { if (mutex == NULL) { - SDL_SetError("Passed a NULL mutex."); - return -1; + return SDL_InvalidParamError("mutex"); } // Not yet implemented. @@ -92,7 +91,7 @@ SDL_LockMutex(SDL_mutex * mutex) { if (mutex == NULL) { - return SDL_SetError("Passed a NULL mutex."); + return SDL_InvalidParamError("mutex"); } RMutex rmutex; @@ -108,7 +107,7 @@ SDL_UnlockMutex(SDL_mutex * mutex) { if ( mutex == NULL ) { - return SDL_SetError("Passed a NULL mutex."); + return SDL_InvalidParamError("mutex"); } RMutex rmutex; diff --git a/src/thread/ngage/SDL_syssem.cpp b/src/thread/ngage/SDL_syssem.cpp index 622d6239a0..a999524e82 100644 --- a/src/thread/ngage/SDL_syssem.cpp +++ b/src/thread/ngage/SDL_syssem.cpp @@ -119,7 +119,7 @@ SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) { if (! sem) { - return SDL_SetError("Passed a NULL sem"); + return SDL_InvalidParamError("sem"); } if (timeout == SDL_MUTEX_MAXWAIT) @@ -152,6 +152,11 @@ SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) int SDL_SemTryWait(SDL_sem *sem) { + if (! sem) + { + return SDL_InvalidParamError("sem"); + } + if(sem->count > 0) { sem->count--; @@ -170,7 +175,7 @@ SDL_SemValue(SDL_sem * sem) { if (! sem) { - SDL_SetError("Passed a NULL sem."); + SDL_InvalidParamError("sem"); return 0; } return sem->count; @@ -181,7 +186,7 @@ SDL_SemPost(SDL_sem * sem) { if (! sem) { - return SDL_SetError("Passed a NULL sem."); + return SDL_InvalidParamError("sem"); } sem->count++; RSemaphore sema; diff --git a/src/thread/pthread/SDL_syssem.c b/src/thread/pthread/SDL_syssem.c index 9a0c888224..01039e801e 100644 --- a/src/thread/pthread/SDL_syssem.c +++ b/src/thread/pthread/SDL_syssem.c @@ -180,11 +180,15 @@ Uint32 SDL_SemValue(SDL_sem * sem) { int ret = 0; - if (sem) { - sem_getvalue(&sem->sem, &ret); - if (ret < 0) { - ret = 0; - } + + if (!sem) { + SDL_InvalidParamError("sem"); + return 0; + } + + sem_getvalue(&sem->sem, &ret); + if (ret < 0) { + ret = 0; } return (Uint32) ret; }