Index | Thread | Search

From:
Klemens Nanni <kn@openbsd.org>
Subject:
arp: print errno on failure
To:
OpenBSD tech <tech@openbsd.org>
Date:
Thu, 09 Apr 2026 21:48:25 +0000

Download raw body.

Thread
Here's an old diff, I don't remember whether I hit it or it just stood out.

getifaddrs(3) sets errno and arp.c:send_frame() also returns it,
only for errx(3) to throw it away;  that seems wrong.

Feedback? OK?

Less braces/return make it a net negative diff.

Index: arp.c
===================================================================
RCS file: /cvs/src/usr.sbin/arp/arp.c,v
diff -u -p -r1.89 arp.c
--- arp.c	4 Apr 2023 21:18:04 -0000	1.89
+++ arp.c	4 Nov 2025 23:25:12 -0000
@@ -808,7 +808,7 @@ wake(const char *ether_addr, const char 
 
 	if (iface == NULL) {
 		if (getifaddrs(&ifa) == -1)
-			errx(1, "Could not get interface addresses.");
+			err(1, "Could not get interface addresses");
 
 		for (ifap = ifa; ifap != NULL; ifap = ifap->ifa_next){
 			if (pname && !strcmp(pname, ifap->ifa_name))
@@ -848,7 +848,7 @@ do_wakeup(const char *eaddr, const char 
 	if (bind_if_to_bpf(iface, bpf) != 0)
 		errx(1, "Failed to bind %s to bpf.", iface);
 	if (send_frame(bpf, &macaddr) != 0)
-		errx(1, "Failed to send WoL frame on %s", iface);
+		err(1, "Failed to send WoL frame on %s", iface);
 	return 0;
 }
 
@@ -880,10 +880,8 @@ get_ether(const char *text, struct ether
 	if (eaddr == NULL) {
 		if (ether_hostton(text, addr))
 			return -1;
-	} else {
+	} else
 		*addr = *eaddr;
-		return 0;
-	}
 
 	return 0;
 }