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.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/util-linux/hwclock.c b/util-linux/hwclock.c
index dc97d8fb4..e85bca2b2 100644
--- a/util-linux/hwclock.c
+++ b/util-linux/hwclock.c
@@ -9,7 +9,6 @@
9//config:config HWCLOCK 9//config:config HWCLOCK
10//config: bool "hwclock (5.8 kb)" 10//config: bool "hwclock (5.8 kb)"
11//config: default y 11//config: default y
12//config: select PLATFORM_LINUX
13//config: help 12//config: help
14//config: The hwclock utility is used to read and set the hardware clock 13//config: The hwclock utility is used to read and set the hardware clock
15//config: on a system. This is primarily used to set the current time on 14//config: on a system. This is primarily used to set the current time on
@@ -122,16 +121,20 @@ static void to_sys_clock(const char **pp_rtcname, int utc)
122 struct timeval tv; 121 struct timeval tv;
123 struct timezone tz; 122 struct timezone tz;
124 123
125 tz.tz_minuteswest = timezone/60; 124 tz.tz_minuteswest = timezone / 60;
126 /* ^^^ used to also subtract 60*daylight, but it's wrong: 125 /* ^^^ used to also subtract 60*daylight, but it's wrong:
127 * daylight!=0 means "this timezone has some DST 126 * daylight!=0 means "this timezone has some DST
128 * during the year", not "DST is in effect now". 127 * during the year", not "DST is in effect now".
129 */ 128 */
130 tz.tz_dsttime = 0; 129 tz.tz_dsttime = 0;
131 130
131 /* glibc v2.31+ returns an error if both args are non-NULL */
132 if (settimeofday(NULL, &tz))
133 bb_simple_perror_msg_and_die("settimeofday");
134
132 tv.tv_sec = read_rtc(pp_rtcname, NULL, utc); 135 tv.tv_sec = read_rtc(pp_rtcname, NULL, utc);
133 tv.tv_usec = 0; 136 tv.tv_usec = 0;
134 if (settimeofday(&tv, &tz)) 137 if (settimeofday(&tv, NULL))
135 bb_simple_perror_msg_and_die("settimeofday"); 138 bb_simple_perror_msg_and_die("settimeofday");
136} 139}
137 140
@@ -283,7 +286,11 @@ static void set_system_clock_timezone(int utc)
283 gettimeofday(&tv, NULL); 286 gettimeofday(&tv, NULL);
284 if (!utc) 287 if (!utc)
285 tv.tv_sec += tz.tz_minuteswest * 60; 288 tv.tv_sec += tz.tz_minuteswest * 60;
286 if (settimeofday(&tv, &tz)) 289
290 /* glibc v2.31+ returns an error if both args are non-NULL */
291 if (settimeofday(NULL, &tz))
292 bb_simple_perror_msg_and_die("settimeofday");
293 if (settimeofday(&tv, NULL))
287 bb_simple_perror_msg_and_die("settimeofday"); 294 bb_simple_perror_msg_and_die("settimeofday");
288} 295}
289 296