summaryrefslogtreecommitdiffstats
path: root/tools/tools
diff options
context:
space:
mode:
authorru <ru@FreeBSD.org>2010-02-12 16:33:03 +0000
committerru <ru@FreeBSD.org>2010-02-12 16:33:03 +0000
commit7b7a6802807ff6509e17b37bd99c46dfe85a7685 (patch)
treef3d821151367f2d4ecd8ad26c51ab7cfb273ea90 /tools/tools
parentb0758cc42c85a9ee2c2ee046020831a2c4afa3f6 (diff)
downloadFreeBSD-src-7b7a6802807ff6509e17b37bd99c46dfe85a7685.zip
FreeBSD-src-7b7a6802807ff6509e17b37bd99c46dfe85a7685.tar.gz
Fixed error checking of pthread(3) functions.
PR: 143807 Submitted by: pluknet (partly)
Diffstat (limited to 'tools/tools')
-rw-r--r--tools/tools/mctest/mctest.cc4
-rw-r--r--tools/tools/netrate/http/http.c8
-rw-r--r--tools/tools/netrate/httpd/httpd.c4
-rw-r--r--tools/tools/netrate/juggle/juggle.c18
4 files changed, 17 insertions, 17 deletions
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);
OpenPOWER on IntegriCloud