forked from len0rd/rockbox
hosted: Fix rtc_write_datetime() error handling
(if mktime() fails, don't attempt to write its result to the RTC) Change-Id: Ib09b8dccafdef032119db76f10af74dfc220cc21
This commit is contained in:
parent
cb6b0d2c0e
commit
f3010c6a8e
1 changed files with 3 additions and 0 deletions
|
@ -54,6 +54,9 @@ int rtc_write_datetime(const struct tm *tm)
|
||||||
tv.tv_sec = mktime((struct tm *)tm);
|
tv.tv_sec = mktime((struct tm *)tm);
|
||||||
tv.tv_usec = 0;
|
tv.tv_usec = 0;
|
||||||
|
|
||||||
|
if ((int)tv.tv_sec == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
/* set system clock */
|
/* set system clock */
|
||||||
settimeofday(&tv, NULL);
|
settimeofday(&tv, NULL);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue