diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2014-02-08 11:04:51 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2014-02-08 11:04:51 +0000 |
commit | 42676d758bb4e99e64200d0ae8fdf3e5a7edf717 (patch) | |
tree | a45ba0842b3369a14da1d310f129d11112ced429 /sys/arch/sparc64 | |
parent | 260a89225b5a0d8f4494866616a4d54b3fe5c148 (diff) |
Initializing the time from an uninitialized variable isn't a very good idea.
While there, afnsify the inittodr() prototype.
Diffstat (limited to 'sys/arch/sparc64')
-rw-r--r-- | sys/arch/sparc64/sparc64/clock.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/sys/arch/sparc64/sparc64/clock.c b/sys/arch/sparc64/sparc64/clock.c index 18efa11bcad..87c15e03b70 100644 --- a/sys/arch/sparc64/sparc64/clock.c +++ b/sys/arch/sparc64/sparc64/clock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clock.c,v 1.50 2014/01/30 00:51:13 dlg Exp $ */ +/* $OpenBSD: clock.c,v 1.51 2014/02/08 11:04:50 kettenis Exp $ */ /* $NetBSD: clock.c,v 1.41 2001/07/24 19:29:25 eeh Exp $ */ /* @@ -899,14 +899,15 @@ int sparc_clock_time_is_ok; * Set up the system's time, given a `reasonable' time value. */ void -inittodr(base) - time_t base; +inittodr(time_t base) { int badbase = 0, waszero = base == 0; char *bad = NULL; struct timeval tv; struct timespec ts; + tv.tv_sec = tv.tv_usec = 0; + if (base < 5 * SECYR) { /* * If base is 0, assume filesystem time is just unknown @@ -919,8 +920,10 @@ inittodr(base) badbase = 1; } - if (todr_handle && (todr_gettime(todr_handle, &tv) != 0 || - tv.tv_sec == 0)) { + if (todr_handle != NULL) + todr_gettime(todr_handle, &tv); + + if (tv.tv_sec == 0) { /* * Believe the time in the file system for lack of * anything better, resetting the clock. |