git: 9d53ea06b320 - stable/14 - arp(8): Complete libxo transition

From: Eugene Grosbein <eugen_at_FreeBSD.org>
Date: Thu, 16 Oct 2025 07:15:19 UTC
The branch stable/14 has been updated by eugen:

URL: https://cgit.FreeBSD.org/src/commit/?id=9d53ea06b32097a648fedbaf4abbe8ee54951225

commit 9d53ea06b32097a648fedbaf4abbe8ee54951225
Author:     Yan-Hao Wang <yanhaowang@FreeBSD.org>
AuthorDate: 2024-10-12 14:38:45 +0000
Commit:     Eugene Grosbein <eugen@FreeBSD.org>
CommitDate: 2025-10-16 07:15:04 +0000

    arp(8): Complete libxo transition
    
    Reviewed by:    des
    MFC after:      3 days
    Differential Revision:  https://reviews.freebsd.org/D41408
    
    (cherry picked from commit 417842f908619336dd4c739a92c326ade2c35770)
---
 usr.sbin/arp/arp.c         | 11 ++++++-----
 usr.sbin/arp/arp_netlink.c |  5 ++---
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/usr.sbin/arp/arp.c b/usr.sbin/arp/arp.c
index 200912736137..fba6bdd57ed5 100644
--- a/usr.sbin/arp/arp.c
+++ b/usr.sbin/arp/arp.c
@@ -67,7 +67,6 @@ static char const sccsid[] = "@(#)from: arp.c	8.2 (Berkeley) 1/2/94";
 #include <arpa/inet.h>
 
 #include <ctype.h>
-#include <err.h>
 #include <errno.h>
 #include <netdb.h>
 #include <nlist.h>
@@ -181,7 +180,8 @@ main(int argc, char *argv[])
 
 			xo_close_list("arp-cache");
 			xo_close_container("arp");
-			xo_finish();
+			if (xo_finish() < 0)
+				xo_err(1, "stdout");
 		} else {
 			if (argc != 1)
 				usage();
@@ -218,7 +218,7 @@ main(int argc, char *argv[])
 	if (ifnameindex != NULL)
 		if_freenameindex(ifnameindex);
 
-	return (rtn);
+	exit(rtn);
 }
 
 /*
@@ -458,7 +458,8 @@ get(char *host)
 
 	xo_close_list("arp-cache");
 	xo_close_container("arp");
-	xo_finish();
+	if (xo_finish() < 0)
+		xo_err(1, "stdout");
 
 	return (found == 0);
 }
@@ -735,7 +736,7 @@ nuke_entries(uint32_t ifindex, struct in_addr addr)
 static void
 usage(void)
 {
-	fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
+	xo_error("%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
 	    "usage: arp [-n] [-i interface] hostname",
 	    "       arp [-n] [-i interface] -a",
 	    "       arp -d hostname [pub]",
diff --git a/usr.sbin/arp/arp_netlink.c b/usr.sbin/arp/arp_netlink.c
index 24e01126044b..db1ef775dea2 100644
--- a/usr.sbin/arp/arp_netlink.c
+++ b/usr.sbin/arp/arp_netlink.c
@@ -2,7 +2,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdbool.h>
-#include <err.h>
 #include <errno.h>
 #include <netdb.h>
 
@@ -43,12 +42,12 @@ nl_init_socket(struct snl_state *ss)
 	if (modfind("netlink") == -1 && errno == ENOENT) {
 		/* Try to load */
 		if (kldload("netlink") == -1)
-			err(1, "netlink is not loaded and load attempt failed");
+			xo_err(1, "netlink is not loaded and load attempt failed");
 		if (snl_init(ss, NETLINK_ROUTE))
 			return;
 	}
 
-	err(1, "unable to open netlink socket");
+	xo_err(1, "unable to open netlink socket");
 }
 
 static bool