summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys-utils/hwclock.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c
index e172fb1bf..df6b59e86 100644
--- a/sys-utils/hwclock.c
+++ b/sys-utils/hwclock.c
@@ -1029,9 +1029,14 @@ manipulate_clock(const struct hwclock_control *ctl, const time_t set_time,
bool hclock_valid = FALSE;
/*
* Tick synchronized time read from the Hardware Clock and
- * then drift correct for all operations except --show.
+ * then drift corrected for all operations except --show.
*/
- struct timeval hclocktime = { 0, 0 };
+ struct timeval hclocktime = { 0 };
+ /*
+ * hclocktime correlated to startup_time. That is, what drift
+ * corrected Hardware Clock time would have been at start up.
+ */
+ struct timeval startup_hclocktime = { 0 };
/* Total Hardware Clock drift correction needed. */
struct timeval tdrift;
@@ -1096,18 +1101,17 @@ manipulate_clock(const struct hwclock_control *ctl, const time_t set_time,
hclocktime.tv_sec, &tdrift);
if (!ctl->show)
hclocktime = time_inc(tdrift, hclocktime.tv_sec);
+
+ startup_hclocktime =
+ time_inc(hclocktime, time_diff(startup_time, read_time));
}
if (ctl->show || ctl->get) {
- display_time(hclock_valid,
- time_inc(hclocktime, -time_diff
- (read_time, startup_time)));
+ display_time(hclock_valid, startup_hclocktime);
} else if (ctl->set) {
set_hardware_clock_exact(ctl, set_time, startup_time);
if (!ctl->noadjfile)
- adjust_drift_factor(ctl, adjtime,
- time_inc(t2tv(set_time), time_diff
- (read_time, startup_time)),
- hclock_valid, hclocktime);
+ adjust_drift_factor(ctl, adjtime, t2tv(set_time),
+ hclock_valid, startup_hclocktime);
} else if (ctl->adjust) {
if (tdrift.tv_sec > 0 || tdrift.tv_sec < -1)
do_adjustment(ctl, adjtime, hclock_valid,