]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
hwclock: don't set time for --systz
authorKarel Zak <kzak@redhat.com>
Wed, 4 Jul 2012 11:40:01 +0000 (13:40 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 4 Jul 2012 11:43:51 +0000 (13:43 +0200)
Not sure why, but the current --systz uses non-NULL timeval for
settimeofday(). It means that build-in kernel warp clock mechanism is
not used and the system time is always modified.

The built-in kernel implementation allows to move the clock by
timezone only for very first settimeofday() call.

Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/hwclock.c

index c0ac678263d226b4829220c668f21cede3e03c1b..332f78cd2f2638ade526ef522c00c67ab5067427 100644 (file)
@@ -814,14 +814,14 @@ static int set_system_clock_timezone(const bool universal, const bool testing)
                minuteswest -= 60;
 #endif
 
-       gettimeofday(&tv, NULL);
-       if (!universal)
-               tv.tv_sec += minuteswest * 60;
-
        if (debug) {
                struct tm broken_time;
                char ctime_now[200];
 
+               gettimeofday(&tv, NULL);
+               if (!universal)
+                       tv.tv_sec += minuteswest * 60;
+
                broken_time = *gmtime(&tv.tv_sec);
                strftime(ctime_now, sizeof(ctime_now), "%Y/%m/%d %H:%M:%S",
                         &broken_time);
@@ -838,8 +838,9 @@ static int set_system_clock_timezone(const bool universal, const bool testing)
                retcode = 0;
        } else {
                const struct timezone tz = { minuteswest, 0 };
+               const struct timeval *tv_null = NULL;
 
-               rc = settimeofday(&tv, &tz);
+               rc = settimeofday(tv_null, &tz);
                if (rc) {
                        if (errno == EPERM) {
                                warnx(_