From c5dc4929a3e8bc91a204eff5b55c10ce54cec591 Mon Sep 17 00:00:00 2001 From: guenther <> Date: Tue, 20 May 2014 01:25:24 +0000 Subject: Use errc/warnc to simplify code. Also, in 'ftp', always put the error message last, after the hostname/ipaddr. ok jsing@ krw@ millert@ --- src/regress/lib/libc/stdio_threading/include/local.h | 14 +++++++------- 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) int r; if ((r = pthread_rwlock_rdlock(&start))) - errx(1, "could not obtain lock in thread: %s", strerror(r)); + errc(1, r, "could not obtain lock in thread"); real_func(arg); if ((r = pthread_rwlock_unlock(&start))) - errx(1, "could not release lock in thread: %s", strerror(r)); + errc(1, r, "could not release lock in thread"); return NULL; } @@ -52,20 +52,20 @@ run_threads(void (*func)(void *), void *arg) self = pthread_self(); real_func = func; if ((r = pthread_rwlock_init(&start, NULL))) - errx(1, "could not initialize lock: %s", strerror(r)); + errc(1, r, "could not initialize lock"); if ((r = pthread_rwlock_wrlock(&start))) /* block */ - errx(1, "could not lock lock: %s", strerror(r)); + errc(1, r, "could not lock lock"); for (i = 0; i < THREAD_COUNT; i++) if ((r = pthread_create(&pthread[i], NULL, thread, arg))) { - warnx("could not create thread: %s", strerror(r)); + warnc(r, "could not create thread"); pthread[i] = self; } if ((r = pthread_rwlock_unlock(&start))) /* unleash */ - errx(1, "could not release lock: %s", strerror(r)); + errc(1, r, "could not release lock"); sleep(1); @@ -76,6 +76,6 @@ run_threads(void (*func)(void *), void *arg) for (i = 0; i < THREAD_COUNT; i++) if (! pthread_equal(pthread[i], self) && (r = pthread_join(pthread[i], NULL))) - warnx("could not join thread: %s", strerror(r)); + warnc(r, "could not join thread"); } 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 @@ -/* $OpenBSD: netcat.c,v 1.118 2014/03/12 10:19:40 jca Exp $ */ +/* $OpenBSD: netcat.c,v 1.119 2014/05/20 01:25:23 guenther Exp $ */ /* * Copyright (c) 2001 Eric Jackson * @@ -608,7 +608,7 @@ remote_connect(const char *host, const char *port, struct addrinfo hints) if (bind(s, (struct sockaddr *)ares->ai_addr, ares->ai_addrlen) < 0) - errx(1, "bind failed: %s", strerror(errno)); + err(1, "bind failed"); freeaddrinfo(ares); } -- cgit v1.2.3-55-g6feb