svn commit: r203800 - in head/tools:
regression/file/newfileops_on_fork regression/gaithrstress
tools/mctest tools/netrate/http tools/netrate/httpd
tools/netrate/juggle
Ruslan Ermilov
ru at FreeBSD.org
Fri Feb 12 16:33:03 UTC 2010
Author: ru
Date: Fri Feb 12 16:33:03 2010
New Revision: 203800
URL: http://svn.freebsd.org/changeset/base/203800
Log:
Fixed error checking of pthread(3) functions.
PR: 143807
Submitted by: pluknet (partly)
Modified:
head/tools/regression/file/newfileops_on_fork/newfileops_on_fork.c
head/tools/regression/gaithrstress/gaithrstress.c
head/tools/tools/mctest/mctest.cc
head/tools/tools/netrate/http/http.c
head/tools/tools/netrate/httpd/httpd.c
head/tools/tools/netrate/juggle/juggle.c
Modified: head/tools/regression/file/newfileops_on_fork/newfileops_on_fork.c
==============================================================================
--- head/tools/regression/file/newfileops_on_fork/newfileops_on_fork.c Fri Feb 12 15:07:24 2010 (r203799)
+++ head/tools/regression/file/newfileops_on_fork/newfileops_on_fork.c Fri Feb 12 16:33:03 2010 (r203800)
@@ -113,7 +113,7 @@ main(__unused int argc, __unused char *a
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();
Modified: head/tools/regression/gaithrstress/gaithrstress.c
==============================================================================
--- head/tools/regression/gaithrstress/gaithrstress.c Fri Feb 12 15:07:24 2010 (r203799)
+++ head/tools/regression/gaithrstress/gaithrstress.c Fri Feb 12 16:33:03 2010 (r203800)
@@ -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);
Modified: head/tools/tools/mctest/mctest.cc
==============================================================================
--- head/tools/tools/mctest/mctest.cc Fri Feb 12 15:07:24 2010 (r203799)
+++ head/tools/tools/mctest/mctest.cc Fri Feb 12 16:33:03 2010 (r203800)
@@ -368,7 +368,7 @@ int source(char *interface, struct in_ad
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_ad
}
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;
}
Modified: head/tools/tools/netrate/http/http.c
==============================================================================
--- head/tools/tools/netrate/http/http.c Fri Feb 12 15:07:24 2010 (r203799)
+++ head/tools/tools/netrate/http/http.c Fri Feb 12 16:33:03 2010 (r203800)
@@ -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);
Modified: head/tools/tools/netrate/httpd/httpd.c
==============================================================================
--- head/tools/tools/netrate/httpd/httpd.c Fri Feb 12 15:07:24 2010 (r203799)
+++ head/tools/tools/netrate/httpd/httpd.c Fri Feb 12 16:33:03 2010 (r203800)
@@ -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);
Modified: head/tools/tools/netrate/juggle/juggle.c
==============================================================================
--- head/tools/tools/netrate/juggle/juggle.c Fri Feb 12 15:07:24 2010 (r203799)
+++ head/tools/tools/netrate/juggle/juggle.c Fri Feb 12 16:33:03 2010 (r203800)
@@ -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 pipe
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 pipe
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);
More information about the svn-src-head
mailing list