summaryrefslogtreecommitdiff
path: root/usr.bin/systat
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2004-11-25 23:08:14 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2004-11-25 23:08:14 +0000
commitce6dd7e9d5c086e064842d58cdd3fda48f91e915 (patch)
tree3cc375d7c6245fa85a51df6da8eeca4809527253 /usr.bin/systat
parentae6bacd0fee6a83a03a7269262e4c494ae0d65e6 (diff)
fix on alpha. the lack of BWX by default, and assumptions of alignment
keep biting us hard for structures that happen to have been plopped at unaligned objects. terrible decisions made at DEC ages ago, and compounded by terrible gcc decisions cause us to make workarounds all the time. showed by markus, found by David Berghoff
Diffstat (limited to 'usr.bin/systat')
-rw-r--r--usr.bin/systat/if.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/usr.bin/systat/if.c b/usr.bin/systat/if.c
index 0045695b85e..8153ee3c3d8 100644
--- a/usr.bin/systat/if.c
+++ b/usr.bin/systat/if.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if.c,v 1.1 2004/11/16 09:52:33 markus Exp $ */
+/* $OpenBSD: if.c,v 1.2 2004/11/25 23:08:13 deraadt Exp $ */
/*
* Copyright (c) 2004 Markus Friedl <markus@openbsd.org>
*
@@ -75,7 +75,7 @@ initifstat(void)
}
#define UPDATE(x, y) do { \
- ifs->ifs_now.x = ifm->y; \
+ ifs->ifs_now.x = ifm.y; \
ifs->ifs_cur.x = ifs->ifs_now.x - ifs->ifs_old.x; \
sum.x += ifs->ifs_cur.x; \
if (state == TIME) \
@@ -102,7 +102,7 @@ void
fetchifstat(void)
{
struct ifstat *newstats, *ifs;
- struct if_msghdr *ifm;
+ struct if_msghdr ifm;
struct sockaddr *info[RTAX_MAX];
struct sockaddr_dl *sdl;
char *buf, *next, *lim;
@@ -128,24 +128,25 @@ fetchifstat(void)
bzero(&sum, sizeof(sum));
lim = buf + need;
- for (next = buf; next < lim; next += ifm->ifm_msglen) {
- ifm = (struct if_msghdr *)next;
- if (ifm->ifm_type != RTM_IFINFO ||
- !(ifm->ifm_addrs & RTA_IFP))
+ for (next = buf; next < lim; next += ifm.ifm_msglen) {
+ bcopy(next, &ifm, sizeof ifm);
+ if (ifm.ifm_type != RTM_IFINFO ||
+ !(ifm.ifm_addrs & RTA_IFP))
continue;
- if (ifm->ifm_index >= nifs) {
- if ((newstats = realloc(ifstats, (ifm->ifm_index + 4) *
+ if (ifm.ifm_index >= nifs) {
+ if ((newstats = realloc(ifstats, (ifm.ifm_index + 4) *
sizeof(struct ifstat))) == NULL)
continue;
ifstats = newstats;
- for (; nifs < ifm->ifm_index + 4; nifs++)
+ for (; nifs < ifm.ifm_index + 4; nifs++)
ifstats[nifs].ifs_name[0] = '\0';
}
- ifs = &ifstats[ifm->ifm_index];
+ ifs = &ifstats[ifm.ifm_index];
if (ifs->ifs_name[0] == '\0') {
bzero(&info, sizeof(info));
- rt_getaddrinfo((struct sockaddr *)(ifm + 1),
- ifm->ifm_addrs, info);
+ rt_getaddrinfo(
+ (struct sockaddr *)((struct if_msghdr *)next + 1),
+ ifm.ifm_addrs, info);
if ((sdl = (struct sockaddr_dl *)info[RTAX_IFP])) {
if (sdl->sdl_family == AF_LINK &&
sdl->sdl_nlen > 0)