Procházet zdrojové kódy

use SDL_InvalidParamError in the thread 'classes'

pionere před 2 roky
rodič
revize
450f184f7d

+ 4 - 4
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;

+ 3 - 3
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);

+ 4 - 4
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;

+ 3 - 4
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;

+ 8 - 3
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;

+ 9 - 5
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;
 }