summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2012-12-13 15:16:41 +0000
committerRobin Watts <robin.watts@artifex.com>2012-12-13 15:18:36 +0000
commit2d23251c4d233693a550cbb352b3de0adbcd030a (patch)
tree3cfa69d1707c10e78cf3320e3fd180ff07cf6026 /doc
parent6e392e5e9a539bef5f608e2c1ee11ea4c1f68f2a (diff)
downloadmupdf-2d23251c4d233693a550cbb352b3de0adbcd030a.tar.xz
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.
Diffstat (limited to 'doc')
-rw-r--r--doc/multi-threaded.c10
1 files changed, 5 insertions, 5 deletions
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);