summaryrefslogtreecommitdiffstats
path: root/usr.bin/dig/lib/isc/unix
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/dig/lib/isc/unix')
-rw-r--r--usr.bin/dig/lib/isc/unix/Makefile.inc5
-rw-r--r--usr.bin/dig/lib/isc/unix/app.c15
-rw-r--r--usr.bin/dig/lib/isc/unix/errno2result.c9
-rw-r--r--usr.bin/dig/lib/isc/unix/include/isc/strerror.h38
-rw-r--r--usr.bin/dig/lib/isc/unix/socket.c48
-rw-r--r--usr.bin/dig/lib/isc/unix/strerror.c41
-rw-r--r--usr.bin/dig/lib/isc/unix/time.c7
7 files changed, 26 insertions, 137 deletions
diff --git a/usr.bin/dig/lib/isc/unix/Makefile.inc b/usr.bin/dig/lib/isc/unix/Makefile.inc
index d6e2b2e4c03..9145f655672 100644
--- a/usr.bin/dig/lib/isc/unix/Makefile.inc
+++ b/usr.bin/dig/lib/isc/unix/Makefile.inc
@@ -1,6 +1,5 @@
-# $OpenBSD: Makefile.inc,v 1.2 2020/02/12 13:05:04 jsg Exp $
+# $OpenBSD: Makefile.inc,v 1.3 2020/02/13 21:34:06 jung Exp $
.PATH: ${.CURDIR}/lib/isc/unix
-SRCS+= app.c errno2result.c socket.c stdio.c net.c stdtime.c
-SRCS+= strerror.c time.c
+SRCS+= app.c errno2result.c socket.c stdio.c net.c stdtime.c time.c
diff --git a/usr.bin/dig/lib/isc/unix/app.c b/usr.bin/dig/lib/isc/unix/app.c
index b69eb627d4d..c63c75cda70 100644
--- a/usr.bin/dig/lib/isc/unix/app.c
+++ b/usr.bin/dig/lib/isc/unix/app.c
@@ -30,7 +30,6 @@
#include <isc/event.h>
-#include <isc/strerror.h>
#include <string.h>
#include <isc/task.h>
#include <isc/time.h>
@@ -143,16 +142,15 @@ reload_action(int arg) {
static isc_result_t
handle_signal(int sig, void (*handler)(int)) {
struct sigaction sa;
- char strbuf[ISC_STRERRORSIZE];
memset(&sa, 0, sizeof(sa));
sa.sa_handler = handler;
if (sigfillset(&sa.sa_mask) != 0 ||
sigaction(sig, &sa, NULL) < 0) {
- isc__strerror(errno, strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__,
- "handle_signal() %d setup: %s", sig, strbuf);
+ "handle_signal() %d setup: %s", sig,
+ strerror(errno));
return (ISC_R_UNEXPECTED);
}
@@ -165,7 +163,6 @@ isc__app_ctxstart(isc_appctx_t *ctx0) {
isc_result_t result;
int presult;
sigset_t sset;
- char strbuf[ISC_STRERRORSIZE];
REQUIRE(VALID_APPCTX(ctx));
@@ -219,17 +216,17 @@ isc__app_ctxstart(isc_appctx_t *ctx0) {
sigaddset(&sset, SIGHUP) != 0 ||
sigaddset(&sset, SIGINT) != 0 ||
sigaddset(&sset, SIGTERM) != 0) {
- isc__strerror(errno, strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__,
- "isc_app_start() sigsetops: %s", strbuf);
+ "isc_app_start() sigsetops: %s",
+ strerror(errno));
result = ISC_R_UNEXPECTED;
goto cleanup;
}
presult = sigprocmask(SIG_UNBLOCK, &sset, NULL);
if (presult != 0) {
- isc__strerror(errno, strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__,
- "isc_app_start() sigprocmask: %s", strbuf);
+ "isc_app_start() sigprocmask: %s",
+ strerror(errno));
result = ISC_R_UNEXPECTED;
goto cleanup;
}
diff --git a/usr.bin/dig/lib/isc/unix/errno2result.c b/usr.bin/dig/lib/isc/unix/errno2result.c
index 449209449be..8675d9b4bb6 100644
--- a/usr.bin/dig/lib/isc/unix/errno2result.c
+++ b/usr.bin/dig/lib/isc/unix/errno2result.c
@@ -14,14 +14,14 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: errno2result.c,v 1.3 2020/02/13 12:03:51 jsg Exp $ */
+/* $Id: errno2result.c,v 1.4 2020/02/13 21:34:06 jung Exp $ */
/*! \file */
#include <errno.h>
+#include <string.h>
#include <isc/result.h>
-#include <isc/strerror.h>
#include <isc/util.h>
#include "errno2result.h"
@@ -36,8 +36,6 @@ isc_result_t
isc___errno2result(int posixerrno, isc_boolean_t dolog,
const char *file, unsigned int line)
{
- char strbuf[ISC_STRERRORSIZE];
-
switch (posixerrno) {
case ENOTDIR:
case ELOOP:
@@ -89,10 +87,9 @@ isc___errno2result(int posixerrno, isc_boolean_t dolog,
return (ISC_R_CONNREFUSED);
default:
if (dolog) {
- isc__strerror(posixerrno, strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(file, line, "unable to convert errno "
"to isc_result: %d: %s",
- posixerrno, strbuf);
+ posixerrno, strerror(posixerrno));
}
/*
* XXXDCL would be nice if perhaps this function could
diff --git a/usr.bin/dig/lib/isc/unix/include/isc/strerror.h b/usr.bin/dig/lib/isc/unix/include/isc/strerror.h
deleted file mode 100644
index 6af33b6628f..00000000000
--- a/usr.bin/dig/lib/isc/unix/include/isc/strerror.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
- * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-/* $Id: strerror.h,v 1.2 2020/02/13 13:53:01 jsg Exp $ */
-
-#ifndef ISC_STRERROR_H
-#define ISC_STRERROR_H
-
-/*! \file */
-
-#include <sys/types.h>
-
-/*% String Error Size */
-#define ISC_STRERRORSIZE 128
-
-/*%
- * Provide a thread safe wrapper to strerror().
- *
- * Requires:
- * 'buf' to be non NULL.
- */
-void
-isc__strerror(int num, char *buf, size_t bufsize);
-
-#endif /* ISC_STRERROR_H */
diff --git a/usr.bin/dig/lib/isc/unix/socket.c b/usr.bin/dig/lib/isc/unix/socket.c
index b3985ccbe7f..3c447ff7f22 100644
--- a/usr.bin/dig/lib/isc/unix/socket.c
+++ b/usr.bin/dig/lib/isc/unix/socket.c
@@ -37,7 +37,6 @@
#include <isc/net.h>
#include <isc/region.h>
#include <isc/socket.h>
-#include <isc/strerror.h>
#include <isc/task.h>
#include <isc/util.h>
@@ -452,7 +451,6 @@ select_poke(isc__socketmgr_t *manager, int fd, int msg) {
static isc_result_t
make_nonblock(int fd) {
int ret;
- char strbuf[ISC_STRERRORSIZE];
int flags;
flags = fcntl(fd, F_GETFL, 0);
@@ -460,11 +458,9 @@ make_nonblock(int fd) {
ret = fcntl(fd, F_SETFL, flags);
if (ret == -1) {
- isc__strerror(errno, strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__,
"fcntl(%d, F_SETFL, %d): %s", fd, flags,
- strbuf);
-
+ strerror(errno));
return (ISC_R_UNEXPECTED);
}
@@ -727,13 +723,11 @@ build_msghdr_send(isc__socket_t *sock, char* cmsgbuf, isc_socketevent_t *dev,
if (setsockopt(sock->fd, IPPROTO_IP, IP_TOS,
(void *)&dscp, sizeof(int)) < 0)
{
- char strbuf[ISC_STRERRORSIZE];
- isc__strerror(errno, strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__,
"setsockopt(%d, IP_TOS, %.02x)"
" %s: %s",
sock->fd, dscp >> 2,
- "failed", strbuf);
+ "failed", strerror(errno));
} else
sock->dscp = dscp;
}
@@ -752,13 +746,11 @@ build_msghdr_send(isc__socket_t *sock, char* cmsgbuf, isc_socketevent_t *dev,
} else if (sock->pf == AF_INET6 && sock->dscp != dev->dscp) {
if (setsockopt(sock->fd, IPPROTO_IPV6, IPV6_TCLASS,
(void *)&dscp, sizeof(int)) < 0) {
- char strbuf[ISC_STRERRORSIZE];
- isc__strerror(errno, strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__,
"setsockopt(%d, IPV6_TCLASS, "
"%.02x) %s: %s",
sock->fd, dscp >> 2,
- "failed", strbuf);
+ "failed", strerror(errno));
} else
sock->dscp = dscp;
}
@@ -931,7 +923,6 @@ doio_recv(isc__socket_t *sock, isc_socketevent_t *dev) {
struct msghdr msghdr;
isc_buffer_t *buffer;
int recv_errno;
- char strbuf[ISC_STRERRORSIZE];
char cmsgbuf[RECVCMSGBUFLEN] = {0};
build_msghdr_recv(sock, cmsgbuf, dev, &msghdr, iov, &read_count);
@@ -944,10 +935,10 @@ doio_recv(isc__socket_t *sock, isc_socketevent_t *dev) {
return (DOIO_SOFT);
if (isc_log_wouldlog(isc_lctx, IOEVENT_LEVEL)) {
- isc__strerror(recv_errno, strbuf, sizeof(strbuf));
socket_log(sock, NULL, IOEVENT,
"doio_recv: recvmsg(%d) %d bytes, err %d/%s",
- sock->fd, cc, recv_errno, strbuf);
+ sock->fd, cc, recv_errno,
+ strerror(recv_errno));
}
#define SOFT_OR_HARD(_system, _isc) \
@@ -1088,7 +1079,6 @@ doio_send(isc__socket_t *sock, isc_socketevent_t *dev) {
char addrbuf[ISC_SOCKADDR_FORMATSIZE];
int attempts = 0;
int send_errno;
- char strbuf[ISC_STRERRORSIZE];
char cmsgbuf[SENDCMSGBUFLEN] = {0};
build_msghdr_send(sock, cmsgbuf, dev, &msghdr, iov, &write_count);
@@ -1149,9 +1139,8 @@ doio_send(isc__socket_t *sock, isc_socketevent_t *dev) {
* a status.
*/
isc_sockaddr_format(&dev->address, addrbuf, sizeof(addrbuf));
- isc__strerror(send_errno, strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__, "internal_send: %s: %s",
- addrbuf, strbuf);
+ addrbuf, strerror(send_errno));
dev->result = isc__errno2result(send_errno);
return (DOIO_HARD);
}
@@ -1341,7 +1330,6 @@ static isc_result_t
opensocket(isc__socket_t *sock)
{
isc_result_t result;
- char strbuf[ISC_STRERRORSIZE];
const char *err = "socket";
int on = 1;
@@ -1358,10 +1346,9 @@ opensocket(isc__socket_t *sock)
switch (errno) {
case EMFILE:
case ENFILE:
- isc__strerror(errno, strbuf, sizeof(strbuf));
isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL,
ISC_LOGMODULE_SOCKET, ISC_LOG_ERROR,
- "%s: %s", err, strbuf);
+ "%s: %s", err, strerror(errno));
/* fallthrough */
case ENOBUFS:
return (ISC_R_NORESOURCES);
@@ -1377,10 +1364,9 @@ opensocket(isc__socket_t *sock)
return (ISC_R_FAMILYNOSUPPORT);
default:
- isc__strerror(errno, strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__,
"%s() %s: %s", err, "failed",
- strbuf);
+ strerror(errno));
return (ISC_R_UNEXPECTED);
}
}
@@ -1404,10 +1390,9 @@ opensocket(isc__socket_t *sock)
if (setsockopt(sock->fd, SOL_SOCKET, SO_TIMESTAMP,
(void *)&on, sizeof(on)) < 0
&& errno != ENOPROTOOPT) {
- isc__strerror(errno, strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__,
"setsockopt(%d, SO_TIMESTAMP) %s: %s",
- sock->fd, "failed", strbuf);
+ sock->fd, "failed", strerror(errno));
/* Press on... */
}
@@ -1415,11 +1400,10 @@ opensocket(isc__socket_t *sock)
if ((sock->pf == AF_INET6)
&& (setsockopt(sock->fd, IPPROTO_IPV6, IPV6_RECVPKTINFO,
(void *)&on, sizeof(on)) < 0)) {
- isc__strerror(errno, strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__,
"setsockopt(%d, IPV6_RECVPKTINFO) "
"%s: %s", sock->fd, "failed",
- strbuf);
+ strerror(errno));
}
}
@@ -2300,7 +2284,6 @@ isc_result_t
isc__socket_bind(isc_socket_t *sock0, isc_sockaddr_t *sockaddr,
unsigned int options) {
isc__socket_t *sock = (isc__socket_t *)sock0;
- char strbuf[ISC_STRERRORSIZE];
int on = 1;
REQUIRE(VALID_SOCKET(sock));
@@ -2333,9 +2316,8 @@ isc__socket_bind(isc_socket_t *sock0, isc_sockaddr_t *sockaddr,
case EINVAL:
return (ISC_R_BOUND);
default:
- isc__strerror(errno, strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__, "bind: %s",
- strbuf);
+ strerror(errno));
return (ISC_R_UNEXPECTED);
}
}
@@ -2355,7 +2337,6 @@ isc__socket_connect(isc_socket_t *sock0, isc_sockaddr_t *addr,
isc_task_t *ntask = NULL;
isc__socketmgr_t *manager;
int cc;
- char strbuf[ISC_STRERRORSIZE];
char addrbuf[ISC_SOCKADDR_FORMATSIZE];
REQUIRE(VALID_SOCKET(sock));
@@ -2419,10 +2400,9 @@ isc__socket_connect(isc_socket_t *sock0, isc_sockaddr_t *addr,
sock->connected = 0;
- isc__strerror(errno, strbuf, sizeof(strbuf));
isc_sockaddr_format(addr, addrbuf, sizeof(addrbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__, "connect(%s) %d/%s",
- addrbuf, errno, strbuf);
+ addrbuf, errno, strerror(errno));
isc_event_free(ISC_EVENT_PTR(&dev));
return (ISC_R_UNEXPECTED);
@@ -2481,7 +2461,6 @@ internal_connect(isc_task_t *me, isc_event_t *ev) {
isc_task_t *task;
int cc;
socklen_t optlen;
- char strbuf[ISC_STRERRORSIZE];
char peerbuf[ISC_SOCKADDR_FORMATSIZE];
UNUSED(me);
@@ -2558,10 +2537,9 @@ internal_connect(isc_task_t *me, isc_event_t *ev) {
dev->result = ISC_R_UNEXPECTED;
isc_sockaddr_format(&sock->peer_address, peerbuf,
sizeof(peerbuf));
- isc__strerror(errno, strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__,
"internal_connect: connect(%s) %s",
- peerbuf, strbuf);
+ peerbuf, strerror(errno));
}
} else {
dev->result = ISC_R_SUCCESS;
diff --git a/usr.bin/dig/lib/isc/unix/strerror.c b/usr.bin/dig/lib/isc/unix/strerror.c
deleted file mode 100644
index a476ad0c989..00000000000
--- a/usr.bin/dig/lib/isc/unix/strerror.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
- * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-/* $Id: strerror.c,v 1.1 2020/02/07 09:58:54 florian Exp $ */
-
-/*! \file */
-
-
-
-#include <stdio.h>
-#include <string.h>
-
-#include <isc/strerror.h>
-#include <isc/util.h>
-
-void
-isc__strerror(int num, char *buf, size_t size) {
- char *msg;
- unsigned int unum = (unsigned int)num;
-
- REQUIRE(buf != NULL);
-
- msg = strerror(num);
- if (msg != NULL)
- snprintf(buf, size, "%s", msg);
- else
- snprintf(buf, size, "Unknown error: %u", unum);
-}
diff --git a/usr.bin/dig/lib/isc/unix/time.c b/usr.bin/dig/lib/isc/unix/time.c
index 39b0cb26f73..c9b8c34c07f 100644
--- a/usr.bin/dig/lib/isc/unix/time.c
+++ b/usr.bin/dig/lib/isc/unix/time.c
@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: time.c,v 1.5 2020/02/13 12:03:51 jsg Exp $ */
+/* $Id: time.c,v 1.6 2020/02/13 21:34:06 jung Exp $ */
/*! \file */
@@ -28,7 +28,6 @@
#include <sys/time.h> /* Required for struct timeval on some platforms. */
-#include <isc/strerror.h>
#include <string.h>
#include <isc/time.h>
@@ -113,13 +112,11 @@ isc_time_isepoch(const isc_time_t *t) {
isc_result_t
isc_time_now(isc_time_t *t) {
struct timeval tv;
- char strbuf[ISC_STRERRORSIZE];
REQUIRE(t != NULL);
if (gettimeofday(&tv, NULL) == -1) {
- isc__strerror(errno, strbuf, sizeof(strbuf));
- UNEXPECTED_ERROR(__FILE__, __LINE__, "%s", strbuf);
+ UNEXPECTED_ERROR(__FILE__, __LINE__, "%s", strerror(errno));
return (ISC_R_UNEXPECTED);
}