diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2013-07-02 04:39:05 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2013-07-02 04:39:05 +0000 |
commit | 75d37bab07e415128728589d49c5ba7c23daf2f0 (patch) | |
tree | be80f127923e598c86189523787ace32c2f1bd69 /sys/arch | |
parent | 8bd06823eb49787242588dac0e55150de2b3ccae (diff) |
Use time_t for storing and returning time_t values, and cast to time_t
before the last multiplication that might take it past 2^31 secounds.
ok deraadt@ miod@
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/aviion/dev/nvram.c | 11 | ||||
-rw-r--r-- | sys/arch/mvme68k/dev/nvram.c | 11 |
2 files changed, 12 insertions, 10 deletions
diff --git a/sys/arch/aviion/dev/nvram.c b/sys/arch/aviion/dev/nvram.c index 200f299a0f1..e40b9cda19b 100644 --- a/sys/arch/aviion/dev/nvram.c +++ b/sys/arch/aviion/dev/nvram.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nvram.c,v 1.7 2010/12/26 15:40:59 miod Exp $ */ +/* $OpenBSD: nvram.c,v 1.8 2013/07/02 04:39:04 guenther Exp $ */ /* * Copyright (c) 1995 Theo de Raadt @@ -67,7 +67,7 @@ struct cfdriver nvram_cd = { NULL, "nvram", DV_DULL }; -u_long chiptotime(int, int, int, int, int, int); +time_t chiptotime(int, int, int, int, int, int); int nvramrw(caddr_t, int, struct uio *, int); int @@ -128,7 +128,7 @@ nvramattach(parent, self, args) const int dayyr[12] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 }; -u_long +time_t chiptotime(sec, min, hour, day, mon, year) int sec, min, hour, day, mon, year; { @@ -162,7 +162,7 @@ chiptotime(sec, min, hour, day, mon, year) days++; /* now have days since Jan 1, 1970; the rest is easy... */ - return (days * SECDAY + hour * 3600 + min * 60 + sec); + return ((time_t)days * SECDAY + hour * 3600 + min * 60 + sec); } struct chiptime { @@ -181,7 +181,8 @@ void timetochip(c) struct chiptime *c; { - int t, t2, t3, now = time_second; + time_t t2, now = time_second; + int t, t3; /* January 1 1970 was a Thursday (4 in unix wdays) */ /* compute the days since the epoch */ diff --git a/sys/arch/mvme68k/dev/nvram.c b/sys/arch/mvme68k/dev/nvram.c index 3f29c1a2d7c..3070729010a 100644 --- a/sys/arch/mvme68k/dev/nvram.c +++ b/sys/arch/mvme68k/dev/nvram.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nvram.c,v 1.22 2012/11/04 13:33:32 miod Exp $ */ +/* $OpenBSD: nvram.c,v 1.23 2013/07/02 04:39:04 guenther Exp $ */ /* * Copyright (c) 1995 Theo de Raadt @@ -161,10 +161,10 @@ struct chiptime { int year; }; -u_long chiptotime(int, int, int, int, int, int); +time_t chiptotime(int, int, int, int, int, int); void timetochip(struct chiptime *); -u_long +time_t chiptotime(sec, min, hour, day, mon, year) register int sec, min, hour, day, mon, year; { @@ -198,14 +198,15 @@ chiptotime(sec, min, hour, day, mon, year) days++; /* now have days since Jan 1, 1970; the rest is easy... */ - return (days * SECDAY + hour * 3600 + min * 60 + sec); + return ((time_t)days * SECDAY + hour * 3600 + min * 60 + sec); } void timetochip(c) struct chiptime *c; { - int t, t2, t3, now = time_second; + time_t t2, now = time_second; + int t, t3; /* January 1 1970 was a Thursday (4 in unix wdays) */ /* compute the days since the epoch */ |