aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXin LI <delphij@FreeBSD.org>2008-01-26 21:59:10 +0000
committerXin LI <delphij@FreeBSD.org>2008-01-26 21:59:10 +0000
commit32b1472d980d89e8414732d34ee372f59887c489 (patch)
treee7de13647e57fe319f0d2a3a4dd1dacc1578fb33
parentb5068b1ada0fd0e6e4e039e7dff028f1d9499ef5 (diff)
Notes
-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 26c81ce1413a..3d3f0753482e 100644
--- a/usr.bin/systat/ifstat.c
+++ b/usr.bin/systat/ifstat.c
@@ -43,6 +43,7 @@
#include <unistd.h>
#include <float.h>
#include <err.h>
+#include <errno.h>
#include "systat.h"
#include "extern.h"
@@ -217,10 +218,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);
@@ -391,8 +391,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");
}