From 8f729d60fa6d0c84780b7af31adce599694869c8 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sat, 16 Jul 2016 22:15:54 +0100 Subject: hwclock: move error messages to determine_clock_access_method() This makes main() a little bit shorter. Reviewed-by: J William Piggott Signed-off-by: Sami Kerola --- sys-utils/hwclock.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'sys-utils/hwclock.c') diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c index fe0d6736d..fc476c088 100644 --- a/sys-utils/hwclock.c +++ b/sys-utils/hwclock.c @@ -1189,17 +1189,24 @@ static void determine_clock_access_method(const struct hwclock_control *ctl) if (ctl->directisa) ur = probe_for_cmos_clock(); - #ifdef __linux__ if (!ur) ur = probe_for_rtc_clock(ctl); #endif + if (ur) { + if (ctl->debug) + puts(ur->interface_name); - if (ctl->debug) { - if (ur) - puts(_(ur->interface_name)); - else + } else { + if (ctl->debug) printf(_("No usable clock interface found.\n")); + warnx(_("Cannot access the Hardware Clock via " + "any known method.")); + if (!ctl->debug) + warnx(_("Use the --debug option to see the " + "details of our search for an access " + "method.")); + hwclock_exit(ctl, EX_SOFTWARE); } } @@ -1821,18 +1828,8 @@ int main(int argc, char **argv) if (ctl.debug) out_version(); - if (!ctl.systz && !ctl.predict) { + if (!ctl.systz && !ctl.predict) determine_clock_access_method(&ctl); - if (!ur) { - warnx(_("Cannot access the Hardware Clock via " - "any known method.")); - if (!ctl.debug) - warnx(_("Use the --debug option to see the " - "details of our search for an access " - "method.")); - hwclock_exit(&ctl, EX_SOFTWARE); - } - } if (!ctl.noadjfile && !(ctl.systz && (ctl.utc || ctl.local_opt))) { if ((rc = read_adjtime(&ctl, &adjtime)) != 0) -- cgit v1.2.3-55-g7522