summaryrefslogtreecommitdiffstats
path: root/sys-utils/rtcwake.c
diff options
context:
space:
mode:
authorSami Kerola2015-01-10 17:34:25 +0100
committerKarel Zak2015-06-29 13:39:37 +0200
commit64a80678356c65ed232b1a2c958ec24cbb3fec32 (patch)
tree68f7320020eac6c58ebd5ca4e0c7e81dcdcb88df /sys-utils/rtcwake.c
parentrtcwake: enumerate constant mode strings (diff)
downloadkernel-qcow2-util-linux-64a80678356c65ed232b1a2c958ec24cbb3fec32.tar.gz
kernel-qcow2-util-linux-64a80678356c65ed232b1a2c958ec24cbb3fec32.tar.xz
kernel-qcow2-util-linux-64a80678356c65ed232b1a2c958ec24cbb3fec32.zip
rtcwake: replace long if else statement with switch case
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'sys-utils/rtcwake.c')
-rw-r--r--sys-utils/rtcwake.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/sys-utils/rtcwake.c b/sys-utils/rtcwake.c
index ae143d31b..4eb539624 100644
--- a/sys-utils/rtcwake.c
+++ b/sys-utils/rtcwake.c
@@ -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();