]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
rtc+getdate: initialize tm_wday for mktime()
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 4 Mar 2024 10:34:22 +0000 (11:34 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Mon, 4 Mar 2024 10:38:16 +0000 (11:38 +0100)
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
rtc_linux.c

index 47d368d30a984591f9d6dff3ef33073898e47eb2..c305fb7c66d39dbe5046780902c7a1cd30671929 100644 (file)
--- 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.  */
index 58b625b60f56a3f9af14666d6044bf3e6db20520..8c428409ddd4b3e204371f90421a7ff444b8d9e7 100644 (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_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);