aboutsummaryrefslogtreecommitdiff
path: root/toys/other/reboot.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2015-08-05 21:39:53 -0500
committerRob Landley <rob@landley.net>2015-08-05 21:39:53 -0500
commit802642ada1acd23fb4559678a916d2c00f6d1355 (patch)
tree01dce619a3edf8c8c24fd6cdd0a7204f05811298 /toys/other/reboot.c
parenta12eec740dc6d0c533fb7d83a0a54de6d3abb17c (diff)
downloadtoybox-802642ada1acd23fb4559678a916d2c00f6d1355.tar.gz
Minor tweak of reboot.c
Diffstat (limited to 'toys/other/reboot.c')
-rw-r--r--toys/other/reboot.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/toys/other/reboot.c b/toys/other/reboot.c
index 9193ba4e..1e8f5e9b 100644
--- a/toys/other/reboot.c
+++ b/toys/other/reboot.c
@@ -24,13 +24,12 @@ config REBOOT
void reboot_main(void)
{
- int types[] = {RB_AUTOBOOT, RB_HALT_SYSTEM, RB_POWER_OFF};
- int sigs[] = {SIGINT, SIGUSR1, SIGUSR2};
+ int types[] = {RB_AUTOBOOT, RB_HALT_SYSTEM, RB_POWER_OFF},
+ sigs[] = {SIGINT, SIGUSR1, SIGUSR2}, idx;
if (!(toys.optflags & FLAG_n)) sync();
- if (toys.optflags & FLAG_f)
- toys.exitval = reboot(types[stridx("hp", *toys.which->name)+1]);
- else
- toys.exitval = kill(1, sigs[stridx("hp", *toys.which->name)+1]);
+ idx = stridx("hp", *toys.which->name)+1;
+ if (toys.optflags & FLAG_f) toys.exitval = reboot(types[idx]);
+ else toys.exitval = kill(1, sigs[idx]);
}