diff options
author | ru <ru@FreeBSD.org> | 2010-02-12 16:33:03 +0000 |
---|---|---|
committer | ru <ru@FreeBSD.org> | 2010-02-12 16:33:03 +0000 |
commit | 7b7a6802807ff6509e17b37bd99c46dfe85a7685 (patch) | |
tree | f3d821151367f2d4ecd8ad26c51ab7cfb273ea90 | |
parent | b0758cc42c85a9ee2c2ee046020831a2c4afa3f6 (diff) | |
download | FreeBSD-src-7b7a6802807ff6509e17b37bd99c46dfe85a7685.zip FreeBSD-src-7b7a6802807ff6509e17b37bd99c46dfe85a7685.tar.gz |
Fixed error checking of pthread(3) functions.
PR: 143807
Submitted by: pluknet (partly)
-rw-r--r-- | tools/regression/file/newfileops_on_fork/newfileops_on_fork.c | 2 | ||||
-rw-r--r-- | tools/regression/gaithrstress/gaithrstress.c | 2 | ||||
-rw-r--r-- | tools/tools/mctest/mctest.cc | 4 | ||||
-rw-r--r-- | tools/tools/netrate/http/http.c | 8 | ||||
-rw-r--r-- | tools/tools/netrate/httpd/httpd.c | 4 | ||||
-rw-r--r-- | tools/tools/netrate/juggle/juggle.c | 18 |
6 files changed, 19 insertions, 19 deletions
diff --git a/tools/regression/file/newfileops_on_fork/newfileops_on_fork.c b/tools/regression/file/newfileops_on_fork/newfileops_on_fork.c index 42a6af7..8713a82 100644 --- a/tools/regression/file/newfileops_on_fork/newfileops_on_fork.c +++ b/tools/regression/file/newfileops_on_fork/newfileops_on_fork.c @@ -113,7 +113,7 @@ main(__unused int argc, __unused char *argv[]) err(-1, "bind"); if (listen(listen_fd, -1) <0) err(-1, "listen"); - if (pthread_create(&accept_thread, NULL, do_accept, NULL) < 0) + if (pthread_create(&accept_thread, NULL, do_accept, NULL) != 0) err(-1, "pthread_create"); sleep(1); /* Easier than using a CV. */; do_fork(); diff --git a/tools/regression/gaithrstress/gaithrstress.c b/tools/regression/gaithrstress/gaithrstress.c index 023e0b5..c76f94f 100644 --- a/tools/regression/gaithrstress/gaithrstress.c +++ b/tools/regression/gaithrstress/gaithrstress.c @@ -241,7 +241,7 @@ usage: fflush(stdout); for (i = 0; i < nworkers; i++) { if (pthread_create(&workers[i].w_thread, NULL, work, - &workers[i]) == -1) + &workers[i]) != 0) err(1, "creating worker %u", i); printf("%u%s", i, i == nworkers - 1 ? ".\n" : ", "); fflush(stdout); diff --git a/tools/tools/mctest/mctest.cc b/tools/tools/mctest/mctest.cc index 7140b62..2bd4b3e 100644 --- a/tools/tools/mctest/mctest.cc +++ b/tools/tools/mctest/mctest.cc @@ -368,7 +368,7 @@ int source(char *interface, struct in_addr *group, int pkt_size, args[i].packets = received[i]; args[i].number = number / clients; args[i].client = base_port + i; - if (pthread_create(&thread[i], NULL, server, &args[i]) < 0) { + if (pthread_create(&thread[i], NULL, server, &args[i]) != 0) { perror("failed to create server thread"); return -1; } @@ -393,7 +393,7 @@ int source(char *interface, struct in_addr *group, int pkt_size, } for (int i = 0; i < clients; i++) { - if (pthread_join(thread[i], NULL) < 0) { + if (pthread_join(thread[i], NULL) != 0) { perror("failed to join thread"); return -1; } diff --git a/tools/tools/netrate/http/http.c b/tools/tools/netrate/http/http.c index 5010703..ea9431f 100644 --- a/tools/tools/netrate/http/http.c +++ b/tools/tools/netrate/http/http.c @@ -300,15 +300,15 @@ main(int argc, char *argv[]) if (threaded) { if (pthread_barrier_init(&statep->start_barrier, NULL, - numthreads) < 0) - err(-1, "pthread_mutex_init"); + numthreads) != 0) + err(-1, "pthread_barrier_init"); } for (i = 0; i < numthreads; i++) { statep->hwd[i].hwd_count = 0; if (threaded) { if (pthread_create(&statep->hwd[i].hwd_thread, NULL, - http_worker, &statep->hwd[i]) < 0) + http_worker, &statep->hwd[i]) != 0) err(-1, "pthread_create"); } else { curthread = i; @@ -339,7 +339,7 @@ main(int argc, char *argv[]) for (i = 0; i < numthreads; i++) { if (threaded) { if (pthread_join(statep->hwd[i].hwd_thread, NULL) - < 0) + != 0) err(-1, "pthread_join"); } else { pid = waitpid(statep->hwd[i].hwd_pid, NULL, 0); diff --git a/tools/tools/netrate/httpd/httpd.c b/tools/tools/netrate/httpd/httpd.c index 73422b1..3e7a672 100644 --- a/tools/tools/netrate/httpd/httpd.c +++ b/tools/tools/netrate/httpd/httpd.c @@ -280,7 +280,7 @@ main(int argc, char *argv[]) for (i = 0; i < THREADS; i++) { if (threaded) { if (pthread_create(&statep->hts[i].hts_thread, NULL, - httpd_worker, &statep->hts[i]) < 0) + httpd_worker, &statep->hts[i]) != 0) err(-1, "pthread_create"); } else { pid = fork(); @@ -299,7 +299,7 @@ main(int argc, char *argv[]) for (i = 0; i < THREADS; i++) { if (threaded) { if (pthread_join(statep->hts[i].hts_thread, NULL) - < 0) + != 0) err(-1, "pthread_join"); } else { pid = waitpid(statep->hts[i].hts_pid, NULL, 0); diff --git a/tools/tools/netrate/juggle/juggle.c b/tools/tools/netrate/juggle/juggle.c index d0bb496..67bb233 100644 --- a/tools/tools/netrate/juggle/juggle.c +++ b/tools/tools/netrate/juggle/juggle.c @@ -301,15 +301,15 @@ juggling_thread(void *arg) fd2 = *(int *)arg; - if (pthread_mutex_lock(&threaded_mtx) < 0) + if (pthread_mutex_lock(&threaded_mtx) != 0) err(-1, "juggling_thread: pthread_mutex_lock"); threaded_child_ready = 1; - if (pthread_cond_signal(&threaded_cond) < 0) + if (pthread_cond_signal(&threaded_cond) != 0) err(-1, "juggling_thread: pthread_cond_signal"); - if (pthread_mutex_unlock(&threaded_mtx) < 0) + if (pthread_mutex_unlock(&threaded_mtx) != 0) err(-1, "juggling_thread: pthread_mutex_unlock"); for (i = 0; i < NUMCYCLES; i++) { @@ -334,21 +334,21 @@ thread_juggle(int fd1, int fd2, int pipeline) threaded_pipeline = pipeline; - if (pthread_mutex_init(&threaded_mtx, NULL) < 0) + if (pthread_mutex_init(&threaded_mtx, NULL) != 0) err(-1, "thread_juggle: pthread_mutex_init"); - if (pthread_create(&thread, NULL, juggling_thread, &fd2) < 0) + if (pthread_create(&thread, NULL, juggling_thread, &fd2) != 0) err(-1, "thread_juggle: pthread_create"); - if (pthread_mutex_lock(&threaded_mtx) < 0) + if (pthread_mutex_lock(&threaded_mtx) != 0) err(-1, "thread_juggle: pthread_mutex_lock"); while (!threaded_child_ready) { - if (pthread_cond_wait(&threaded_cond, &threaded_mtx) < 0) + if (pthread_cond_wait(&threaded_cond, &threaded_mtx) != 0) err(-1, "thread_juggle: pthread_cond_wait"); } - if (pthread_mutex_unlock(&threaded_mtx) < 0) + if (pthread_mutex_unlock(&threaded_mtx) != 0) err(-1, "thread_juggle: pthread_mutex_unlock"); if (clock_gettime(CLOCK_REALTIME, &tstart) < 0) @@ -369,7 +369,7 @@ thread_juggle(int fd1, int fd2, int pipeline) if (clock_gettime(CLOCK_REALTIME, &tfinish) < 0) err(-1, "thread_juggle: clock_gettime"); - if (pthread_join(thread, NULL) < 0) + if (pthread_join(thread, NULL) != 0) err(-1, "thread_juggle: pthread_join"); timespecsub(&tfinish, &tstart); |