rtc+getdate: initialize tm_wday for mktime()

Even though mktime() is documented as ignoring the tm_wday field, the
coverity static analyzer complains about passing an uninitialized value.
Set the field to zero to make it happy.
This commit is contained in:
Miroslav Lichvar 2024-03-04 11:34:22 +01:00
parent ad79aec946
commit b0750136b5
2 changed files with 2 additions and 0 deletions

View file

@ -943,6 +943,7 @@ get_date (const char *p, const time_t *now)
tm.tm_hour += yyRelHour; tm.tm_hour += yyRelHour;
tm.tm_min += yyRelMinutes; tm.tm_min += yyRelMinutes;
tm.tm_sec += yyRelSeconds; tm.tm_sec += yyRelSeconds;
tm.tm_wday = 0;
/* Let mktime deduce tm_isdst if we have an absolute timestamp, /* Let mktime deduce tm_isdst if we have an absolute timestamp,
or if the relative timestamp mentions days, months, or years. */ or if the relative timestamp mentions days, months, or years. */

View file

@ -802,6 +802,7 @@ read_from_device(int fd_, int event, void *any)
rtc_tm.tm_mday = rtc_raw.tm_mday; rtc_tm.tm_mday = rtc_raw.tm_mday;
rtc_tm.tm_mon = rtc_raw.tm_mon; rtc_tm.tm_mon = rtc_raw.tm_mon;
rtc_tm.tm_year = rtc_raw.tm_year; rtc_tm.tm_year = rtc_raw.tm_year;
rtc_tm.tm_wday = 0;
rtc_t = t_from_rtc(&rtc_tm); rtc_t = t_from_rtc(&rtc_tm);