diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2014-08-13 01:03:57 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2014-08-13 01:03:57 +0000 |
commit | 9b3e5e0bb3fde337365a91a44f51e62e19559459 (patch) | |
tree | cf63d06feb354cf955a1f86779a010c1acb5de3f | |
parent | 75ae2fe98a758c8869f24742cda2614245f5fb92 (diff) |
use errc instead of juggling errno values in tftpd_listen.
-rw-r--r-- | usr.sbin/tftpd/tftpd.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/usr.sbin/tftpd/tftpd.c b/usr.sbin/tftpd/tftpd.c index 49c7b363433..053a893a93a 100644 --- a/usr.sbin/tftpd/tftpd.c +++ b/usr.sbin/tftpd/tftpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tftpd.c,v 1.20 2014/08/13 01:00:16 dlg Exp $ */ +/* $OpenBSD: tftpd.c,v 1.21 2014/08/13 01:03:56 dlg Exp $ */ /* * Copyright (c) 2012 David Gwynne <dlg@uq.edu.au> @@ -490,8 +490,8 @@ tftpd_listen(const char *addr, const char *port, int family) int error; int s; - int saved_errno; - const char *cause = NULL; + int cerrno = EADDRNOTAVAIL; + const char *cause = "getaddrinfo"; int on = 1; @@ -512,14 +512,14 @@ tftpd_listen(const char *addr, const char *port, int family) s = socket(res->ai_family, res->ai_socktype, res->ai_protocol); if (s == -1) { cause = "socket"; + cerrno = errno; continue; } if (bind(s, res->ai_addr, res->ai_addrlen) == -1) { cause = "bind"; - saved_errno = errno; + cerrno = errno; close(s); - errno = saved_errno; continue; } @@ -548,7 +548,7 @@ tftpd_listen(const char *addr, const char *port, int family) } if (TAILQ_EMPTY(&tftp_servers)) - err(1, "%s", cause); + errc(1, cerrno, "%s", cause); return (0); } |