fix unaligned access errors by copying untyped data to properly aligned

locals
PR: alpha/13912
obtained from: NetBSD
tested by: Marcin Gryszkalis <dagoon@rs.math.uni.lodz.pl>
This commit is contained in:
Andrew Gallatin 2000-10-26 17:35:46 +00:00
parent 870b024f5d
commit e49012e8ea
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=67642
2 changed files with 48 additions and 48 deletions

View File

@ -408,19 +408,19 @@ static int
cmp_usrsys(d1, d2)
const DBT *d1, *d2;
{
struct cmdinfo *c1, *c2;
struct cmdinfo c1, c2;
u_quad_t t1, t2;
c1 = (struct cmdinfo *) d1->data;
c2 = (struct cmdinfo *) d2->data;
memcpy(&c1, d1->data, sizeof(c1));
memcpy(&c2, d2->data, sizeof(c2));
t1 = c1->ci_utime + c1->ci_stime;
t2 = c2->ci_utime + c2->ci_stime;
t1 = c1.ci_utime + c1.ci_stime;
t2 = c2.ci_utime + c2.ci_stime;
if (t1 < t2)
return -1;
else if (t1 == t2)
return (cmp_comm(c1->ci_comm, c2->ci_comm));
return (cmp_comm(c1.ci_comm, c2.ci_comm));
else
return 1;
}
@ -430,22 +430,22 @@ static int
cmp_avgusrsys(d1, d2)
const DBT *d1, *d2;
{
struct cmdinfo *c1, *c2;
struct cmdinfo c1, c2;
double t1, t2;
c1 = (struct cmdinfo *) d1->data;
c2 = (struct cmdinfo *) d2->data;
memcpy(&c1, d1->data, sizeof(c1));
memcpy(&c2, d2->data, sizeof(c2));
t1 = c1->ci_utime + c1->ci_stime;
t1 /= (double) (c1->ci_calls ? c1->ci_calls : 1);
t1 = c1.ci_utime + c1.ci_stime;
t1 /= (double) (c1.ci_calls ? c1.ci_calls : 1);
t2 = c2->ci_utime + c2->ci_stime;
t2 /= (double) (c2->ci_calls ? c2->ci_calls : 1);
t2 = c2.ci_utime + c2.ci_stime;
t2 /= (double) (c2.ci_calls ? c2.ci_calls : 1);
if (t1 < t2)
return -1;
else if (t1 == t2)
return (cmp_comm(c1->ci_comm, c2->ci_comm));
return (cmp_comm(c1.ci_comm, c2.ci_comm));
else
return 1;
}
@ -455,15 +455,15 @@ static int
cmp_dkio(d1, d2)
const DBT *d1, *d2;
{
struct cmdinfo *c1, *c2;
struct cmdinfo c1, c2;
c1 = (struct cmdinfo *) d1->data;
c2 = (struct cmdinfo *) d2->data;
memcpy(&c1, d1->data, sizeof(c1));
memcpy(&c2, d2->data, sizeof(c2));
if (c1->ci_io < c2->ci_io)
if (c1.ci_io < c2.ci_io)
return -1;
else if (c1->ci_io == c2->ci_io)
return (cmp_comm(c1->ci_comm, c2->ci_comm));
else if (c1.ci_io == c2.ci_io)
return (cmp_comm(c1.ci_comm, c2.ci_comm));
else
return 1;
}
@ -473,19 +473,19 @@ static int
cmp_avgdkio(d1, d2)
const DBT *d1, *d2;
{
struct cmdinfo *c1, *c2;
struct cmdinfo c1, c2;
double n1, n2;
c1 = (struct cmdinfo *) d1->data;
c2 = (struct cmdinfo *) d2->data;
memcpy(&c1, d1->data, sizeof(c1));
memcpy(&c2, d2->data, sizeof(c2));
n1 = (double) c1->ci_io / (double) (c1->ci_calls ? c1->ci_calls : 1);
n2 = (double) c2->ci_io / (double) (c2->ci_calls ? c2->ci_calls : 1);
n1 = (double) c1.ci_io / (double) (c1.ci_calls ? c1.ci_calls : 1);
n2 = (double) c2.ci_io / (double) (c2.ci_calls ? c2.ci_calls : 1);
if (n1 < n2)
return -1;
else if (n1 == n2)
return (cmp_comm(c1->ci_comm, c2->ci_comm));
return (cmp_comm(c1.ci_comm, c2.ci_comm));
else
return 1;
}
@ -495,15 +495,15 @@ static int
cmp_cpumem(d1, d2)
const DBT *d1, *d2;
{
struct cmdinfo *c1, *c2;
struct cmdinfo c1, c2;
c1 = (struct cmdinfo *) d1->data;
c2 = (struct cmdinfo *) d2->data;
memcpy(&c1, d1->data, sizeof(c1));
memcpy(&c2, d2->data, sizeof(c2));
if (c1->ci_mem < c2->ci_mem)
if (c1.ci_mem < c2.ci_mem)
return -1;
else if (c1->ci_mem == c2->ci_mem)
return (cmp_comm(c1->ci_comm, c2->ci_comm));
else if (c1.ci_mem == c2.ci_mem)
return (cmp_comm(c1.ci_comm, c2.ci_comm));
else
return 1;
}
@ -513,23 +513,23 @@ static int
cmp_avgcpumem(d1, d2)
const DBT *d1, *d2;
{
struct cmdinfo *c1, *c2;
struct cmdinfo c1, c2;
u_quad_t t1, t2;
double n1, n2;
c1 = (struct cmdinfo *) d1->data;
c2 = (struct cmdinfo *) d2->data;
memcpy(&c1, d1->data, sizeof(c1));
memcpy(&c2, d2->data, sizeof(c2));
t1 = c1->ci_utime + c1->ci_stime;
t2 = c2->ci_utime + c2->ci_stime;
t1 = c1.ci_utime + c1.ci_stime;
t2 = c2.ci_utime + c2.ci_stime;
n1 = (double) c1->ci_mem / (double) (t1 ? t1 : 1);
n2 = (double) c2->ci_mem / (double) (t2 ? t2 : 1);
n1 = (double) c1.ci_mem / (double) (t1 ? t1 : 1);
n2 = (double) c2.ci_mem / (double) (t2 ? t2 : 1);
if (n1 < n2)
return -1;
else if (n1 == n2)
return (cmp_comm(c1->ci_comm, c2->ci_comm));
return (cmp_comm(c1.ci_comm, c2.ci_comm));
else
return 1;
}
@ -539,15 +539,15 @@ static int
cmp_calls(d1, d2)
const DBT *d1, *d2;
{
struct cmdinfo *c1, *c2;
struct cmdinfo c1, c2;
c1 = (struct cmdinfo *) d1->data;
c2 = (struct cmdinfo *) d2->data;
memcpy(&c1, d1->data, sizeof(c1));
memcpy(&c2, d2->data, sizeof(c2));
if (c1->ci_calls < c2->ci_calls)
if (c1.ci_calls < c2.ci_calls)
return -1;
else if (c1->ci_calls == c2->ci_calls)
return (cmp_comm(c1->ci_comm, c2->ci_comm));
else if (c1.ci_calls == c2.ci_calls)
return (cmp_comm(c1.ci_comm, c2.ci_comm));
else
return 1;
}

View File

@ -226,7 +226,7 @@ void
usracct_print()
{
DBT key, data;
struct userinfo *ui;
struct userinfo uistore, *ui = &uistore;
double t;
int rv;
@ -235,7 +235,7 @@ usracct_print()
warn("retrieving user accounting stats");
while (rv == 0) {
ui = (struct userinfo *) data.data;
memcpy(ui, data.data, sizeof(struct userinfo));
printf("%-*s %9qu ", MAXLOGNAME - 1,
user_from_uid(ui->ui_uid, 0), ui->ui_calls);