From: Sami Kerola Date: Sat, 16 Jul 2016 21:15:54 +0000 (+0100) Subject: hwclock: move error messages to determine_clock_access_method() X-Git-Tag: v2.30-rc1~267^2~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8f729d60fa6d0c84780b7af31adce599694869c8;p=thirdparty%2Futil-linux.git 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 --- diff --git a/sys-utils/hwclock-rtc.c b/sys-utils/hwclock-rtc.c index e9ca9ce393..8dd47092f2 100644 --- a/sys-utils/hwclock-rtc.c +++ b/sys-utils/hwclock-rtc.c @@ -387,7 +387,7 @@ static int get_permissions_rtc(void) } static struct clock_ops rtc = { - N_("Using the /dev interface to the clock."), + N_("Using the rtc interface to the clock."), get_permissions_rtc, read_hardware_clock_rtc, set_hardware_clock_rtc, diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c index fe0d6736da..fc476c0884 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)