From 2d23251c4d233693a550cbb352b3de0adbcd030a Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Thu, 13 Dec 2012 15:16:41 +0000 Subject: Bug 693487: fix error handling in doc/multi-threaded.c A user (av1474) points out that pthread error codes are non zero, not negative; hence fix the example code to test for these correctly. --- doc/multi-threaded.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'doc') diff --git a/doc/multi-threaded.c b/doc/multi-threaded.c index a0a4ef50..68cd568d 100644 --- a/doc/multi-threaded.c +++ b/doc/multi-threaded.c @@ -116,7 +116,7 @@ void lock_mutex(void *user, int lock) { pthread_mutex_t *mutex = (pthread_mutex_t *) user; - if (pthread_mutex_lock(&mutex[lock]) < 0) + if (pthread_mutex_lock(&mutex[lock]) != 0) fail("pthread_mutex_lock()"); } @@ -124,7 +124,7 @@ void unlock_mutex(void *user, int lock) { pthread_mutex_t *mutex = (pthread_mutex_t *) user; - if (pthread_mutex_unlock(&mutex[lock]) < 0) + if (pthread_mutex_unlock(&mutex[lock]) != 0) fail("pthread_mutex_unlock()"); } @@ -140,7 +140,7 @@ int main(int argc, char **argv) for (i = 0; i < FZ_LOCK_MAX; i++) { - if (pthread_mutex_init(&mutex[i], NULL) < 0) + if (pthread_mutex_init(&mutex[i], NULL) != 0) fail("pthread_mutex_init()"); } @@ -219,7 +219,7 @@ int main(int argc, char **argv) // Create the thread and pass it the data structure. - if (pthread_create(&thread[i], NULL, renderer, data) < 0) + if (pthread_create(&thread[i], NULL, renderer, data) != 0) fail("pthread_create()"); } @@ -232,7 +232,7 @@ int main(int argc, char **argv) char filename[42]; struct data *data; - if (pthread_join(thread[i], (void **) &data) < 0) + if (pthread_join(thread[i], (void **) &data) != 0) fail("pthread_join"); sprintf(filename, "out%04d.png", i); -- cgit v1.2.3