summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2021-08-05 09:22:14 -0400
committerSolomon Peachy <pizza@shaftnet.org>2021-08-05 13:44:11 +0000
commitf3010c6a8e7946bfb8db9a681e7bff6d93e56a7c (patch)
tree35844579aafb17587b77b03b691335f579574cdd
parentcb6b0d2c0e8835d360f85384d3eef53fcc17dc5a (diff)
downloadrockbox-f3010c6a8e7946bfb8db9a681e7bff6d93e56a7c.tar.gz
rockbox-f3010c6a8e7946bfb8db9a681e7bff6d93e56a7c.tar.bz2
rockbox-f3010c6a8e7946bfb8db9a681e7bff6d93e56a7c.zip
hosted: Fix rtc_write_datetime() error handling
(if mktime() fails, don't attempt to write its result to the RTC) Change-Id: Ib09b8dccafdef032119db76f10af74dfc220cc21
-rw-r--r--firmware/target/hosted/rtc.c3
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);