summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2011-06-12 19:33:23 +0000
committerJay Freeman (saurik) <saurik@saurik.com>2011-06-12 19:33:23 +0000
commit2dd5da1605dad121be0de8d4be4361c58808b350 (patch)
tree23d43dc049a6a3929d63f7a2215dd5a8a7e52c72
parentd9e253f67bf1ec5a63fec7061a4b8899c6ba8d0e (diff)
Simplify sbreload code.
-rw-r--r--sbreload.c33
1 files changed, 15 insertions, 18 deletions
diff --git a/sbreload.c b/sbreload.c
index e499118..dc669d5 100644
--- a/sbreload.c
+++ b/sbreload.c
@@ -122,10 +122,7 @@ void stop() {
}
int main(int argc, const char *argv[]) {
- if (argc > 1) {
- fprintf(stderr, "usage: sbreload\n");
- return 1;
- }
+ _assert(argc == 1, "usage: sbreload");
CFDictionaryRef plist = CreateMyPropertyListFromFile("/System/Library/LaunchDaemons/com.apple.SpringBoard.plist");
_assert(plist != NULL, "CreateMyPropertyListFromFile() == NULL");
@@ -175,23 +172,23 @@ int main(int argc, const char *argv[]) {
request = launch_data_alloc(LAUNCH_DATA_DICTIONARY);
launch_data_dict_insert(request, job, LAUNCH_KEY_SUBMITJOB);
- launch_msg:
- response = launch_msg(request);
- _assert(response != NULL, "launch_msg(SubmitJob) == NULL");
+ for (;;) {
+ response = launch_msg(request);
+ _assert(response != NULL, "launch_msg(SubmitJob) == NULL");
- _assert(launch_data_get_type(response) == LAUNCH_DATA_ERRNO, "launch_data_get_type() != ERRNO");
- int error = launch_data_get_errno(response);
- launch_data_free(response);
+ _assert(launch_data_get_type(response) == LAUNCH_DATA_ERRNO, "launch_data_get_type() != ERRNO");
+ int error = launch_data_get_errno(response);
+ launch_data_free(response);
- const char *string = strerror(error);
+ const char *string = strerror(error);
- if (error == EEXIST) {
- fprintf(stderr, "SubmitJob(%s): %s, retrying...\n", label, string);
- stop();
- goto launch_msg;
- } else if (error != 0) {
- fprintf(stderr, "SubmitJob(%s): %s\n", label, string);
- return 6;
+ if (error == EEXIST) {
+ fprintf(stderr, "SubmitJob(%s): %s, retrying...\n", label, string);
+ stop();
+ } else {
+ _assert(error == 0, "SubmitJob(%s): %s", label, string);
+ break;
+ }
}
launch_data_free(request);