mkfs_ext2: fix 60k image creation
[oweals/busybox.git] / util-linux / hwclock.c
index a03d61bbf0d307038b71b0906cc2af91b0b6451e..6dff57f094a5ff9192337f6c3278938cbf960642 100644 (file)
@@ -7,8 +7,9 @@
  * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
 */
 
-#include <sys/utsname.h>
 #include "libbb.h"
+/* After libbb.h, since it needs sys/types.h on some systems */
+#include <sys/utsname.h>
 #include "rtc_.h"
 
 #if ENABLE_FEATURE_HWCLOCK_LONG_OPTIONS
@@ -36,7 +37,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);
@@ -64,7 +68,10 @@ static void show_clock(int utc)
 static void to_sys_clock(int utc)
 {
        struct timeval tv;
-       const struct timezone tz = { timezone/60 - 60*daylight, 0 };
+       struct timezone tz;
+
+       tz.tz_minuteswest = timezone/60 - 60*daylight;
+       tz.tz_dsttime = 0;
 
        tv.tv_sec = read_rtc(utc);
        tv.tv_usec = 0;
@@ -90,7 +97,7 @@ static void from_sys_clock(int utc)
 #define HWCLOCK_OPT_RTCFILE     0x20
 
 int hwclock_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int hwclock_main(int argc ATTRIBUTE_UNUSED, char **argv)
+int hwclock_main(int argc UNUSED_PARAM, char **argv)
 {
        unsigned opt;
        int utc;