diff options
| author | guenther <> | 2014-05-20 01:25:24 +0000 | 
|---|---|---|
| committer | guenther <> | 2014-05-20 01:25:24 +0000 | 
| commit | c5dc4929a3e8bc91a204eff5b55c10ce54cec591 (patch) | |
| tree | 35f3e235e477c74cd6b783d86d4b098a8b54aa11 /src/regress/lib/libc/stdio_threading/include | |
| parent | 3c12c2aea2c1cdfaab42054ed8643b2bd31e4fdd (diff) | |
| download | openbsd-c5dc4929a3e8bc91a204eff5b55c10ce54cec591.tar.gz openbsd-c5dc4929a3e8bc91a204eff5b55c10ce54cec591.tar.bz2 openbsd-c5dc4929a3e8bc91a204eff5b55c10ce54cec591.zip | |
Use errc/warnc to simplify code.
Also, in 'ftp', always put the error message last, after the hostname/ipaddr.
ok jsing@ krw@ millert@
Diffstat (limited to 'src/regress/lib/libc/stdio_threading/include')
| -rw-r--r-- | src/regress/lib/libc/stdio_threading/include/local.h | 14 | 
1 files changed, 7 insertions, 7 deletions
| diff --git a/src/regress/lib/libc/stdio_threading/include/local.h b/src/regress/lib/libc/stdio_threading/include/local.h index e2ad4e31e0..b21fabd390 100644 --- a/src/regress/lib/libc/stdio_threading/include/local.h +++ b/src/regress/lib/libc/stdio_threading/include/local.h | |||
| @@ -36,10 +36,10 @@ thread(void *arg) | |||
| 36 | int r; | 36 | int r; | 
| 37 | 37 | ||
| 38 | if ((r = pthread_rwlock_rdlock(&start))) | 38 | if ((r = pthread_rwlock_rdlock(&start))) | 
| 39 | errx(1, "could not obtain lock in thread: %s", strerror(r)); | 39 | errc(1, r, "could not obtain lock in thread"); | 
| 40 | real_func(arg); | 40 | real_func(arg); | 
| 41 | if ((r = pthread_rwlock_unlock(&start))) | 41 | if ((r = pthread_rwlock_unlock(&start))) | 
| 42 | errx(1, "could not release lock in thread: %s", strerror(r)); | 42 | errc(1, r, "could not release lock in thread"); | 
| 43 | return NULL; | 43 | return NULL; | 
| 44 | } | 44 | } | 
| 45 | 45 | ||
| @@ -52,20 +52,20 @@ run_threads(void (*func)(void *), void *arg) | |||
| 52 | self = pthread_self(); | 52 | self = pthread_self(); | 
| 53 | real_func = func; | 53 | real_func = func; | 
| 54 | if ((r = pthread_rwlock_init(&start, NULL))) | 54 | if ((r = pthread_rwlock_init(&start, NULL))) | 
| 55 | errx(1, "could not initialize lock: %s", strerror(r)); | 55 | errc(1, r, "could not initialize lock"); | 
| 56 | 56 | ||
| 57 | if ((r = pthread_rwlock_wrlock(&start))) /* block */ | 57 | if ((r = pthread_rwlock_wrlock(&start))) /* block */ | 
| 58 | errx(1, "could not lock lock: %s", strerror(r)); | 58 | errc(1, r, "could not lock lock"); | 
| 59 | 59 | ||
| 60 | for (i = 0; i < THREAD_COUNT; i++) | 60 | for (i = 0; i < THREAD_COUNT; i++) | 
| 61 | if ((r = pthread_create(&pthread[i], NULL, thread, arg))) { | 61 | if ((r = pthread_create(&pthread[i], NULL, thread, arg))) { | 
| 62 | warnx("could not create thread: %s", strerror(r)); | 62 | warnc(r, "could not create thread"); | 
| 63 | pthread[i] = self; | 63 | pthread[i] = self; | 
| 64 | } | 64 | } | 
| 65 | 65 | ||
| 66 | 66 | ||
| 67 | if ((r = pthread_rwlock_unlock(&start))) /* unleash */ | 67 | if ((r = pthread_rwlock_unlock(&start))) /* unleash */ | 
| 68 | errx(1, "could not release lock: %s", strerror(r)); | 68 | errc(1, r, "could not release lock"); | 
| 69 | 69 | ||
| 70 | sleep(1); | 70 | sleep(1); | 
| 71 | 71 | ||
| @@ -76,6 +76,6 @@ run_threads(void (*func)(void *), void *arg) | |||
| 76 | for (i = 0; i < THREAD_COUNT; i++) | 76 | for (i = 0; i < THREAD_COUNT; i++) | 
| 77 | if (! pthread_equal(pthread[i], self) && | 77 | if (! pthread_equal(pthread[i], self) && | 
| 78 | (r = pthread_join(pthread[i], NULL))) | 78 | (r = pthread_join(pthread[i], NULL))) | 
| 79 | warnx("could not join thread: %s", strerror(r)); | 79 | warnc(r, "could not join thread"); | 
| 80 | } | 80 | } | 
| 81 | 81 | ||
