From: Karel Zak Date: Wed, 4 Jul 2012 11:40:01 +0000 (+0200) Subject: hwclock: don't set time for --systz X-Git-Tag: v2.22-rc1~188 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=839be2ba6b44fa9dc927f081d547ebadec9de19c;p=thirdparty%2Futil-linux.git 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 --- diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c index c0ac678263..332f78cd2f 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(_