diff options
author | Karel Zak | 2012-07-04 13:40:01 +0200 |
---|---|---|
committer | Karel Zak | 2012-07-04 13:43:51 +0200 |
commit | 839be2ba6b44fa9dc927f081d547ebadec9de19c (patch) | |
tree | e1ca652bdb1048e083cc7a30dcdc034483749266 /sys-utils/hwclock.c | |
parent | utmpdump: use xalloc.h, minor coding style changes (diff) | |
download | kernel-qcow2-util-linux-839be2ba6b44fa9dc927f081d547ebadec9de19c.tar.gz kernel-qcow2-util-linux-839be2ba6b44fa9dc927f081d547ebadec9de19c.tar.xz kernel-qcow2-util-linux-839be2ba6b44fa9dc927f081d547ebadec9de19c.zip |
hwclock: don't set time for --systz
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>
Diffstat (limited to 'sys-utils/hwclock.c')
-rw-r--r-- | sys-utils/hwclock.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c index c0ac67826..332f78cd2 100644 --- a/sys-utils/hwclock.c +++ b/sys-utils/hwclock.c @@ -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(_ |