aboutsummaryrefslogtreecommitdiff
path: root/toys
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2013-10-17 14:43:38 -0500
committerRob Landley <rob@landley.net>2013-10-17 14:43:38 -0500
commit4aee303add071ca3c1f6af54238556e117365357 (patch)
treec3c9ed443110cf0c730f48d97155f64cf7fa4721 /toys
parent9b2b24a1e88f4e96e431b0292831d13995fbdd7f (diff)
downloadtoybox-4aee303add071ca3c1f6af54238556e117365357.tar.gz
Minor cleanup of reboot
Diffstat (limited to 'toys')
-rw-r--r--toys/other/reboot.c21
1 files changed, 5 insertions, 16 deletions
diff --git a/toys/other/reboot.c b/toys/other/reboot.c
index ae70cf91..5cbc4f87 100644
--- a/toys/other/reboot.c
+++ b/toys/other/reboot.c
@@ -23,20 +23,9 @@ config REBOOT
void reboot_main(void)
{
- char c = toys.which->name[0];
-
- if (!(toys.optflags & FLAG_n))
- sync();
-
- 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);
- }
+ int types[] = {RB_AUTOBOOT, RB_HALT_SYSTEM, RB_POWER_OFF};
+
+ if (!(toys.optflags & FLAG_n)) sync();
+
+ toys.exitval = reboot(types[stridx("hp", *toys.which->name)+1]);
}