Merge pull request #4526 from mysterywolf/time1

[libc][time] add LOG_W to give a warning when RTC device is not used
This commit is contained in:
Bernard Xiong 2021-03-27 14:22:10 +08:00 committed by GitHub
commit ec6d707539
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -21,6 +21,7 @@
#include <sys/time.h>
#include <rtthread.h>
#include <rtdbg.h>
#ifdef RT_USING_DEVICE
#include <rtdevice.h>
#endif
@ -219,6 +220,7 @@ RT_WEAK time_t time(time_t *t)
if(time_now == (time_t)-1)
{
LOG_W("Cannot find a RTC device to provide time!");
errno = ENOSYS;
}
@ -246,12 +248,13 @@ int stime(const time_t *t)
}
else
{
LOG_W("Cannot find a RTC device to provide time!");
errno = ENOSYS;
return -1;
}
return 0;
#else
LOG_W("Cannot find a RTC device to provide time!");
errno = ENOSYS;
return -1;
#endif /* RT_USING_RTC */