summaryrefslogtreecommitdiffstats
path: root/sys-utils/hwclock.c
diff options
context:
space:
mode:
authorSami Kerola2016-07-16 23:15:54 +0200
committerSami Kerola2017-02-05 00:39:37 +0100
commit8f729d60fa6d0c84780b7af31adce599694869c8 (patch)
tree3601199148d6dadee745b42aa9e7a312b898e73c /sys-utils/hwclock.c
parenthwclock: clarify set_cmos_epoch() code (diff)
downloadkernel-qcow2-util-linux-8f729d60fa6d0c84780b7af31adce599694869c8.tar.gz
kernel-qcow2-util-linux-8f729d60fa6d0c84780b7af31adce599694869c8.tar.xz
kernel-qcow2-util-linux-8f729d60fa6d0c84780b7af31adce599694869c8.zip
hwclock: move error messages to determine_clock_access_method()
This makes main() a little bit shorter. Reviewed-by: J William Piggott <elseifthen@gmx.com> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'sys-utils/hwclock.c')
-rw-r--r--sys-utils/hwclock.c29
1 files changed, 13 insertions, 16 deletions
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)