Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/smartpqi/smartpqi_misc.c
Show All 24 Lines | |||||
/* $FreeBSD$ */ | /* $FreeBSD$ */ | ||||
#include "smartpqi_includes.h" | #include "smartpqi_includes.h" | ||||
/* | /* | ||||
* Populate hostwellness time variables in bcd format from FreeBSD format | * Populate hostwellness time variables in bcd format from FreeBSD format | ||||
*/ | */ | ||||
void | int | ||||
os_get_time(struct bmic_host_wellness_time *host_wellness_time) | os_get_time(struct bmic_host_wellness_time *host_wellness_time) | ||||
{ | { | ||||
struct timespec ts; | struct timespec ts; | ||||
struct clocktime ct; | struct clocktime ct; | ||||
int err; | |||||
getnanotime(&ts); | getnanotime(&ts); | ||||
clock_ts_to_ct(&ts, &ct); | err = clock_ts_to_ct(&ts, &ct); | ||||
if (err) | |||||
imp: So how does this fail? Especially since we truncate the year a few lines below to 25500 years. | |||||
Done Inline ActionsEven though the RTC can't be set to a year greater than 10,000 AD, the system clock can be. So getnanouptime could return 1.4 billion AD or something like that. In that case, the clocktime structure won't be initialized. And even though there's no precedent for this function returning an error, there is for its caller. So I think it's ok to return an error here. The only alternatives would be to panic, or to zero the structure, or something like that. asomers: Even though the RTC can't be set to a year greater than 10,000 AD, the system clock can be. So… | |||||
return (err); | |||||
/* Fill the time In BCD Format */ | /* Fill the time In BCD Format */ | ||||
host_wellness_time->hour= (uint8_t)bin2bcd(ct.hour); | host_wellness_time->hour= (uint8_t)bin2bcd(ct.hour); | ||||
host_wellness_time->min = (uint8_t)bin2bcd(ct.min); | host_wellness_time->min = (uint8_t)bin2bcd(ct.min); | ||||
host_wellness_time->sec= (uint8_t)bin2bcd(ct.sec); | host_wellness_time->sec= (uint8_t)bin2bcd(ct.sec); | ||||
host_wellness_time->reserved = 0; | host_wellness_time->reserved = 0; | ||||
host_wellness_time->month = (uint8_t)bin2bcd(ct.mon); | host_wellness_time->month = (uint8_t)bin2bcd(ct.mon); | ||||
host_wellness_time->day = (uint8_t)bin2bcd(ct.day); | host_wellness_time->day = (uint8_t)bin2bcd(ct.day); | ||||
host_wellness_time->century = (uint8_t)bin2bcd(ct.year / 100); | host_wellness_time->century = (uint8_t)bin2bcd(ct.year / 100); | ||||
host_wellness_time->year = (uint8_t)bin2bcd(ct.year % 100); | host_wellness_time->year = (uint8_t)bin2bcd(ct.year % 100); | ||||
return (0); | |||||
} | } | ||||
/* | /* | ||||
* Update host time to f/w every 24 hours in a periodic timer. | * Update host time to f/w every 24 hours in a periodic timer. | ||||
*/ | */ | ||||
void | void | ||||
os_wellness_periodic(void *data) | os_wellness_periodic(void *data) | ||||
▲ Show 20 Lines • Show All 124 Lines • Show Last 20 Lines |
So how does this fail? Especially since we truncate the year a few lines below to 25500 years.
Since this is vendor code (I know it's in the wrong place in the tree for that, but it is), and since there's other bugs, I'd suggest leaving it alone and reporting it upstream.