aboutsummaryrefslogtreecommitdiffstats
path: root/swaynag
diff options
context:
space:
mode:
authorLibravatar Nihal Jere <nihal@nihaljere.xyz>2022-02-28 17:29:56 -0600
committerLibravatar Simon Ser <contact@emersion.fr>2022-03-15 11:40:32 +0100
commit78758ef3696d195b8622c34feb042b63cc03bd49 (patch)
tree944965979137665622dd37b10363763efa5601b5 /swaynag
parentswaynag: remove unnecessary zero of swaynag struct (diff)
downloadsway-78758ef3696d195b8622c34feb042b63cc03bd49.tar.gz
sway-78758ef3696d195b8622c34feb042b63cc03bd49.tar.zst
sway-78758ef3696d195b8622c34feb042b63cc03bd49.zip
swaynag: remove redundant status variables in main
Instead, we just use `status` for all failures.
Diffstat (limited to 'swaynag')
-rw-r--r--swaynag/main.c24
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) {
20} 20}
21 21
22int main(int argc, char **argv) { 22int main(int argc, char **argv) {
23 int exit_code = EXIT_SUCCESS; 23 int status = EXIT_SUCCESS;
24 24
25 list_t *types = create_list(); 25 list_t *types = create_list();
26 swaynag_types_add_default(types); 26 swaynag_types_add_default(types);
@@ -31,10 +31,9 @@ int main(int argc, char **argv) {
31 31
32 char *config_path = NULL; 32 char *config_path = NULL;
33 bool debug = false; 33 bool debug = false;
34 int launch_status = swaynag_parse_options(argc, argv, NULL, NULL, NULL, 34 status = swaynag_parse_options(argc, argv, NULL, NULL, NULL,
35 &config_path, &debug); 35 &config_path, &debug);
36 if (launch_status != 0) { 36 if (status != 0) {
37 exit_code = launch_status;
38 goto cleanup; 37 goto cleanup;
39 } 38 }
40 sway_log_init(debug ? SWAY_DEBUG : SWAY_ERROR, NULL); 39 sway_log_init(debug ? SWAY_DEBUG : SWAY_ERROR, NULL);
@@ -44,10 +43,8 @@ int main(int argc, char **argv) {
44 } 43 }
45 if (config_path) { 44 if (config_path) {
46 sway_log(SWAY_DEBUG, "Loading config file: %s", config_path); 45 sway_log(SWAY_DEBUG, "Loading config file: %s", config_path);
47 int config_status = swaynag_load_config(config_path, &swaynag, types); 46 status = swaynag_load_config(config_path, &swaynag, types);
48 free(config_path); 47 if (status != 0) {
49 if (config_status != 0) {
50 exit_code = config_status;
51 goto cleanup; 48 goto cleanup;
52 } 49 }
53 } 50 }
@@ -59,17 +56,16 @@ int main(int argc, char **argv) {
59 struct swaynag_type *type_args = swaynag_type_new("<args>"); 56 struct swaynag_type *type_args = swaynag_type_new("<args>");
60 list_add(types, type_args); 57 list_add(types, type_args);
61 58
62 int result = swaynag_parse_options(argc, argv, &swaynag, types, 59 status = swaynag_parse_options(argc, argv, &swaynag, types,
63 type_args, NULL, NULL); 60 type_args, NULL, NULL);
64 if (result != 0) { 61 if (status != 0) {
65 exit_code = result;
66 goto cleanup; 62 goto cleanup;
67 } 63 }
68 } 64 }
69 65
70 if (!swaynag.message) { 66 if (!swaynag.message) {
71 sway_log(SWAY_ERROR, "No message passed. Please provide --message/-m"); 67 sway_log(SWAY_ERROR, "No message passed. Please provide --message/-m");
72 exit_code = EXIT_FAILURE; 68 status = EXIT_FAILURE;
73 goto cleanup; 69 goto cleanup;
74 } 70 }
75 71
@@ -113,11 +109,11 @@ int main(int argc, char **argv) {
113 109
114 swaynag_setup(&swaynag); 110 swaynag_setup(&swaynag);
115 swaynag_run(&swaynag); 111 swaynag_run(&swaynag);
116 return exit_code; 112 return status;
117 113
118cleanup: 114cleanup:
119 swaynag_types_free(types); 115 swaynag_types_free(types);
120 free(swaynag.details.button_details.text); 116 free(swaynag.details.button_details.text);
121 swaynag_destroy(&swaynag); 117 swaynag_destroy(&swaynag);
122 return exit_code; 118 return status;
123} 119}