Always use clock drivers with a valid instance
This commit is contained in:
parent
7af49989ec
commit
4f8536876a
|
@ -13,9 +13,12 @@
|
|||
/* time */
|
||||
time_t time(time_t * time)
|
||||
{
|
||||
ukClock * clock;
|
||||
time_t t;
|
||||
|
||||
if(clock_get_time(NULL, &t) != 0)
|
||||
if((clock = clock_get_default()) == NULL)
|
||||
return -1;
|
||||
if(clock_get_time(clock, &t) != 0)
|
||||
return -1;
|
||||
if(time != NULL)
|
||||
*time = t;
|
||||
|
|
|
@ -64,10 +64,9 @@ ukClock * clock_get_default(void)
|
|||
/* clock_get_time */
|
||||
int clock_get_time(ukClock * clock, time_t * time)
|
||||
{
|
||||
if(clock == NULL
|
||||
&& (clock = clock_get_default()) == NULL)
|
||||
if(clock->get_time == NULL)
|
||||
{
|
||||
errno = ENODEV;
|
||||
errno = ENOTSUP;
|
||||
return -1;
|
||||
}
|
||||
return clock->get_time(clock, time);
|
||||
|
|
Loading…
Reference in New Issue
Block a user