diff --git a/components/libc/compilers/dlib/time.c b/components/libc/compilers/dlib/time.c index 87574df85152dfb562f3004319a7e026cdc2aa00..df35313b0ebb07ec3f5c475d99c658d9c01ef414 100644 --- a/components/libc/compilers/dlib/time.c +++ b/components/libc/compilers/dlib/time.c @@ -16,19 +16,16 @@ int gettimeofday(struct timeval *tp, void *ignore) rt_device_t device; device = rt_device_find("rtc"); - if (device != RT_NULL) - { - rt_device_control(device, RT_DEVICE_CTRL_RTC_GET_TIME, &time); - if (tp != RT_NULL) - { - tp->tv_sec = time; - tp->tv_usec = 0; - } + RT_ASSERT(device != RT_NULL); - return time; + rt_device_control(device, RT_DEVICE_CTRL_RTC_GET_TIME, &time); + if (tp != RT_NULL) + { + tp->tv_sec = time; + tp->tv_usec = 0; } - return 0; + return time; } #endif diff --git a/components/libc/compilers/minilibc/time.c b/components/libc/compilers/minilibc/time.c index 508558bafc3cd702e837a615fbe047cdfd8cbe40..c04652c8842a51cf8db6b3d97a5a3df452630e5b 100644 --- a/components/libc/compilers/minilibc/time.c +++ b/components/libc/compilers/minilibc/time.c @@ -211,19 +211,16 @@ int gettimeofday(struct timeval *tp, void *ignore) rt_device_t device; device = rt_device_find("rtc"); - if (device != RT_NULL) - { - rt_device_control(device, RT_DEVICE_CTRL_RTC_GET_TIME, &time); - if (tp != RT_NULL) - { - tp->tv_sec = time; - tp->tv_usec = 0; - } + RT_ASSERT(device != RT_NULL); - return time; - } + rt_device_control(device, RT_DEVICE_CTRL_RTC_GET_TIME, &time); + if (tp != RT_NULL) + { + tp->tv_sec = time; + tp->tv_usec = 0; + } - return 0; + return time; } #endif diff --git a/components/libc/compilers/newlib/time.c b/components/libc/compilers/newlib/time.c index 29c5c6cdd2ca818a9cb8ca3b0a1ea60f10a6a5d3..f099d51330da569b8b3f3bb1c53e57f222870d32 100644 --- a/components/libc/compilers/newlib/time.c +++ b/components/libc/compilers/newlib/time.c @@ -16,19 +16,16 @@ int gettimeofday(struct timeval *tp, void *ignore) rt_device_t device; device = rt_device_find("rtc"); - if (device != RT_NULL) - { - rt_device_control(device, RT_DEVICE_CTRL_RTC_GET_TIME, &time); - if (tp != RT_NULL) - { - tp->tv_sec = time; - tp->tv_usec = 0; - } + RT_ASSERT(device != RT_NULL); - return time; + rt_device_control(device, RT_DEVICE_CTRL_RTC_GET_TIME, &time); + if (tp != RT_NULL) + { + tp->tv_sec = time; + tp->tv_usec = 0; } - return 0; + return time; } #endif