]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
hwclock: move error messages to determine_clock_access_method()
authorSami Kerola <kerolasa@iki.fi>
Sat, 16 Jul 2016 21:15:54 +0000 (22:15 +0100)
committerSami Kerola <kerolasa@iki.fi>
Sat, 4 Feb 2017 23:39:37 +0000 (23:39 +0000)
This makes main() a little bit shorter.

Reviewed-by: J William Piggott <elseifthen@gmx.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
sys-utils/hwclock-rtc.c
sys-utils/hwclock.c

index e9ca9ce393966bb96d0434bb6789b98b5a32bc40..8dd47092f2624befc770d8f17a6302fde76cb723 100644 (file)
@@ -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,
index fe0d6736da1c6cc4baaa6614639ddf696fd69b4e..fc476c088454f08e64fc79f6440eef0976a4c54e 100644 (file)
@@ -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)