]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
rtcwake: replace long if else statement with switch case
authorSami Kerola <kerolasa@iki.fi>
Sat, 10 Jan 2015 16:34:25 +0000 (16:34 +0000)
committerKarel Zak <kzak@redhat.com>
Mon, 29 Jun 2015 11:39:37 +0000 (13:39 +0200)
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
sys-utils/rtcwake.c

index ae143d31b7b6a87eb15bbafda52c5a966f7005e0..4eb539624c599def254d6294abe9a67bc8324729 100644 (file)
@@ -588,12 +588,15 @@ int main(int argc, char **argv)
                xusleep(10 * 1000);
        }
 
-       if (suspend == NO_MODE) {
+       switch (suspend) {
+       case NO_MODE:
                if (ctl.verbose)
                        printf(_("suspend mode: no; leaving\n"));
                ctl.dryrun = 1; /* to skip disabling alarm at the end */
+               break;
 
-       } else if (suspend == OFF_MODE) {
+       case OFF_MODE:
+       {
                char *arg[5];
                int i = 0;
 
@@ -612,8 +615,10 @@ int main(int argc, char **argv)
                        warn(_("failed to execute %s"), _PATH_SHUTDOWN);
                        rc = EXIT_FAILURE;
                }
-
-       } else if (suspend == ON_MODE) {
+               break;
+       }
+       case ON_MODE:
+       {
                unsigned long data;
 
                if (ctl.verbose)
@@ -630,20 +635,23 @@ int main(int argc, char **argv)
                                        printf("... %s: %03lx\n", devname, data);
                        } while (!(data & RTC_AF));
                }
-
-       } else if (suspend == DISABLE_MODE) {
+               break;
+       }
+       case DISABLE_MODE:
                /* just break, alarm gets disabled in the end */
                if (ctl.verbose)
                        printf(_("suspend mode: disable; disabling alarm\n"));
+               break;
 
-       } else if (suspend == SHOW_MODE) {
+       case SHOW_MODE:
                if (ctl.verbose)
                        printf(_("suspend mode: show; printing alarm info\n"));
                if (print_alarm(&ctl, fd))
                        rc = EXIT_FAILURE;
                ctl.dryrun = 1; /* don't really disable alarm in the end, just show */
+               break;
 
-       } else {
+       default:
                if (ctl.verbose)
                        printf(_("suspend mode: %s; suspending system\n"), mode_str[suspend]);
                sync();