diff options
Diffstat (limited to 'reboot/reboot.c')
-rw-r--r-- | reboot/reboot.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/reboot/reboot.c b/reboot/reboot.c index f0cf40c89..fe763a882 100644 --- a/reboot/reboot.c +++ b/reboot/reboot.c | |||
@@ -21,13 +21,13 @@ | |||
21 | #include <cutils/android_reboot.h> | 21 | #include <cutils/android_reboot.h> |
22 | #include <unistd.h> | 22 | #include <unistd.h> |
23 | 23 | ||
24 | int main(int argc, char *argv[]) | 24 | int main(int argc, char* argv[]) { |
25 | { | ||
26 | int ret; | 25 | int ret; |
27 | size_t prop_len; | 26 | size_t prop_len; |
28 | char property_val[PROPERTY_VALUE_MAX]; | 27 | char property_val[PROPERTY_VALUE_MAX]; |
29 | const char *cmd = "reboot"; | 28 | static const char reboot[] = "reboot"; |
30 | char *optarg = ""; | 29 | const char* cmd = reboot; |
30 | char* optarg = ""; | ||
31 | 31 | ||
32 | opterr = 0; | 32 | opterr = 0; |
33 | do { | 33 | do { |
@@ -60,19 +60,23 @@ int main(int argc, char *argv[]) | |||
60 | 60 | ||
61 | prop_len = snprintf(property_val, sizeof(property_val), "%s,%s", cmd, optarg); | 61 | prop_len = snprintf(property_val, sizeof(property_val), "%s,%s", cmd, optarg); |
62 | if (prop_len >= sizeof(property_val)) { | 62 | if (prop_len >= sizeof(property_val)) { |
63 | fprintf(stderr, "reboot command too long: %s\n", optarg); | 63 | fprintf(stderr, "%s command too long: %s\n", cmd, optarg); |
64 | exit(EXIT_FAILURE); | 64 | exit(EXIT_FAILURE); |
65 | } | 65 | } |
66 | 66 | ||
67 | ret = property_set(ANDROID_RB_PROPERTY, property_val); | 67 | ret = property_set(ANDROID_RB_PROPERTY, property_val); |
68 | if(ret < 0) { | 68 | if (ret < 0) { |
69 | perror("reboot"); | 69 | perror(cmd); |
70 | exit(EXIT_FAILURE); | 70 | exit(EXIT_FAILURE); |
71 | } | 71 | } |
72 | 72 | ||
73 | // Don't return early. Give the reboot command time to take effect | 73 | // Don't return early. Give the reboot command time to take effect |
74 | // to avoid messing up scripts which do "adb shell reboot && adb wait-for-device" | 74 | // to avoid messing up scripts which do "adb shell reboot && adb wait-for-device" |
75 | while(1) { pause(); } | 75 | if (cmd == reboot) { |
76 | while (1) { | ||
77 | pause(); | ||
78 | } | ||
79 | } | ||
76 | 80 | ||
77 | fprintf(stderr, "Done\n"); | 81 | fprintf(stderr, "Done\n"); |
78 | return 0; | 82 | return 0; |