diff options
| author | guenther <> | 2014-05-20 01:25:24 +0000 |
|---|---|---|
| committer | guenther <> | 2014-05-20 01:25:24 +0000 |
| commit | c828f49e874ccefdf66c868b128f304c3870e615 (patch) | |
| tree | 35f3e235e477c74cd6b783d86d4b098a8b54aa11 | |
| parent | b19e47792ae015b7179921c106605e9b7861cb0c (diff) | |
| download | openbsd-c828f49e874ccefdf66c868b128f304c3870e615.tar.gz openbsd-c828f49e874ccefdf66c868b128f304c3870e615.tar.bz2 openbsd-c828f49e874ccefdf66c868b128f304c3870e615.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 '')
| -rw-r--r-- | src/regress/lib/libc/stdio_threading/include/local.h | 14 | ||||
| -rw-r--r-- | src/usr.bin/nc/netcat.c | 4 |
2 files changed, 9 insertions, 9 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 | ||
diff --git a/src/usr.bin/nc/netcat.c b/src/usr.bin/nc/netcat.c index c120016912..1454dd7b90 100644 --- a/src/usr.bin/nc/netcat.c +++ b/src/usr.bin/nc/netcat.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: netcat.c,v 1.118 2014/03/12 10:19:40 jca Exp $ */ | 1 | /* $OpenBSD: netcat.c,v 1.119 2014/05/20 01:25:23 guenther Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2001 Eric Jackson <ericj@monkey.org> | 3 | * Copyright (c) 2001 Eric Jackson <ericj@monkey.org> |
| 4 | * | 4 | * |
| @@ -608,7 +608,7 @@ remote_connect(const char *host, const char *port, struct addrinfo hints) | |||
| 608 | 608 | ||
| 609 | if (bind(s, (struct sockaddr *)ares->ai_addr, | 609 | if (bind(s, (struct sockaddr *)ares->ai_addr, |
| 610 | ares->ai_addrlen) < 0) | 610 | ares->ai_addrlen) < 0) |
| 611 | errx(1, "bind failed: %s", strerror(errno)); | 611 | err(1, "bind failed"); |
| 612 | freeaddrinfo(ares); | 612 | freeaddrinfo(ares); |
| 613 | } | 613 | } |
| 614 | 614 | ||
