diff options
author | Solomon Peachy <pizza@shaftnet.org> | 2021-08-05 09:22:14 -0400 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2021-08-05 13:44:11 +0000 |
commit | f3010c6a8e7946bfb8db9a681e7bff6d93e56a7c (patch) | |
tree | 35844579aafb17587b77b03b691335f579574cdd /firmware/target | |
parent | cb6b0d2c0e8835d360f85384d3eef53fcc17dc5a (diff) |
hosted: Fix rtc_write_datetime() error handling
(if mktime() fails, don't attempt to write its result to the RTC)
Change-Id: Ib09b8dccafdef032119db76f10af74dfc220cc21
Diffstat (limited to 'firmware/target')
-rw-r--r-- | firmware/target/hosted/rtc.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/firmware/target/hosted/rtc.c b/firmware/target/hosted/rtc.c index e747aece38..05c8f75ef7 100644 --- a/firmware/target/hosted/rtc.c +++ b/firmware/target/hosted/rtc.c @@ -54,6 +54,9 @@ int rtc_write_datetime(const struct tm *tm) tv.tv_sec = mktime((struct tm *)tm); tv.tv_usec = 0; + if ((int)tv.tv_sec == -1) + return -1; + /* set system clock */ settimeofday(&tv, NULL); |