[PATCH 03/13] rtcwake: replace long if else statement with switch case

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Sami Kerola <kerolasa@xxxxxx>
---
 sys-utils/rtcwake.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/sys-utils/rtcwake.c b/sys-utils/rtcwake.c
index 372e620..5f4b602 100644
--- a/sys-utils/rtcwake.c
+++ b/sys-utils/rtcwake.c
@@ -602,12 +602,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;
 
@@ -626,8 +629,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)
@@ -644,20 +649,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();
-- 
2.3.0

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux