getdate+nts+rtc: avoid some coverity false positives

Modify the code to avoid making the following calls incorrectly reported
as important findings by the coverity static analyzer:

- memset() of size 0 at the end of an array
- mktime() on a struct tm that has uninitialized tm_yday
This commit is contained in:
Miroslav Lichvar
2025-05-21 08:43:12 +02:00
parent 545bd59563
commit bda2ff77e8
3 changed files with 4 additions and 3 deletions

View File

@@ -359,13 +359,13 @@ t_from_rtc(struct rtc_time *rtc_raw, int utc)
time_t t1, t2;
/* Convert to seconds since 1970 */
memset(&rtc_tm, 0, sizeof (rtc_tm));
rtc_tm.tm_sec = rtc_raw->tm_sec;
rtc_tm.tm_min = rtc_raw->tm_min;
rtc_tm.tm_hour = rtc_raw->tm_hour;
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;
temp1 = rtc_tm;
temp1.tm_isdst = 0;