diff options
author | dwmalone <dwmalone@FreeBSD.org> | 2007-07-23 09:42:32 +0000 |
---|---|---|
committer | dwmalone <dwmalone@FreeBSD.org> | 2007-07-23 09:42:32 +0000 |
commit | e8276674f3dc77e497ee2600cd45f51e731c6dab (patch) | |
tree | 9e35e0b6e5b6c0c6047ac01c3aa7bf287ef1c85d | |
parent | 9f42d6219fe8097ea3b6faf2beb93af539c11208 (diff) | |
download | FreeBSD-src-e8276674f3dc77e497ee2600cd45f51e731c6dab.zip FreeBSD-src-e8276674f3dc77e497ee2600cd45f51e731c6dab.tar.gz |
If clock_ct_to_ts fails to convert time time from the real time clock,
print a one line error message. Add some comments on not being able to
trust the day of week field (I'll act on these comments in a follow up
commit).
Approved by: re
MFC after: 3 weeks
-rw-r--r-- | sys/amd64/isa/clock.c | 3 | ||||
-rw-r--r-- | sys/i386/isa/clock.c | 9 | ||||
-rw-r--r-- | sys/ia64/ia64/clock.c | 3 | ||||
-rw-r--r-- | sys/isa/atrtc.c | 9 | ||||
-rw-r--r-- | sys/kern/subr_clock.c | 2 | ||||
-rw-r--r-- | sys/pc98/cbus/clock.c | 6 | ||||
-rw-r--r-- | sys/pc98/cbus/pcrtc.c | 6 | ||||
-rw-r--r-- | sys/sparc64/sparc64/eeprom.c | 8 | ||||
-rw-r--r-- | sys/sparc64/sparc64/rtc.c | 8 |
9 files changed, 36 insertions, 18 deletions
diff --git a/sys/amd64/isa/clock.c b/sys/amd64/isa/clock.c index 0ef295b..852cca1 100644 --- a/sys/amd64/isa/clock.c +++ b/sys/amd64/isa/clock.c @@ -686,8 +686,7 @@ inittodr(time_t base) return; wrong_time: - printf("Invalid time in real time clock.\n"); - printf("Check and reset the date immediately!\n"); + printf("Invalid time in clock: check and reset the date!\n"); } /* diff --git a/sys/i386/isa/clock.c b/sys/i386/isa/clock.c index f8e1c4e..a519a9e 100644 --- a/sys/i386/isa/clock.c +++ b/sys/i386/isa/clock.c @@ -679,8 +679,7 @@ inittodr(time_t base) /* Look if we have a RTC present and the time is valid */ if (!(rtcin(RTC_STATUSD) & RTCSD_PWR)) { - printf("Invalid time in real time clock.\n"); - printf("Check and reset the date immediately!\n"); + printf("Invalid time in clock: check and reset the date!\n"); return; } @@ -704,7 +703,11 @@ inittodr(time_t base) #else ct.year += 2000; #endif - clock_ct_to_ts(&ct, &ts); + /* Should we set dow = -1 because some clocks don't set it correctly? */ + if (clock_ct_to_ts(&ct, &ts)) { + printf("Invalid time in clock: check and reset the date!\n"); + return; + } ts.tv_sec += utc_offset(); tc_setclock(&ts); } diff --git a/sys/ia64/ia64/clock.c b/sys/ia64/ia64/clock.c index 07950d5..ba8dd56 100644 --- a/sys/ia64/ia64/clock.c +++ b/sys/ia64/ia64/clock.c @@ -142,7 +142,8 @@ inittodr(time_t base) ct.mon = tm.tm_mon; ct.year = tm.tm_year; ct.dow = -1; - clock_ct_to_ts(&ct, &ts); + if (clock_ct_to_ts(&ct, &ts)) + printf("Invalid time in clock: check and reset the date!\n"); ts.tv_sec += utc_offset(); /* diff --git a/sys/isa/atrtc.c b/sys/isa/atrtc.c index f8e1c4e..a519a9e 100644 --- a/sys/isa/atrtc.c +++ b/sys/isa/atrtc.c @@ -679,8 +679,7 @@ inittodr(time_t base) /* Look if we have a RTC present and the time is valid */ if (!(rtcin(RTC_STATUSD) & RTCSD_PWR)) { - printf("Invalid time in real time clock.\n"); - printf("Check and reset the date immediately!\n"); + printf("Invalid time in clock: check and reset the date!\n"); return; } @@ -704,7 +703,11 @@ inittodr(time_t base) #else ct.year += 2000; #endif - clock_ct_to_ts(&ct, &ts); + /* Should we set dow = -1 because some clocks don't set it correctly? */ + if (clock_ct_to_ts(&ct, &ts)) { + printf("Invalid time in clock: check and reset the date!\n"); + return; + } ts.tv_sec += utc_offset(); tc_setclock(&ts); } diff --git a/sys/kern/subr_clock.c b/sys/kern/subr_clock.c index fe6adf9..b2f7827 100644 --- a/sys/kern/subr_clock.c +++ b/sys/kern/subr_clock.c @@ -151,7 +151,7 @@ clock_ct_to_ts(struct clocktime *ct, struct timespec *ts) days += days_in_month(year, i); days += (ct->day - 1); - /* Another sanity check. */ + /* XXX Dow sanity check. Dow is not used, so should we check it? */ if (ct->dow != -1 && ct->dow != day_of_week(days)) return (EINVAL); diff --git a/sys/pc98/cbus/clock.c b/sys/pc98/cbus/clock.c index 874109a..7b993dc 100644 --- a/sys/pc98/cbus/clock.c +++ b/sys/pc98/cbus/clock.c @@ -638,7 +638,11 @@ inittodr(time_t base) ct.year = bcd2bin(rtc_inb() & 0xff) + 1900; /* year */ if (ct.year < 1995) ct.year += 100; - clock_ct_to_ts(&ct, &ts); + /* Should we set dow = -1 because some clocks don't set it correctly? */ + if (clock_ct_to_ts(&ct, &ts)) { + printf("Invalid time in clock: check and reset the date!\n"); + return; + } ts.tv_sec += utc_offset(); tc_setclock(&ts); } diff --git a/sys/pc98/cbus/pcrtc.c b/sys/pc98/cbus/pcrtc.c index 874109a..7b993dc 100644 --- a/sys/pc98/cbus/pcrtc.c +++ b/sys/pc98/cbus/pcrtc.c @@ -638,7 +638,11 @@ inittodr(time_t base) ct.year = bcd2bin(rtc_inb() & 0xff) + 1900; /* year */ if (ct.year < 1995) ct.year += 100; - clock_ct_to_ts(&ct, &ts); + /* Should we set dow = -1 because some clocks don't set it correctly? */ + if (clock_ct_to_ts(&ct, &ts)) { + printf("Invalid time in clock: check and reset the date!\n"); + return; + } ts.tv_sec += utc_offset(); tc_setclock(&ts); } diff --git a/sys/sparc64/sparc64/eeprom.c b/sys/sparc64/sparc64/eeprom.c index 84c0272..c707018 100644 --- a/sys/sparc64/sparc64/eeprom.c +++ b/sys/sparc64/sparc64/eeprom.c @@ -170,9 +170,11 @@ eeprom_attach(device_t dev) } if (bootverbose) { - mk48txx_gettime(dev, &ts); - device_printf(dev, "current time: %ld.%09ld\n", (long)ts.tv_sec, - ts.tv_nsec); + if (mk48txx_gettime(dev, &ts) != 0) + device_printf(dev, "invalid time"); + else + device_printf(dev, "current time: %ld.%09ld\n", + (long)ts.tv_sec, ts.tv_nsec); } return (0); diff --git a/sys/sparc64/sparc64/rtc.c b/sys/sparc64/sparc64/rtc.c index f018131..fe7f17e 100644 --- a/sys/sparc64/sparc64/rtc.c +++ b/sys/sparc64/sparc64/rtc.c @@ -208,9 +208,11 @@ rtc_attach(device_t dev) } if (bootverbose) { - mc146818_gettime(dev, &ts); - device_printf(dev, "current time: %ld.%09ld\n", (long)ts.tv_sec, - ts.tv_nsec); + if (mc146818_gettime(dev, &ts) != 0) + device_printf(dev, "invalid time"); + else + device_printf(dev, "current time: %ld.%09ld\n", + (long)ts.tv_sec, ts.tv_nsec); } return (0); |