mirror of
https://github.com/NickHu/sway
synced 2024-12-28 22:23:30 +01:00
refactor: use sway_abort instead
This commit is contained in:
parent
96baef8ae9
commit
b223f70250
1 changed files with 28 additions and 26 deletions
|
@ -487,9 +487,11 @@ int main(int argc, char **argv) {
|
||||||
// pretty print the json
|
// pretty print the json
|
||||||
json_tokener *tok = json_tokener_new_ex(JSON_MAX_DEPTH);
|
json_tokener *tok = json_tokener_new_ex(JSON_MAX_DEPTH);
|
||||||
if (tok == NULL) {
|
if (tok == NULL) {
|
||||||
sway_log(SWAY_ERROR, "failed allocating json_tokener");
|
if (quiet) {
|
||||||
ret = 1;
|
exit(EXIT_FAILURE);
|
||||||
} else {
|
}
|
||||||
|
sway_abort("failed allocating json_tokener");
|
||||||
|
}
|
||||||
json_object *obj = json_tokener_parse_ex(tok, resp, -1);
|
json_object *obj = json_tokener_parse_ex(tok, resp, -1);
|
||||||
enum json_tokener_error err = json_tokener_get_error(tok);
|
enum json_tokener_error err = json_tokener_get_error(tok);
|
||||||
json_tokener_free(tok);
|
json_tokener_free(tok);
|
||||||
|
@ -513,7 +515,6 @@ int main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
json_object_put(obj);
|
json_object_put(obj);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
free(command);
|
free(command);
|
||||||
free(resp);
|
free(resp);
|
||||||
|
|
||||||
|
@ -531,9 +532,10 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
json_tokener *tok = json_tokener_new_ex(JSON_MAX_DEPTH);
|
json_tokener *tok = json_tokener_new_ex(JSON_MAX_DEPTH);
|
||||||
if (tok == NULL) {
|
if (tok == NULL) {
|
||||||
sway_log(SWAY_ERROR, "failed allocating json_tokener");
|
if (quiet) {
|
||||||
ret = 1;
|
exit(EXIT_FAILURE);
|
||||||
break;
|
}
|
||||||
|
sway_abort("failed allocating json_tokener");
|
||||||
}
|
}
|
||||||
json_object *obj = json_tokener_parse_ex(tok, reply->payload, -1);
|
json_object *obj = json_tokener_parse_ex(tok, reply->payload, -1);
|
||||||
enum json_tokener_error err = json_tokener_get_error(tok);
|
enum json_tokener_error err = json_tokener_get_error(tok);
|
||||||
|
|
Loading…
Reference in a new issue