summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--usr.bin/systat/ifstat.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/usr.bin/systat/ifstat.c b/usr.bin/systat/ifstat.c
index 27bf9ec..62773e9 100644
--- a/usr.bin/systat/ifstat.c
+++ b/usr.bin/systat/ifstat.c
@@ -37,6 +37,7 @@
#include <stdlib.h>
#include <string.h>
#include <err.h>
+#include <errno.h>
#include "systat.h"
#include "extern.h"
@@ -210,10 +211,9 @@ initifstat(void)
SLIST_INIT(&curlist);
for (i = 0; i < n; i++) {
- p = (struct if_stat *)malloc(sizeof(struct if_stat));
+ p = (struct if_stat *)calloc(1, sizeof(struct if_stat));
if (p == NULL)
IFSTAT_ERR(1, "out of memory");
- memset((void *)p, 0, sizeof(struct if_stat));
SLIST_INSERT_HEAD(&curlist, p, link);
p->if_row = i+1;
getifmibdata(p->if_row, &p->if_mib);
@@ -384,8 +384,8 @@ getifmibdata(int row, struct ifmibdata *data)
datalen = sizeof(*data);
name[4] = row;
- if (sysctl(name, 6, (void *)data, (size_t *)&datalen, (void *)NULL,
- (size_t)0) != 0)
+ if ((sysctl(name, 6, (void *)data, (size_t *)&datalen, (void *)NULL,
+ (size_t)0) != 0) && (errno != ENOENT))
IFSTAT_ERR(2, "sysctl error getting interface data");
}
OpenPOWER on IntegriCloud