From 404fdd2ca44af56e7074ea9324aea550087a1df6 Mon Sep 17 00:00:00 2001 From: J William Piggott Date: Sun, 6 Aug 2017 11:39:33 -0400 Subject: hwclock: move systz into hctosys The set_system_clock_timezone() function is nearly identical to set_system_clock(). Three additional statements are required to include systz in hctosys. This patch is intentionally incomplete to make reviewing the actual required changes easier. Other patches in this set will: * remove set_system_clock_timezone() * fix messages and debugging * fix comments * and finally refactor set_system_clock() Signed-off-by: J William Piggott --- sys-utils/hwclock.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'sys-utils/hwclock.c') diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c index 910e39f1c..e49f1a153 100644 --- a/sys-utils/hwclock.c +++ b/sys-utils/hwclock.c @@ -594,6 +594,7 @@ set_system_clock(const struct hwclock_control *ctl, struct tm *broken; int minuteswest; int rc = 0; + const struct timezone tz_utc = { 0 }; broken = localtime(&newtime.tv_sec); #ifdef HAVE_TM_GMTOFF @@ -621,10 +622,15 @@ set_system_clock(const struct hwclock_control *ctl, * mode does not clobber the Hardware Clock with UTC. This * is only available on first call of settimeofday after boot. */ - if (!ctl->universal) + if (ctl->hctosys && !ctl->universal) /* set PCIL */ rc = settimeofday(tv_null, &tz); - if (!rc) + if (ctl->systz && ctl->universal) /* lock warp_clock */ + rc = settimeofday(tv_null, &tz_utc); + if (!rc && ctl->hctosys) rc = settimeofday(&newtime, &tz); + else if (!rc) + rc = settimeofday(NULL, &tz); + if (rc) { warn(_("settimeofday() failed")); retcode = 1; @@ -1024,7 +1030,7 @@ manipulate_clock(const struct hwclock_control *ctl, const time_t set_time, } if (ctl->systz) - return set_system_clock_timezone(ctl); + return set_system_clock(ctl, startup_time); if (ur->get_permissions()) return EX_NOPERM; -- cgit v1.2.3-55-g7522