diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2017-02-13 21:53:54 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2017-02-13 21:53:54 +0000 |
commit | f353601f76547b08e9491eee728a0b3b8e3c56c1 (patch) | |
tree | dc914411b832bb0805cf29f26d30b8ef0efb6a1e | |
parent | 24ead626973a93a63ca03771a25c6a99c4b0cb5c (diff) |
Do the strerror() elimination dance with log_warnx() -> log_warn(),
fatalx() -> fatal() and even a couple of fprintf(stderr) -> log_warn().
-rw-r--r-- | usr.sbin/dhcpd/dispatch.c | 5 | ||||
-rw-r--r-- | usr.sbin/dhcpd/pfutils.c | 10 | ||||
-rw-r--r-- | usr.sbin/dhcpd/sync.c | 12 | ||||
-rw-r--r-- | usr.sbin/dhcpd/udpsock.c | 18 |
4 files changed, 20 insertions, 25 deletions
diff --git a/usr.sbin/dhcpd/dispatch.c b/usr.sbin/dhcpd/dispatch.c index 450a416b33e..84281895576 100644 --- a/usr.sbin/dhcpd/dispatch.c +++ b/usr.sbin/dhcpd/dispatch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dispatch.c,v 1.39 2017/02/13 19:13:14 krw Exp $ */ +/* $OpenBSD: dispatch.c,v 1.40 2017/02/13 21:53:53 krw Exp $ */ /* * Copyright (c) 1995, 1996, 1997, 1998, 1999 @@ -417,8 +417,7 @@ got_one(struct protocol *l) if ((result = receive_packet(ip, u.packbuf, sizeof u, &from, &hfrom)) == -1) { - log_warnx("receive_packet failed on %s: %s", ip->name, - strerror(errno)); + log_warn("receive_packet failed on %s", ip->name); ip->errors++; if ((!interface_status(ip)) || (ip->noifmedia && ip->errors > 20)) { diff --git a/usr.sbin/dhcpd/pfutils.c b/usr.sbin/dhcpd/pfutils.c index 145c58cc9ff..419515e942a 100644 --- a/usr.sbin/dhcpd/pfutils.c +++ b/usr.sbin/dhcpd/pfutils.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfutils.c,v 1.16 2017/02/13 19:13:14 krw Exp $ */ +/* $OpenBSD: pfutils.c,v 1.17 2017/02/13 21:53:53 krw Exp $ */ /* * Copyright (c) 2006 Chris Kuethe <ckuethe@openbsd.org> * @@ -156,8 +156,8 @@ pf_change_table(int fd, int op, struct in_addr ip, char *table) if (ioctl(fd, op ? DIOCRADDADDRS : DIOCRDELADDRS, &io) && errno != ESRCH) { - log_warnx( "DIOCR%sADDRS on table %s: %s", - op ? "ADD" : "DEL", table, strerror(errno)); + log_warn( "DIOCR%sADDRS on table %s", op ? "ADD" : "DEL", + table); } } @@ -179,7 +179,7 @@ pf_kill_state(int fd, struct in_addr ip) memset(&psk.psk_src.addr.v.a.mask, 0xff, sizeof(psk.psk_src.addr.v.a.mask)); if (ioctl(fd, DIOCKILLSTATES, &psk)) { - log_warnx("DIOCKILLSTATES failed (%s)", strerror(errno)); + log_warn("DIOCKILLSTATES failed"); } /* Kill all states to target */ @@ -189,7 +189,7 @@ pf_kill_state(int fd, struct in_addr ip) memset(&psk.psk_dst.addr.v.a.mask, 0xff, sizeof(psk.psk_dst.addr.v.a.mask)); if (ioctl(fd, DIOCKILLSTATES, &psk)) { - log_warnx("DIOCKILLSTATES failed (%s)", strerror(errno)); + log_warn("DIOCKILLSTATES failed"); } } diff --git a/usr.sbin/dhcpd/sync.c b/usr.sbin/dhcpd/sync.c index 781e1f328af..f231cd3519a 100644 --- a/usr.sbin/dhcpd/sync.c +++ b/usr.sbin/dhcpd/sync.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sync.c,v 1.20 2017/02/13 19:13:14 krw Exp $ */ +/* $OpenBSD: sync.c,v 1.21 2017/02/13 21:53:53 krw Exp $ */ /* * Copyright (c) 2008 Bob Beck <beck@openbsd.org> @@ -143,8 +143,7 @@ sync_init(const char *iface, const char *baddr, u_short port) sync_key = SHA1File(DHCP_SYNC_KEY, NULL); if (sync_key == NULL) { if (errno != ENOENT) { - fprintf(stderr, "failed to open sync key: %s\n", - strerror(errno)); + log_warn("failed to open sync key"); return (-1); } /* Use empty key by default */ @@ -206,14 +205,13 @@ sync_init(const char *iface, const char *baddr, u_short port) if (setsockopt(syncfd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) == -1) { - fprintf(stderr, "failed to add multicast membership to %s: %s", - DHCP_SYNC_MCASTADDR, strerror(errno)); + log_warn("failed to add multicast membership to %s", + DHCP_SYNC_MCASTADDR); goto fail; } if (setsockopt(syncfd, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof(ttl)) == -1) { - fprintf(stderr, "failed to set multicast ttl to " - "%u: %s\n", ttl, strerror(errno)); + log_warn("failed to set multicast ttl to %u", ttl); setsockopt(syncfd, IPPROTO_IP, IP_DROP_MEMBERSHIP, &mreq, sizeof(mreq)); goto fail; diff --git a/usr.sbin/dhcpd/udpsock.c b/usr.sbin/dhcpd/udpsock.c index f88cc72a596..fedd9a4399b 100644 --- a/usr.sbin/dhcpd/udpsock.c +++ b/usr.sbin/dhcpd/udpsock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udpsock.c,v 1.8 2017/02/13 19:13:14 krw Exp $ */ +/* $OpenBSD: udpsock.c,v 1.9 2017/02/13 21:53:53 krw Exp $ */ /* * Copyright (c) 2014 YASUOKA Masahiko <yasuoka@openbsd.org> @@ -55,16 +55,15 @@ udpsock_startup(struct in_addr bindaddr) struct udpsock *udpsock; if ((udpsock = calloc(1, sizeof(struct udpsock))) == NULL) - fatalx("could not create udpsock: %s", strerror(errno)); + fatal("could not create udpsock"); memset(&sin4, 0, sizeof(sin4)); if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) - fatalx("creating a socket failed for udp: %s", strerror(errno)); + fatal("creating a socket failed for udp"); onoff = 1; if (setsockopt(sock, IPPROTO_IP, IP_RECVIF, &onoff, sizeof(onoff)) != 0) - fatalx("setsocketopt IP_RECVIF failed for udp: %s", - strerror(errno)); + fatal("setsocketopt IP_RECVIF failed for udp"); sin4.sin_family = AF_INET; sin4.sin_len = sizeof(sin4); @@ -72,7 +71,7 @@ udpsock_startup(struct in_addr bindaddr) sin4.sin_port = server_port; if (bind(sock, (struct sockaddr *)&sin4, sizeof(sin4)) != 0) - fatalx("bind failed for udp: %s", strerror(errno)); + fatal("bind failed for udp"); add_protocol("udp", sock, udpsock_handler, (void *)(intptr_t)udpsock); log_info("Listening on %s:%d/udp.", inet_ntoa(sin4.sin_addr), @@ -116,7 +115,7 @@ udpsock_handler(struct protocol *protocol) memset(&iface, 0, sizeof(iface)); if ((len = recvmsg(udpsock->sock, &m, 0)) < 0) { - log_warnx("receiving a DHCP message failed: %s", strerror(errno)); + log_warn("receiving a DHCP message failed"); return; } if (ss.ss_family != AF_INET) { @@ -138,13 +137,12 @@ udpsock_handler(struct protocol *protocol) if_indextoname(sdl->sdl_index, ifname); if ((sockio = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { - log_warnx("socket creation failed: %s", strerror(errno)); + log_warn("socket creation failed"); return; } strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); if (ioctl(sockio, SIOCGIFADDR, &ifr, sizeof(ifr)) != 0) { - log_warnx("Failed to get address for %s: %s", ifname, - strerror(errno)); + log_warn("Failed to get address for %s", ifname); close(sockio); return; } |