From b0750136b50e674e329185925253207fa7c6b333 Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Mon, 4 Mar 2024 11:34:22 +0100 Subject: [PATCH] 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. --- getdate.y | 1 + rtc_linux.c | 1 + 2 files changed, 2 insertions(+) diff --git a/getdate.y b/getdate.y index 47d368d..c305fb7 100644 --- a/getdate.y +++ b/getdate.y @@ -943,6 +943,7 @@ get_date (const char *p, const time_t *now) tm.tm_hour += yyRelHour; tm.tm_min += yyRelMinutes; tm.tm_sec += yyRelSeconds; + tm.tm_wday = 0; /* Let mktime deduce tm_isdst if we have an absolute timestamp, or if the relative timestamp mentions days, months, or years. */ diff --git a/rtc_linux.c b/rtc_linux.c index 58b625b..8c42840 100644 --- a/rtc_linux.c +++ b/rtc_linux.c @@ -802,6 +802,7 @@ read_from_device(int fd_, int event, void *any) rtc_tm.tm_mday = rtc_raw.tm_mday; rtc_tm.tm_mon = rtc_raw.tm_mon; rtc_tm.tm_year = rtc_raw.tm_year; + rtc_tm.tm_wday = 0; rtc_t = t_from_rtc(&rtc_tm);