changeset 1093:e1d3a9ac9e9f draft

Minor cleanup of reboot
author Rob Landley <rob@landley.net>
date Thu, 17 Oct 2013 14:43:38 -0500
parents 1a5c7092afbf
children 370f15d1ece1
files toys/other/reboot.c
diffstat 1 files changed, 4 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/toys/other/reboot.c	Tue Oct 01 20:57:21 2013 +0200
+++ b/toys/other/reboot.c	Thu Oct 17 14:43:38 2013 -0500
@@ -23,20 +23,9 @@
 
 void reboot_main(void)
 {
-  char c = toys.which->name[0];
-
-  if (!(toys.optflags & FLAG_n))
-    sync();
+  int types[] = {RB_AUTOBOOT, RB_HALT_SYSTEM, RB_POWER_OFF};
 
-  switch(c) {
-  case 'p':
-    toys.exitval = reboot(RB_POWER_OFF);
-      break;
-  case 'h':
-    toys.exitval = reboot(RB_HALT_SYSTEM);
-    break;
-  case 'r':
-  default:
-    toys.exitval = reboot(RB_AUTOBOOT);
-  }
+  if (!(toys.optflags & FLAG_n)) sync();
+
+  toys.exitval = reboot(types[stridx("hp", *toys.which->name)+1]);
 }