aboutsummaryrefslogtreecommitdiff
path: root/toys
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2016-06-25 14:57:39 -0500
committerRob Landley <rob@landley.net>2016-06-25 14:57:39 -0500
commitc02e584c5915b8ab0793b51664d3e4a27c7bda6c (patch)
tree0346e2f8f59015e8d8bad425b9247eab357a9404 /toys
parent8c5cc551ed02fbf4b67488c58e7462ad2538afb6 (diff)
downloadtoybox-c02e584c5915b8ab0793b51664d3e4a27c7bda6c.tar.gz
Code style pass.
Diffstat (limited to 'toys')
-rw-r--r--toys/android/start.c33
1 files changed, 12 insertions, 21 deletions
diff --git a/toys/android/start.c b/toys/android/start.c
index 8981b679..82703b1f 100644
--- a/toys/android/start.c
+++ b/toys/android/start.c
@@ -29,28 +29,23 @@ config STOP
#include <cutils/properties.h>
-static const char *services[] = {
- "netd", "surfaceflinger", "zygote", "zygote_secondary", NULL,
-};
-
static void start_stop(int start)
{
- const char* property = start ? "ctl.start" : "ctl.stop";
- int i;
+ // null terminated in both directions
+ char *services[] = {0,"netd","surfaceflinger","zygote","zygote_secondary",0},
+ **ss = toys.optargs;
+ int direction = 1;
- if (getuid() != 0) error_exit("must be root");
+ if (getuid()) error_exit("must be root");
- if (*toys.optargs) {
- for (i = 0; toys.optargs[i]; i++) property_set(property, toys.optargs[i]);
- } else if (start) {
- for (i = 0; i < ARRAY_LEN(services); ++i) {
- property_set(property, services[i]);
- }
- } else {
- for (i = ARRAY_LEN(services) - 1; i >= 0; --i) {
- property_set(property, services[i]);
- }
+ if (!*ss) {
+ // Iterate through optargs, or services forward/backward.
+ ss = services+1;
+ if (!start) ss += ARRAY_LEN(services)-1, direction = -1;
}
+
+ for (; *ss; ss += direction)
+ property_set(start ? "ctl.start" : "ctl.stop", property, *ss);
}
void start_main(void)
@@ -58,10 +53,6 @@ void start_main(void)
start_stop(1);
}
-#define CLEANUP_start
-#define FOR_stop
-#include "generated/flags.h"
-
void stop_main(void)
{
start_stop(0);