Skip to content

Commit

Permalink
hwclock: remove --compare option
Browse files Browse the repository at this point in the history
Compare functionality was printing nonsense values.  There is no knowledge
of anyone using this broken functionality.  Instead of deprecating the code
for months, and removing it after few release, it is removed immediately.
Needless to say this is unusual removal.

Reference: http://marc.info/?l=util-linux-ng&m=148396210506652&w=2
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
  • Loading branch information
kerolasa committed Feb 4, 2017
1 parent c9a86ff commit 92931ab
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 80 deletions.
5 changes: 5 additions & 0 deletions Documentation/deprecated.txt
Expand Up @@ -8,6 +8,11 @@ since: v2.30

--------------------------

what: hwclock --compare
why: Output printed by --compare option was nonesense.

--------------------------

what: tailf
why: "tail -f" is better nowadays, tailf has unfixed bugs

Expand Down
1 change: 0 additions & 1 deletion bash-completion/hwclock
Expand Up @@ -32,7 +32,6 @@ _hwclock_module()
--systohc
--systz
--adjust
--compare
--getepoch
--setepoch
--predict
Expand Down
6 changes: 0 additions & 6 deletions sys-utils/hwclock.8.in
Expand Up @@ -41,12 +41,6 @@ discussion below, under
.BR "The Adjust Function" .
.
.TP
.BR \-c , \ \-\-compare
Periodically compare the Hardware Clock to the System Time and output
the difference every 10 seconds. This will also print the frequency
offset and tick.
.
.TP
.B \-\-getepoch
.TQ
.B \-\-setepoch
Expand Down
75 changes: 3 additions & 72 deletions sys-utils/hwclock.c
Expand Up @@ -1364,63 +1364,6 @@ manipulate_epoch(const struct hwclock_control *ctl)
# endif /* __alpha__ */
#endif /* __linux__ */

/*
* Compare the system and CMOS time and output the drift
* in 10 second intervals.
*/
static int compare_clock(const struct hwclock_control *ctl)
{
struct tm tm;
struct timeval tv;
double time1_sys, time2_sys;
time_t time1_hw, time2_hw;
bool hclock_valid = FALSE, first_pass = TRUE;

if (ur->get_permissions())
return EX_NOPERM;

/* dummy call for increased precision */
gettimeofday(&tv, NULL);

synchronize_to_clock_tick(ctl);
ur->read_hardware_clock(ctl, &tm);

gettimeofday(&tv, NULL);
time1_sys = tv.tv_sec + tv.tv_usec / 1000000.0;

mktime_tz(ctl, tm, &hclock_valid, &time1_hw);

while (1) {
double res;

synchronize_to_clock_tick(ctl);
ur->read_hardware_clock(ctl, &tm);

gettimeofday(&tv, NULL);
time2_sys = tv.tv_sec + tv.tv_usec / 1000000.0;

mktime_tz(ctl, tm, &hclock_valid, &time2_hw);

if ((res = time2_hw - time1_hw))
res = (((double)time1_hw - time1_sys) -
((double)time2_hw - time2_sys))
/ res;

if (!first_pass)
printf("%10.0f %10.6f %15.0f %4.0f\n",
(double) time2_hw, time2_sys, res * 1e6, res *1e4);
else {
first_pass = FALSE;
printf("hw-time system-time freq-offset-ppm tick\n");
printf("%10.0f %10.6f\n", (double) time1_hw, time1_sys);
}
fflush(stdout);
sleep(10);
}

return 0;
}

static void out_version(void)
{
printf(UTIL_LINUX_VERSION);
Expand Down Expand Up @@ -1459,7 +1402,6 @@ static void usage(const struct hwclock_control *ctl, const char *fmt, ...)
" --systz set the system time based on the current timezone\n"
" --adjust adjust the RTC to account for systematic drift since\n"
" the clock was last set or adjusted\n"), usageto);
fputs(_(" -c, --compare periodically compare the system clock with the CMOS clock\n"), usageto);
#ifdef __linux__
fputs(_(" --getepoch print out the kernel's hardware clock epoch value\n"
" --setepoch set the kernel's hardware clock epoch value to the \n"
Expand Down Expand Up @@ -1547,7 +1489,6 @@ int main(int argc, char **argv)

static const struct option longopts[] = {
{"adjust", 0, 0, 'a'},
{"compare", 0, 0, 'c'},
{"help", 0, 0, 'h'},
{"show", 0, 0, 'r'},
{"hctosys", 0, 0, 's'},
Expand Down Expand Up @@ -1627,7 +1568,7 @@ int main(int argc, char **argv)
atexit(close_stdout);

while ((c = getopt_long(argc, argv,
"?hvVDacrsuwAJSFf:", longopts, NULL)) != -1) {
"?hvVDarsuwAJSFf:", longopts, NULL)) != -1) {

err_exclusive_options(c, longopts, excl, excl_st);

Expand All @@ -1638,9 +1579,6 @@ int main(int argc, char **argv)
case 'a':
ctl.adjust = 1;
break;
case 'c':
ctl.compare = 1;
break;
case 'r':
ctl.show = 1;
break;
Expand Down Expand Up @@ -1773,7 +1711,7 @@ int main(int argc, char **argv)

if (!(ctl.show | ctl.set | ctl.systohc | ctl.hctosys |
ctl.systz | ctl.adjust | ctl.getepoch | ctl.setepoch |
ctl.predict | ctl.compare | ctl.get))
ctl.predict | ctl.get))
ctl.show = 1; /* default to show */

#ifdef __linux__
Expand All @@ -1796,14 +1734,7 @@ int main(int argc, char **argv)
/* Avoid writing adjtime file if we don't have to. */
adjtime.dirty = FALSE;
ctl.universal = hw_clock_is_utc(&ctl, adjtime);
if (ctl.compare) {
if (compare_clock(&ctl))
hwclock_exit(&ctl, EX_NOPERM);

rc = EX_OK;
} else
rc = manipulate_clock(&ctl, set_time, startup_time, &adjtime);

rc = manipulate_clock(&ctl, set_time, startup_time, &adjtime);
hwclock_exit(&ctl, rc);
return rc; /* Not reached */
}
Expand Down
1 change: 0 additions & 1 deletion sys-utils/hwclock.h
Expand Up @@ -28,7 +28,6 @@ struct hwclock_control {
hwaudit_on:1,
#endif
adjust:1,
compare:1,
show:1,
hctosys:1,
utc:1,
Expand Down

0 comments on commit 92931ab

Please sign in to comment.