diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2013-04-23 07:38:06 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2013-04-23 07:38:06 +0000 |
commit | 0046070904d6748aa50f69fad11838cf4c276d18 (patch) | |
tree | 60e8e3f2cc428305f1c4e5d43862e57b7f5ba5d9 /sys/arch/macppc/dev | |
parent | d6ec1e7d722bbaef7d9d8c473505a9a07412a761 (diff) |
Don't assume time_t is an uint32_t.
ok deraadt@
Diffstat (limited to 'sys/arch/macppc/dev')
-rw-r--r-- | sys/arch/macppc/dev/adb.c | 17 | ||||
-rw-r--r-- | sys/arch/macppc/dev/pm_direct.c | 11 |
2 files changed, 18 insertions, 10 deletions
diff --git a/sys/arch/macppc/dev/adb.c b/sys/arch/macppc/dev/adb.c index 7faa468dca9..8f3b95a9542 100644 --- a/sys/arch/macppc/dev/adb.c +++ b/sys/arch/macppc/dev/adb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: adb.c,v 1.36 2013/03/10 11:26:34 mpi Exp $ */ +/* $OpenBSD: adb.c,v 1.37 2013/04/23 07:38:05 mpi Exp $ */ /* $NetBSD: adb.c,v 1.6 1999/08/16 06:28:09 tsubai Exp $ */ /* $NetBSD: adb_direct.c,v 1.14 2000/06/08 22:10:45 tsubai Exp $ */ @@ -1358,6 +1358,7 @@ adb_read_date_time(time_t *time) int result; int retcode; volatile int flag = 0; + u_int32_t t; switch (adbHardware) { case ADB_HW_PMU: @@ -1380,7 +1381,8 @@ adb_read_date_time(time_t *time) ; delay(20); /* completion occurs too soon? */ - memcpy(time, output + 1, 4); + memcpy(&t, output + 1, sizeof(t)); + *time = (time_t)t; retcode = 0; break; @@ -1407,18 +1409,21 @@ adb_set_date_time(time_t time) u_char output[ADB_MAX_MSG_LENGTH]; int result; volatile int flag = 0; + u_int32_t t; time += DIFF19041970; switch (adbHardware) { case ADB_HW_CUDA: + t = time; /* XXX eventually truncates */ + output[0] = 0x06; /* 6 byte message */ output[1] = 0x01; /* to pram/rtc device */ output[2] = 0x09; /* set date/time */ - output[3] = (u_char)(time >> 24); - output[4] = (u_char)(time >> 16); - output[5] = (u_char)(time >> 8); - output[6] = (u_char)(time); + output[3] = (u_char)(t >> 24); + output[4] = (u_char)(t >> 16); + output[5] = (u_char)(t >> 8); + output[6] = (u_char)(t); result = send_adb_cuda((u_char *)output, (u_char *)0, (void *)adb_op_comprout, (void *)&flag, (int)0); if (result != 0) /* exit if not sent */ diff --git a/sys/arch/macppc/dev/pm_direct.c b/sys/arch/macppc/dev/pm_direct.c index 4242bf40df4..3861c443090 100644 --- a/sys/arch/macppc/dev/pm_direct.c +++ b/sys/arch/macppc/dev/pm_direct.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pm_direct.c,v 1.24 2012/12/05 23:20:13 deraadt Exp $ */ +/* $OpenBSD: pm_direct.c,v 1.25 2013/04/23 07:38:05 mpi Exp $ */ /* $NetBSD: pm_direct.c,v 1.9 2000/06/08 22:10:46 tsubai Exp $ */ /* @@ -694,6 +694,7 @@ void pm_read_date_time(time_t *time) { PMData p; + u_int32_t t; p.command = PMU_READ_RTC; p.num_data = 0; @@ -701,18 +702,20 @@ pm_read_date_time(time_t *time) p.r_buf = p.data; pmgrop(&p); - bcopy(p.data, time, 4); + bcopy(p.data, &t, sizeof(t)); + *time = (time_t)t; } void pm_set_date_time(time_t time) { PMData p; + u_int32_t t = time; /* XXX eventually truncates */ p.command = PMU_SET_RTC; - p.num_data = 4; + p.num_data = sizeof(t); p.s_buf = p.r_buf = p.data; - bcopy(&time, p.data, 4); + bcopy(&t, p.data, sizeof(t)); pmgrop(&p); } |