summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan C. Gordon <icculus@icculus.org>2018-02-17 23:57:57 -0500
committerRyan C. Gordon <icculus@icculus.org>2018-02-17 23:57:57 -0500
commit03495f9a7f547cf462725bec4c6093f2b0918724 (patch)
tree3678198bd0234cb23e028d138adbcf34e0453113
parentc167d6f645f1b5f7681949f88c128d53c0244077 (diff)
pthread: fix error code checks (thanks, Andreas!).
Most pthread functions return 0 on success and non-zero on error, but those errors might be positive or negative, so checking for return values in the Unix style, where errors are less than zero, is a bug. Fixes Bugzilla #4039.
-rw-r--r--src/thread/pthread/SDL_syscond.c2
-rw-r--r--src/thread/pthread/SDL_sysmutex.c4
-rw-r--r--src/thread/pthread/SDL_systhread.c4
3 files changed, 5 insertions, 5 deletions
diff --git a/src/thread/pthread/SDL_syscond.c b/src/thread/pthread/SDL_syscond.c
index bb0c31824b..d23578038d 100644
--- a/src/thread/pthread/SDL_syscond.c
+++ b/src/thread/pthread/SDL_syscond.c
@@ -42,7 +42,7 @@ SDL_CreateCond(void)
cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond));
if (cond) {
- if (pthread_cond_init(&cond->cond, NULL) < 0) {
+ if (pthread_cond_init(&cond->cond, NULL) != 0) {
SDL_SetError("pthread_cond_init() failed");
SDL_free(cond);
cond = NULL;
diff --git a/src/thread/pthread/SDL_sysmutex.c b/src/thread/pthread/SDL_sysmutex.c
index 071a56c97d..e7b5b5cece 100644
--- a/src/thread/pthread/SDL_sysmutex.c
+++ b/src/thread/pthread/SDL_sysmutex.c
@@ -105,7 +105,7 @@ SDL_LockMutex(SDL_mutex * mutex)
}
}
#else
- if (pthread_mutex_lock(&mutex->id) < 0) {
+ if (pthread_mutex_lock(&mutex->id) != 0) {
return SDL_SetError("pthread_mutex_lock() failed");
}
#endif
@@ -181,7 +181,7 @@ SDL_UnlockMutex(SDL_mutex * mutex)
}
#else
- if (pthread_mutex_unlock(&mutex->id) < 0) {
+ if (pthread_mutex_unlock(&mutex->id) != 0) {
return SDL_SetError("pthread_mutex_unlock() failed");
}
#endif /* FAKE_RECURSIVE_MUTEX */
diff --git a/src/thread/pthread/SDL_systhread.c b/src/thread/pthread/SDL_systhread.c
index 5539d75818..035484085c 100644
--- a/src/thread/pthread/SDL_systhread.c
+++ b/src/thread/pthread/SDL_systhread.c
@@ -212,7 +212,7 @@ SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
int policy;
pthread_t thread = pthread_self();
- if (pthread_getschedparam(thread, &policy, &sched) < 0) {
+ if (pthread_getschedparam(thread, &policy, &sched) != 0) {
return SDL_SetError("pthread_getschedparam() failed");
}
if (priority == SDL_THREAD_PRIORITY_LOW) {
@@ -224,7 +224,7 @@ SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
int max_priority = sched_get_priority_max(policy);
sched.sched_priority = (min_priority + (max_priority - min_priority) / 2);
}
- if (pthread_setschedparam(thread, policy, &sched) < 0) {
+ if (pthread_setschedparam(thread, policy, &sched) != 0) {
return SDL_SetError("pthread_setschedparam() failed");
}
return 0;