aboutsummaryrefslogtreecommitdiff
path: root/util-linux/hwclock.c
diff options
context:
space:
mode:
Diffstat (limited to 'util-linux/hwclock.c')
-rw-r--r--util-linux/hwclock.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/util-linux/hwclock.c b/util-linux/hwclock.c
index 3d28364e9..2cdb186c5 100644
--- a/util-linux/hwclock.c
+++ b/util-linux/hwclock.c
@@ -36,7 +36,10 @@ static void write_rtc(time_t t, int utc)
struct tm tm;
int rtc = rtc_xopen(&rtcname, O_WRONLY);
- tm = *(utc ? gmtime(&t) : localtime(&t));
+ if (utc)
+ gmtime_r(&t, &tm);
+ else
+ localtime_r(&t, &tm);
tm.tm_isdst = 0;
xioctl(rtc, RTC_SET_TIME, &tm);