summaryrefslogtreecommitdiffstats
path: root/usr.bin/netstat
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/netstat')
-rw-r--r--usr.bin/netstat/mbuf.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.bin/netstat/mbuf.c b/usr.bin/netstat/mbuf.c
index e7de17e..9cf319b 100644
--- a/usr.bin/netstat/mbuf.c
+++ b/usr.bin/netstat/mbuf.c
@@ -138,7 +138,7 @@ mbpr(u_long mbaddr, u_long mbtaddr, u_long nmbcaddr, u_long nmbufaddr,
}
#endif
- mlen = sizeof mbstat;
+ mlen = sizeof *mbstat;
if ((mbstat = malloc(mlen)) == NULL) {
warn("malloc: cannot allocate memory for mbstat");
goto err;
@@ -190,6 +190,7 @@ mbpr(u_long mbaddr, u_long mbtaddr, u_long nmbcaddr, u_long nmbufaddr,
warn("sysctl: retrieving mb_statpcpu");
goto err;
}
+ mlen = sizeof *mbstat;
if (sysctlbyname("kern.ipc.mbstat", mbstat, &mlen, NULL, 0)
< 0) {
warn("sysctl: retrieving mbstat");
@@ -227,8 +228,9 @@ mbpr(u_long mbaddr, u_long mbtaddr, u_long nmbcaddr, u_long nmbufaddr,
goto err;
}
mlen = sizeof(int);
- if (sysctlbyname("kern.smp.cpus", &ncpu, &mlen, NULL, 0) < 0) {
- warn("sysctl: retrieving kern.smp.cpus");
+ if (sysctlbyname("kern.smp.cpus", &ncpu, &mlen, NULL, 0) < 0 &&
+ sysctlbyname("hw.ncpu", &ncpu, &mlen, NULL, 0) < 0) {
+ warn("sysctl: retrieving number of cpus");
goto err;
}
mlen = sizeof(int);
OpenPOWER on IntegriCloud