/* Sync system clock from RTC; first, initialize the timezone fields of struct tm. */
if (c->local_rtc)
- tm = *localtime(&ts.tv_sec);
+ localtime_r(&ts.tv_sec, &tm);
else
- tm = *gmtime(&ts.tv_sec);
+ gmtime_r(&ts.tv_sec, &tm);
/* Override the main fields of struct tm, but not the timezone fields */
r = clock_get_hwclock(&tm);
}
} else {
- struct tm *tm;
+ struct tm tm;
/* Sync RTC from system clock */
if (c->local_rtc)
- tm = localtime(&ts.tv_sec);
+ localtime_r(&ts.tv_sec, &tm);
else
- tm = gmtime(&ts.tv_sec);
+ gmtime_r(&ts.tv_sec, &tm);
- r = clock_set_hwclock(tm);
+ r = clock_set_hwclock(&tm);
if (r < 0)
log_debug_errno(r, "Failed to sync time to hardware clock, ignoring: %m");
}
int64_t utc;
struct timespec ts;
usec_t start;
- struct tm* tm;
+ struct tm tm;
assert(m);
assert(c);
/* Sync down to RTC */
if (c->local_rtc)
- tm = localtime(&ts.tv_sec);
+ localtime_r(&ts.tv_sec, &tm);
else
- tm = gmtime(&ts.tv_sec);
+ gmtime_r(&ts.tv_sec, &tm);
- r = clock_set_hwclock(tm);
+ r = clock_set_hwclock(&tm);
if (r < 0)
log_debug_errno(r, "Failed to update hardware clock, ignoring: %m");