workaround for volatile struct timeval time vs todr_*() arg mismatch.

This commit is contained in:
tsutsui 2005-06-03 12:32:44 +00:00
parent 09ae8cb89e
commit 64cdf507bf

View File

@ -1,4 +1,4 @@
/* $NetBSD: todclock.c,v 1.6 2005/01/22 07:35:33 tsutsui Exp $ */
/* $NetBSD: todclock.c,v 1.7 2005/06/03 12:32:44 tsutsui Exp $ */
/*
* Copyright (c) 1992, 1993
@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: todclock.c,v 1.6 2005/01/22 07:35:33 tsutsui Exp $");
__KERNEL_RCSID(0, "$NetBSD: todclock.c,v 1.7 2005/06/03 12:32:44 tsutsui Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@ -71,6 +71,7 @@ todr_attach(todr_chip_handle_t handle)
void
inittodr(time_t base)
{
struct timeval tv;
int badbase, waszero;
badbase = 0;
@ -89,8 +90,8 @@ inittodr(time_t base)
badbase = 1;
}
if (todr_gettime(todr_handle, (struct timeval *)&time) != 0 ||
time.tv_sec == 0) {
if (todr_gettime(todr_handle, &tv) != 0 ||
tv.tv_sec == 0) {
printf("WARNING: bad date in battery clock");
/*
* Believe the time in the file system for lack of
@ -100,7 +101,10 @@ inittodr(time_t base)
if (!badbase)
resettodr();
} else {
int deltat = time.tv_sec - base;
int deltat;
time = tv;
deltat = time.tv_sec - base;
if (deltat < 0)
deltat = -deltat;
@ -121,10 +125,12 @@ inittodr(time_t base)
void
resettodr(void)
{
struct timeval tv;
if (time.tv_sec == 0)
return;
if (todr_settime(todr_handle, (struct timeval *)&time) != 0)
tv = time;
if (todr_settime(todr_handle, &tv) != 0)
printf("resettodr: cannot set time in time-of-day clock\n");
}