Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F107622845
D41427.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
21 KB
Referenced Files
None
Subscribers
None
D41427.diff
View Options
diff --git a/usr.bin/netstat/bpf.c b/usr.bin/netstat/bpf.c
--- a/usr.bin/netstat/bpf.c
+++ b/usr.bin/netstat/bpf.c
@@ -39,7 +39,6 @@
#include <net/bpfdesc.h>
#include <arpa/inet.h>
-#include <err.h>
#include <errno.h>
#include <stdint.h>
#include <stdio.h>
diff --git a/usr.bin/netstat/common.c b/usr.bin/netstat/common.c
--- a/usr.bin/netstat/common.c
+++ b/usr.bin/netstat/common.c
@@ -50,7 +50,6 @@
#include <string.h>
#include <sysexits.h>
#include <unistd.h>
-#include <err.h>
#include <libxo/xo.h>
#include "netstat.h"
#include "common.h"
@@ -100,7 +99,7 @@
* since we need #ifindex -> if_xname match
*/
if (getifaddrs(&ifap) != 0)
- err(EX_OSERR, "getifaddrs");
+ xo_err(EX_OSERR, "getifaddrs");
for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
@@ -114,7 +113,7 @@
size = roundup2(ifindex + 1, 32) *
sizeof(struct ifmap_entry);
if ((ifmap = realloc(ifmap, size)) == NULL)
- errx(2, "realloc(%d) failed", size);
+ xo_errx(EX_OSERR, "realloc(%d) failed", size);
memset(&ifmap[ifmap_size], 0,
size - ifmap_size *
sizeof(struct ifmap_entry));
diff --git a/usr.bin/netstat/if.c b/usr.bin/netstat/if.c
--- a/usr.bin/netstat/if.c
+++ b/usr.bin/netstat/if.c
@@ -49,7 +49,6 @@
#include <net/if_pfsync.h>
#endif
-#include <err.h>
#include <errno.h>
#include <ifaddrs.h>
#include <libutil.h>
@@ -395,9 +394,9 @@
return sidewaysintpr();
if (getifaddrs(&ifap) != 0)
- err(EX_OSERR, "getifaddrs");
+ xo_err(EX_OSERR, "getifaddrs");
if (aflag && getifmaddrs(&ifmap) != 0)
- err(EX_OSERR, "getifmaddrs");
+ xo_err(EX_OSERR, "getifmaddrs");
for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
if (interface != NULL &&
diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c
--- a/usr.bin/netstat/inet.c
+++ b/usr.bin/netstat/inet.c
@@ -63,7 +63,6 @@
#include <netinet/udp_var.h>
#include <arpa/inet.h>
-#include <err.h>
#include <errno.h>
#include <libutil.h>
#include <netdb.h>
diff --git a/usr.bin/netstat/inet6.c b/usr.bin/netstat/inet6.c
--- a/usr.bin/netstat/inet6.c
+++ b/usr.bin/netstat/inet6.c
@@ -54,7 +54,6 @@
#include <arpa/inet.h>
#include <netdb.h>
-#include <err.h>
#include <stdint.h>
#include <stdio.h>
#include <stdbool.h>
diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c
--- a/usr.bin/netstat/main.c
+++ b/usr.bin/netstat/main.c
@@ -46,7 +46,6 @@
#endif
#include <ctype.h>
-#include <err.h>
#include <errno.h>
#ifdef JAIL
#include <jail.h>
@@ -61,6 +60,7 @@
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
+#include <sysexits.h>
#include <unistd.h>
#include "netstat.h"
#include "nl_defs.h"
@@ -258,14 +258,14 @@
#ifdef INET
af = AF_INET;
#else
- errx(1, "IPv4 support is not compiled in");
+ xo_errx(EX_UNAVAILABLE, "IPv4 support is not compiled in");
#endif
break;
case '6':
#ifdef INET6
af = AF_INET6;
#else
- errx(1, "IPv6 support is not compiled in");
+ xo_errx(EX_UNAVAILABLE, "IPv6 support is not compiled in");
#endif
break;
case 'A':
@@ -293,7 +293,7 @@
fib = strtol(optarg, &endptr, 0);
if (*endptr != '\0' ||
(fib == 0 && (errno == EINVAL || errno == ERANGE)))
- xo_errx(1, "%s: invalid fib", optarg);
+ xo_errx(EX_DATAERR, "%s: invalid fib", optarg);
break;
case 'f':
if (strcmp(optarg, "inet") == 0)
@@ -317,7 +317,7 @@
else if (strcmp(optarg, "link") == 0)
af = AF_LINK;
else {
- xo_errx(1, "%s: unknown address family",
+ xo_errx(EX_DATAERR, "%s: unknown address family",
optarg);
}
break;
@@ -345,7 +345,7 @@
usage();
jail_name = optarg;
#else
- errx(1, "Jail support is not compiled in");
+ xo_errx(EX_UNAVAILABLE, "Jail support is not compiled in");
#endif
break;
case 'L':
@@ -374,7 +374,7 @@
break;
case 'p':
if ((tp = name2protox(optarg)) == NULL) {
- xo_errx(1, "%s: unknown or uninstrumented "
+ xo_errx(EX_DATAERR, "%s: unknown or uninstrumented "
"protocol", optarg);
}
pflag = 1;
@@ -448,9 +448,9 @@
if (jail_name != NULL) {
jid = jail_getid(jail_name);
if (jid == -1)
- errx(1, "Jail not found");
+ xo_errx(EX_UNAVAILABLE, "Jail not found");
if (jail_attach(jid) != 0)
- errx(1, "Cannot attach to jail");
+ xo_errx(EX_UNAVAILABLE, "Cannot attach to jail");
}
#endif
@@ -461,20 +461,21 @@
live = (nlistf == NULL && memf == NULL);
if (!live) {
if (setgid(getgid()) != 0)
- xo_err(-1, "setgid");
+ xo_err(EX_OSERR, "setgid");
/* Load all necessary kvm symbols */
kresolve_list(nl);
}
if (xflag && Tflag)
- xo_errx(1, "-x and -T are incompatible, pick one.");
+ xo_errx(EX_USAGE, "-x and -T are incompatible, pick one.");
if (Bflag) {
if (!live)
usage();
bpf_stats(interface);
- xo_finish();
- exit(0);
+ if (xo_finish() < 0)
+ xo_err(EX_IOERR, "stdout");
+ exit(EX_OK);
}
if (mflag) {
if (!live) {
@@ -482,8 +483,9 @@
mbpr(kvmd, nl[N_SFSTAT].n_value);
} else
mbpr(NULL, 0);
- xo_finish();
- exit(0);
+ if (xo_finish() < 0)
+ xo_err(EX_IOERR, "stdout");
+ exit(EX_OK);
}
if (Qflag) {
if (!live) {
@@ -491,8 +493,9 @@
netisr_stats();
} else
netisr_stats();
- xo_finish();
- exit(0);
+ if (xo_finish() < 0)
+ xo_err(EX_IOERR, "stdout");
+ exit(EX_OK);
}
#if 0
/*
@@ -513,8 +516,9 @@
xo_set_version(NETSTAT_XO_VERSION);
intpr(NULL, af);
xo_close_container("statistics");
- xo_finish();
- exit(0);
+ if (xo_finish() < 0)
+ xo_err(EX_IOERR, "stdout");
+ exit(EX_OK);
}
if (rflag) {
xo_open_container("statistics");
@@ -527,24 +531,27 @@
} else
routepr(fib, af);
xo_close_container("statistics");
- xo_finish();
- exit(0);
+ if (xo_finish() < 0)
+ xo_err(EX_IOERR, "stdout");
+ exit(EX_OK);
}
if (oflag) {
xo_open_container("statistics");
xo_set_version(NETSTAT_XO_VERSION);
nhops_print(fib, af);
xo_close_container("statistics");
- xo_finish();
- exit(0);
+ if (xo_finish() < 0)
+ xo_err(EX_IOERR, "stdout");
+ exit(EX_OK);
}
if (Oflag) {
xo_open_container("statistics");
xo_set_version(NETSTAT_XO_VERSION);
nhgrp_print(fib, af);
xo_close_container("statistics");
- xo_finish();
- exit(0);
+ if (xo_finish() < 0)
+ xo_err(EX_IOERR, "stdout");
+ exit(EX_OK);
}
@@ -568,8 +575,9 @@
#endif
}
xo_close_container("statistics");
- xo_finish();
- exit(0);
+ if (xo_finish() < 0)
+ xo_err(EX_IOERR, "stdout");
+ exit(EX_OK);
}
if (tp) {
@@ -579,8 +587,9 @@
if (!first)
xo_close_list("socket");
xo_close_container("statistics");
- xo_finish();
- exit(0);
+ if (xo_finish() < 0)
+ xo_err(EX_IOERR, "stdout");
+ exit(EX_OK);
}
xo_open_container("statistics");
@@ -611,8 +620,9 @@
if (!first)
xo_close_list("socket");
xo_close_container("statistics");
- xo_finish();
- exit(0);
+ if (xo_finish() < 0)
+ xo_err(EX_IOERR, "stdout");
+ exit(EX_OK);
}
static int
@@ -732,7 +742,7 @@
kvmd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, errbuf);
if (setgid(getgid()) != 0)
- xo_err(-1, "setgid");
+ xo_err(EX_OSERR, "setgid");
if (kvmd == NULL) {
xo_warnx("kvm not available: %s", errbuf);
@@ -757,10 +767,10 @@
if (kvm_nlist(kvmd, _nl) < 0) {
if (nlistf)
- xo_errx(1, "%s: kvm_nlist: %s", nlistf,
+ xo_errx(EX_UNAVAILABLE, "%s: kvm_nlist: %s", nlistf,
kvm_geterr(kvmd));
else
- xo_errx(1, "kvm_nlist: %s", kvm_geterr(kvmd));
+ xo_errx(EX_UNAVAILABLE, "kvm_nlist: %s", kvm_geterr(kvmd));
}
return (0);
@@ -774,10 +784,10 @@
{
if ((kvmd == NULL) && (kvmd_init() != 0))
- xo_errx(-1, "%s: kvm is not available", __func__);
+ xo_errx(EX_UNAVAILABLE, "%s: kvm is not available", __func__);
if (kvm_dpcpu_setcpu(kvmd, cpuid) < 0)
- xo_errx(-1, "%s: kvm_dpcpu_setcpu(%u): %s", __func__,
+ xo_errx(EX_UNAVAILABLE, "%s: kvm_dpcpu_setcpu(%u): %s", __func__,
cpuid, kvm_geterr(kvmd));
return;
}
@@ -834,7 +844,7 @@
n = size / sizeof(uint64_t);
if ((counters = malloc(n * sizeof(u_long))) == NULL)
- xo_err(-1, "malloc");
+ xo_err(EX_OSERR, "malloc");
if (kread(addr, counters, n * sizeof(u_long)) < 0) {
free(counters);
return (-1);
@@ -914,7 +924,7 @@
static void
usage(void)
{
- (void)xo_error("%s\n%s\n%s\n%s\n%s\n%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%s\n%s\n%s\n%s\n%s\n",
"usage: netstat [-j jail] [-46AaCcLnRSTWx] [-f protocol_family | -p protocol]\n"
" [-M core] [-N system]",
" netstat [-j jail] -i | -I interface [-46abdhnW] [-f address_family]\n"
@@ -933,6 +943,5 @@
" netstat [-j jail] -g [-46W] [-f address_family] [-M core] [-N system]",
" netstat [-j jail] -gs [-46s] [-f address_family] [-M core] [-N system]",
" netstat [-j jail] -Q");
- xo_finish();
- exit(1);
+ exit(EX_USAGE);
}
diff --git a/usr.bin/netstat/mbuf.c b/usr.bin/netstat/mbuf.c
--- a/usr.bin/netstat/mbuf.c
+++ b/usr.bin/netstat/mbuf.c
@@ -43,7 +43,6 @@
#include <sys/socketvar.h>
#include <sys/sysctl.h>
-#include <err.h>
#include <kvm.h>
#include <memstat.h>
#include <stdint.h>
diff --git a/usr.bin/netstat/mroute.c b/usr.bin/netstat/mroute.c
--- a/usr.bin/netstat/mroute.c
+++ b/usr.bin/netstat/mroute.c
@@ -62,7 +62,6 @@
#include <netinet/ip_mroute.h>
#undef _NETSTAT_
-#include <err.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/usr.bin/netstat/mroute6.c b/usr.bin/netstat/mroute6.c
--- a/usr.bin/netstat/mroute6.c
+++ b/usr.bin/netstat/mroute6.c
@@ -81,7 +81,6 @@
#include <netinet/in.h>
-#include <err.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/usr.bin/netstat/netgraph.c b/usr.bin/netstat/netgraph.c
--- a/usr.bin/netstat/netgraph.c
+++ b/usr.bin/netstat/netgraph.c
@@ -53,7 +53,6 @@
#include <stdbool.h>
#include <string.h>
#include <unistd.h>
-#include <err.h>
#include <libxo/xo.h>
#include "netstat.h"
diff --git a/usr.bin/netstat/netisr.c b/usr.bin/netstat/netisr.c
--- a/usr.bin/netstat/netisr.c
+++ b/usr.bin/netstat/netisr.c
@@ -40,12 +40,12 @@
#include <net/netisr.h>
#include <net/netisr_internal.h>
-#include <err.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
+#include <sysexits.h>
#include <libxo/xo.h>
#include "netstat.h"
#include "nl_defs.h"
@@ -112,7 +112,7 @@
for (i = 0; i < limit; i++) {
if (kread(addr + i, &dest[i], sizeof(dest[i])) != 0)
- xo_errx(-1, "%s: kread()", __func__);
+ xo_errx(EX_OSERR, "%s: kread()", __func__);
if (dest[i] == '\0')
break;
}
@@ -167,9 +167,9 @@
retlen = sizeof(u_int);
if (sysctlbyname(name, p, &retlen, NULL, 0) < 0)
- xo_err(-1, "%s", name);
+ xo_err(EX_OSERR, "%s", name);
if (retlen != sizeof(u_int))
- xo_errx(-1, "%s: invalid len %ju", name, (uintmax_t)retlen);
+ xo_errx(EX_DATAERR, "%s: invalid len %ju", name, (uintmax_t)retlen);
}
static void
@@ -179,7 +179,7 @@
retlen = len;
if (sysctlbyname(name, p, &retlen, NULL, 0) < 0)
- xo_err(-1, "%s", name);
+ xo_err(EX_OSERR, "%s", name);
p[len - 1] = '\0';
}
@@ -212,13 +212,13 @@
*/
kread(nl[N_NETISR_MAXPROT].n_value, &maxprot, sizeof(u_int));
if (maxprot != NETISR_MAXPROT)
- xo_errx(-1, "%s: NETISR_MAXPROT mismatch", __func__);
+ xo_errx(EX_DATAERR, "%s: NETISR_MAXPROT mismatch", __func__);
len = maxprot * sizeof(*np_array);
np_array = malloc(len);
if (np_array == NULL)
- xo_err(-1, "%s: malloc", __func__);
+ xo_err(EX_OSERR, "%s: malloc", __func__);
if (kread(nl[N_NETISR_PROTO].n_value, np_array, len) != 0)
- xo_errx(-1, "%s: kread(_netisr_proto)", __func__);
+ xo_errx(EX_DATAERR, "%s: kread(_netisr_proto)", __func__);
/*
* Size and allocate memory to hold only live protocols.
@@ -231,7 +231,7 @@
}
proto_array = calloc(protocount, sizeof(*proto_array));
if (proto_array == NULL)
- err(-1, "malloc");
+ xo_err(EX_OSERR, "malloc");
protocount = 0;
for (i = 0; i < maxprot; i++) {
npp = &np_array[i];
@@ -263,21 +263,21 @@
size_t len;
if (sysctlbyname("net.isr.proto", NULL, &len, NULL, 0) < 0)
- xo_err(-1, "net.isr.proto: query len");
+ xo_err(EX_OSERR, "net.isr.proto: query len");
if (len % sizeof(*proto_array) != 0)
- xo_errx(-1, "net.isr.proto: invalid len");
+ xo_errx(EX_DATAERR, "net.isr.proto: invalid len");
proto_array = malloc(len);
if (proto_array == NULL)
- xo_err(-1, "malloc");
+ xo_err(EX_OSERR, "malloc");
if (sysctlbyname("net.isr.proto", proto_array, &len, NULL, 0) < 0)
- xo_err(-1, "net.isr.proto: query data");
+ xo_err(EX_OSERR, "net.isr.proto: query data");
if (len % sizeof(*proto_array) != 0)
- xo_errx(-1, "net.isr.proto: invalid len");
+ xo_errx(EX_DATAERR, "net.isr.proto: invalid len");
proto_array_len = len / sizeof(*proto_array);
if (proto_array_len < 1)
- xo_errx(-1, "net.isr.proto: no data");
+ xo_errx(EX_DATAERR, "net.isr.proto: no data");
if (proto_array[0].snp_version != sizeof(proto_array[0]))
- xo_errx(-1, "net.isr.proto: invalid version");
+ xo_errx(EX_DATAERR, "net.isr.proto: invalid version");
}
static void
@@ -293,22 +293,22 @@
len = numthreads * sizeof(*nws_array);
nws_array = malloc(len);
if (nws_array == NULL)
- xo_err(-1, "malloc");
+ xo_err(EX_OSERR, "malloc");
if (kread(nl[N_NWS_ARRAY].n_value, nws_array, len) != 0)
- xo_errx(-1, "%s: kread(_nws_array)", __func__);
+ xo_errx(EX_OSERR, "%s: kread(_nws_array)", __func__);
workstream_array = calloc(numthreads, sizeof(*workstream_array));
if (workstream_array == NULL)
- xo_err(-1, "calloc");
+ xo_err(EX_OSERR, "calloc");
workstream_array_len = numthreads;
work_array = calloc(numthreads * proto_array_len, sizeof(*work_array));
if (work_array == NULL)
- xo_err(-1, "calloc");
+ xo_err(EX_OSERR, "calloc");
counter = 0;
for (wsid = 0; wsid < numthreads; wsid++) {
cpuid = nws_array[wsid];
kset_dpcpu(cpuid);
if (kread(nl[N_NWS].n_value, &nws, sizeof(nws)) != 0)
- xo_errx(-1, "%s: kread(nw)", __func__);
+ xo_errx(EX_OSERR, "%s: kread(nw)", __func__);
snwsp = &workstream_array[wsid];
snwsp->snws_version = sizeof(*snwsp);
snwsp->snws_wsid = cpuid;
@@ -348,22 +348,22 @@
size_t len;
if (sysctlbyname("net.isr.workstream", NULL, &len, NULL, 0) < 0)
- xo_err(-1, "net.isr.workstream: query len");
+ xo_err(EX_OSERR, "net.isr.workstream: query len");
if (len % sizeof(*workstream_array) != 0)
- xo_errx(-1, "net.isr.workstream: invalid len");
+ xo_errx(EX_DATAERR, "net.isr.workstream: invalid len");
workstream_array = malloc(len);
if (workstream_array == NULL)
- xo_err(-1, "malloc");
+ xo_err(EX_OSERR, "malloc");
if (sysctlbyname("net.isr.workstream", workstream_array, &len, NULL,
0) < 0)
- xo_err(-1, "net.isr.workstream: query data");
+ xo_err(EX_OSERR, "net.isr.workstream: query data");
if (len % sizeof(*workstream_array) != 0)
- xo_errx(-1, "net.isr.workstream: invalid len");
+ xo_errx(EX_DATAERR, "net.isr.workstream: invalid len");
workstream_array_len = len / sizeof(*workstream_array);
if (workstream_array_len < 1)
- xo_errx(-1, "net.isr.workstream: no data");
+ xo_errx(EX_DATAERR, "net.isr.workstream: no data");
if (workstream_array[0].snws_version != sizeof(workstream_array[0]))
- xo_errx(-1, "net.isr.workstream: invalid version");
+ xo_errx(EX_DATAERR, "net.isr.workstream: invalid version");
}
static void
@@ -372,21 +372,21 @@
size_t len;
if (sysctlbyname("net.isr.work", NULL, &len, NULL, 0) < 0)
- xo_err(-1, "net.isr.work: query len");
+ xo_err(EX_OSERR, "net.isr.work: query len");
if (len % sizeof(*work_array) != 0)
- xo_errx(-1, "net.isr.work: invalid len");
+ xo_errx(EX_DATAERR, "net.isr.work: invalid len");
work_array = malloc(len);
if (work_array == NULL)
- xo_err(-1, "malloc");
+ xo_err(EX_OSERR, "malloc");
if (sysctlbyname("net.isr.work", work_array, &len, NULL, 0) < 0)
- xo_err(-1, "net.isr.work: query data");
+ xo_err(EX_OSERR, "net.isr.work: query data");
if (len % sizeof(*work_array) != 0)
- xo_errx(-1, "net.isr.work: invalid len");
+ xo_errx(EX_DATAERR, "net.isr.work: invalid len");
work_array_len = len / sizeof(*work_array);
if (work_array_len < 1)
- xo_errx(-1, "net.isr.work: no data");
+ xo_errx(EX_DATAERR, "net.isr.work: no data");
if (work_array[0].snw_version != sizeof(work_array[0]))
- xo_errx(-1, "net.isr.work: invalid version");
+ xo_errx(EX_DATAERR, "net.isr.work: invalid version");
}
static void
diff --git a/usr.bin/netstat/nhgrp.c b/usr.bin/netstat/nhgrp.c
--- a/usr.bin/netstat/nhgrp.c
+++ b/usr.bin/netstat/nhgrp.c
@@ -45,7 +45,6 @@
#include <string.h>
#include <sysexits.h>
#include <unistd.h>
-#include <err.h>
#include <libxo/xo.h>
#include "netstat.h"
#include "common.h"
@@ -209,12 +208,12 @@
mib[5] = 0;
mib[6] = fibnum;
if (sysctl(mib, nitems(mib), NULL, &needed, NULL, 0) < 0)
- err(EX_OSERR, "sysctl: net.route.0.%d.nhgrpdump.%d estimate",
+ xo_err(EX_OSERR, "sysctl: net.route.0.%d.nhgrpdump.%d estimate",
af, fibnum);
if ((buf = malloc(needed)) == NULL)
- errx(2, "malloc(%lu)", (unsigned long)needed);
+ xo_errx(EX_OSERR, "malloc(%lu)", (unsigned long)needed);
if (sysctl(mib, nitems(mib), buf, &needed, NULL, 0) < 0)
- err(1, "sysctl: net.route.0.%d.nhgrpdump.%d", af, fibnum);
+ xo_err(EX_OSERR, "sysctl: net.route.0.%d.nhgrpdump.%d", af, fibnum);
lim = buf + needed;
/*
@@ -337,7 +336,7 @@
if (sysctlbyname("net.fibs", &numfibs, &intsize, NULL, 0) == -1)
numfibs = 1;
if (fibnum < 0 || fibnum > numfibs - 1)
- errx(EX_USAGE, "%d: invalid fib", fibnum);
+ xo_errx(EX_USAGE, "%d: invalid fib", fibnum);
ifmap = prepare_ifmap(&ifmap_size);
prepare_nh_map(fibnum, af);
diff --git a/usr.bin/netstat/nhops.c b/usr.bin/netstat/nhops.c
--- a/usr.bin/netstat/nhops.c
+++ b/usr.bin/netstat/nhops.c
@@ -58,7 +58,6 @@
#include <string.h>
#include <sysexits.h>
#include <unistd.h>
-#include <err.h>
#include <libxo/xo.h>
#include "netstat.h"
#include "common.h"
@@ -213,7 +212,7 @@
sz = new_size * (sizeof(struct nhop_entry));
if ((map->ptr = realloc(map->ptr, sz)) == NULL)
- errx(2, "realloc(%zu) failed", sz);
+ xo_errx(EX_OSERR, "realloc(%zu) failed", sz);
memset(&map->ptr[map->size], 0, (new_size - map->size) * sizeof(struct nhop_entry));
map->size = new_size;
@@ -352,12 +351,12 @@
mib[5] = 0;
mib[6] = fibnum;
if (sysctl(mib, nitems(mib), NULL, &needed, NULL, 0) < 0)
- err(EX_OSERR, "sysctl: net.route.0.%d.nhdump.%d estimate", af,
+ xo_err(EX_OSERR, "sysctl: net.route.0.%d.nhdump.%d estimate", af,
fibnum);
if ((buf = malloc(needed)) == NULL)
- errx(2, "malloc(%lu)", (unsigned long)needed);
+ xo_errx(EX_OSERR, "malloc(%lu)", (unsigned long)needed);
if (sysctl(mib, nitems(mib), buf, &needed, NULL, 0) < 0)
- err(1, "sysctl: net.route.0.%d.nhdump.%d", af, fibnum);
+ xo_err(EX_OSERR, "sysctl: net.route.0.%d.nhdump.%d", af, fibnum);
lim = buf + needed;
/*
@@ -463,7 +462,7 @@
if (sysctlbyname("net.fibs", &numfibs, &intsize, NULL, 0) == -1)
numfibs = 1;
if (fibnum < 0 || fibnum > numfibs - 1)
- errx(EX_USAGE, "%d: invalid fib", fibnum);
+ xo_errx(EX_USAGE, "%d: invalid fib", fibnum);
ifmap = prepare_ifmap(&ifmap_size);
diff --git a/usr.bin/netstat/route.c b/usr.bin/netstat/route.c
--- a/usr.bin/netstat/route.c
+++ b/usr.bin/netstat/route.c
@@ -57,7 +57,6 @@
#include <string.h>
#include <sysexits.h>
#include <unistd.h>
-#include <err.h>
#include <libxo/xo.h>
#include "netstat.h"
#include "common.h"
@@ -124,14 +123,14 @@
if (sysctlbyname("net.fibs", &numfibs, &intsize, NULL, 0) == -1)
numfibs = 1;
if (fibnum < 0 || fibnum > numfibs - 1)
- errx(EX_USAGE, "%d: invalid fib", fibnum);
+ xo_errx(EX_USAGE, "%d: invalid fib", fibnum);
/*
* Since kernel & userland use different timebase
* (time_uptime vs time_second) and we are reading kernel memory
* directly we should do rt_expire --> expire_time conversion.
*/
if (clock_gettime(CLOCK_UPTIME, &uptime) < 0)
- err(EX_OSERR, "clock_gettime() failed");
+ xo_err(EX_OSERR, "clock_gettime() failed");
xo_open_container("route-information");
xo_emit("{T:Routing tables}");
@@ -259,12 +258,12 @@
mib[5] = 0;
mib[6] = fibnum;
if (sysctl(mib, nitems(mib), NULL, &needed, NULL, 0) < 0)
- err(EX_OSERR, "sysctl: net.route.0.%d.dump.%d estimate", af,
+ xo_err(EX_OSERR, "sysctl: net.route.0.%d.dump.%d estimate", af,
fibnum);
if ((buf = malloc(needed)) == NULL)
- errx(2, "malloc(%lu)", (unsigned long)needed);
+ xo_errx(EX_OSERR, "malloc(%lu)", (unsigned long)needed);
if (sysctl(mib, nitems(mib), buf, &needed, NULL, 0) < 0)
- err(1, "sysctl: net.route.0.%d.dump.%d", af, fibnum);
+ xo_err(EX_OSERR, "sysctl: net.route.0.%d.dump.%d", af, fibnum);
lim = buf + needed;
xo_open_container("route-table");
xo_open_list("rt-family");
diff --git a/usr.bin/netstat/route_netlink.c b/usr.bin/netstat/route_netlink.c
--- a/usr.bin/netstat/route_netlink.c
+++ b/usr.bin/netstat/route_netlink.c
@@ -62,7 +62,6 @@
#include <string.h>
#include <sysexits.h>
#include <unistd.h>
-#include <err.h>
#include <libxo/xo.h>
#include "netstat.h"
#include "common.h"
@@ -104,7 +103,7 @@
if (link.ifi_index >= ifmap_size) {
size_t size = roundup2(link.ifi_index + 1, 32) * sizeof(struct ifmap_entry);
if ((ifmap = realloc(ifmap, size)) == NULL)
- errx(2, "realloc(%zu) failed", size);
+ xo_errx(EX_OSERR, "realloc(%zu) failed", size);
memset(&ifmap[ifmap_size], 0,
size - ifmap_size *
sizeof(struct ifmap_entry));
diff --git a/usr.bin/netstat/sctp.c b/usr.bin/netstat/sctp.c
--- a/usr.bin/netstat/sctp.c
+++ b/usr.bin/netstat/sctp.c
@@ -44,7 +44,6 @@
#include <netinet/sctp_constants.h>
#include <arpa/inet.h>
-#include <err.h>
#include <errno.h>
#include <libutil.h>
#include <netdb.h>
diff --git a/usr.bin/netstat/unix.c b/usr.bin/netstat/unix.c
--- a/usr.bin/netstat/unix.c
+++ b/usr.bin/netstat/unix.c
@@ -48,7 +48,6 @@
#include <netinet/in.h>
#include <errno.h>
-#include <err.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jan 17, 7:38 PM (19 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15842584
Default Alt Text
D41427.diff (21 KB)
Attached To
Mode
D41427: netstat: Complete libxo transition.
Attached
Detach File
Event Timeline
Log In to Comment