[Git][NTPsec/ntpsec][master] Use gmtime_r() instead of gmtime() since the latter is a banned function

Matt Selsky gitlab at mg.gitlab.com
Tue Dec 11 17:36:32 UTC 2018


Matt Selsky pushed to branch master at NTPsec / ntpsec


Commits:
8b749233 by Matt Selsky at 2018-12-11T17:27:16Z
Use gmtime_r() instead of gmtime() since the latter is a banned function

- - - - -


1 changed file:

- libntp/ntp_calendar.c


Changes:

=====================================
libntp/ntp_calendar.c
=====================================
@@ -39,27 +39,26 @@ ntpcal_get_build_date(
 	)
 {
         time_t epoch = (time_t)BUILD_EPOCH;
-        struct tm *epoch_tm;
+        struct tm epoch_tm;
 
 	ZERO(*jd);
 	jd->year     = 1970;
 	jd->month    = 1;
 	jd->monthday = 1;
 
-        epoch_tm = gmtime(&epoch);
-        if ( NULL == epoch_tm ) {
+        if (NULL == gmtime_r(&epoch, &epoch_tm)) {
             /* bad EPOCH */
 	    return false;
         }
 	/* good EPOCH */
-	jd->year     = epoch_tm->tm_year + 1900;
-	jd->yearday  = epoch_tm->tm_yday + 1;
-	jd->month    = epoch_tm->tm_mon + 1;
-	jd->monthday = epoch_tm->tm_mday;
-	jd->hour     = epoch_tm->tm_hour;
-	jd->minute   = epoch_tm->tm_min;
-	jd->second   = epoch_tm->tm_sec;
-	jd->weekday  = epoch_tm->tm_wday;
+	jd->year     = epoch_tm.tm_year + 1900;
+	jd->yearday  = epoch_tm.tm_yday + 1;
+	jd->month    = epoch_tm.tm_mon + 1;
+	jd->monthday = epoch_tm.tm_mday;
+	jd->hour     = epoch_tm.tm_hour;
+	jd->minute   = epoch_tm.tm_min;
+	jd->second   = epoch_tm.tm_sec;
+	jd->weekday  = epoch_tm.tm_wday;
 
 #if 0
         fprintf(stderr, "Build: %d %d %d %d %d %d %d %d\n",



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/8b749233b60c8b4a09218906ddc9cd3591f91117

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/8b749233b60c8b4a09218906ddc9cd3591f91117
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20181211/43603869/attachment-0001.html>


More information about the vc mailing list