Always use clock drivers with a valid instance

This commit is contained in:
Pierre Pronchery 2018-08-03 02:06:43 +02:00
parent 7af49989ec
commit 4f8536876a
2 changed files with 6 additions and 4 deletions

View File

@ -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;

View File

@ -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);