diff options
author | Nihal Jere <nihal@nihaljere.xyz> | 2022-02-28 17:29:56 -0600 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2022-03-15 11:40:32 +0100 |
commit | 78758ef3696d195b8622c34feb042b63cc03bd49 (patch) | |
tree | 944965979137665622dd37b10363763efa5601b5 /swaynag | |
parent | 20729a6a5e4a2a424b7c176f2914927266335594 (diff) |
swaynag: remove redundant status variables in main
Instead, we just use `status` for all failures.
Diffstat (limited to 'swaynag')
-rw-r--r-- | swaynag/main.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/swaynag/main.c b/swaynag/main.c index 3b099e8c..56e4950b 100644 --- a/swaynag/main.c +++ b/swaynag/main.c @@ -20,7 +20,7 @@ void sway_terminate(int code) { } int main(int argc, char **argv) { - int exit_code = EXIT_SUCCESS; + int status = EXIT_SUCCESS; list_t *types = create_list(); swaynag_types_add_default(types); @@ -31,10 +31,9 @@ int main(int argc, char **argv) { char *config_path = NULL; bool debug = false; - int launch_status = swaynag_parse_options(argc, argv, NULL, NULL, NULL, + status = swaynag_parse_options(argc, argv, NULL, NULL, NULL, &config_path, &debug); - if (launch_status != 0) { - exit_code = launch_status; + if (status != 0) { goto cleanup; } sway_log_init(debug ? SWAY_DEBUG : SWAY_ERROR, NULL); @@ -44,10 +43,8 @@ int main(int argc, char **argv) { } if (config_path) { sway_log(SWAY_DEBUG, "Loading config file: %s", config_path); - int config_status = swaynag_load_config(config_path, &swaynag, types); - free(config_path); - if (config_status != 0) { - exit_code = config_status; + status = swaynag_load_config(config_path, &swaynag, types); + if (status != 0) { goto cleanup; } } @@ -59,17 +56,16 @@ int main(int argc, char **argv) { struct swaynag_type *type_args = swaynag_type_new("<args>"); list_add(types, type_args); - int result = swaynag_parse_options(argc, argv, &swaynag, types, + status = swaynag_parse_options(argc, argv, &swaynag, types, type_args, NULL, NULL); - if (result != 0) { - exit_code = result; + if (status != 0) { goto cleanup; } } if (!swaynag.message) { sway_log(SWAY_ERROR, "No message passed. Please provide --message/-m"); - exit_code = EXIT_FAILURE; + status = EXIT_FAILURE; goto cleanup; } @@ -113,11 +109,11 @@ int main(int argc, char **argv) { swaynag_setup(&swaynag); swaynag_run(&swaynag); - return exit_code; + return status; cleanup: swaynag_types_free(types); free(swaynag.details.button_details.text); swaynag_destroy(&swaynag); - return exit_code; + return status; } |