summaryrefslogtreecommitdiff
path: root/sys/arch/macppc
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2013-04-23 07:38:06 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2013-04-23 07:38:06 +0000
commit0046070904d6748aa50f69fad11838cf4c276d18 (patch)
tree60e8e3f2cc428305f1c4e5d43862e57b7f5ba5d9 /sys/arch/macppc
parentd6ec1e7d722bbaef7d9d8c473505a9a07412a761 (diff)
Don't assume time_t is an uint32_t.
ok deraadt@
Diffstat (limited to 'sys/arch/macppc')
-rw-r--r--sys/arch/macppc/dev/adb.c17
-rw-r--r--sys/arch/macppc/dev/pm_direct.c11
-rw-r--r--sys/arch/macppc/macppc/clock.c4
3 files changed, 20 insertions, 12 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);
}
diff --git a/sys/arch/macppc/macppc/clock.c b/sys/arch/macppc/macppc/clock.c
index fb0d4663c7d..fd44514216a 100644
--- a/sys/arch/macppc/macppc/clock.c
+++ b/sys/arch/macppc/macppc/clock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: clock.c,v 1.32 2011/08/29 20:21:44 drahn Exp $ */
+/* $OpenBSD: clock.c,v 1.33 2013/04/23 07:38:05 mpi Exp $ */
/* $NetBSD: clock.c,v 1.1 1996/09/30 16:34:40 ws Exp $ */
/*
@@ -103,7 +103,7 @@ inittodr(time_t base)
}
if (time_read != NULL) {
- u_int32_t cursec;
+ time_t cursec;
(*time_read)(&cursec);
tv.tv_sec = cursec;
tv.tv_usec = 0;