aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/output
diff options
context:
space:
mode:
authorLibravatar M Stoeckl <code@mstoeckl.com>2019-01-10 18:27:21 -0500
committerLibravatar M Stoeckl <code@mstoeckl.com>2019-01-14 08:05:29 -0500
commit2a684cad5fc8e12a8e47a7fd00e2b7c66b43afb0 (patch)
tree56332b9c150459beb5aef94605372ef179ec8854 /sway/commands/output
parentRemove 'input' field of IPC command return json (diff)
downloadsway-2a684cad5fc8e12a8e47a7fd00e2b7c66b43afb0.tar.gz
sway-2a684cad5fc8e12a8e47a7fd00e2b7c66b43afb0.tar.zst
sway-2a684cad5fc8e12a8e47a7fd00e2b7c66b43afb0.zip
Remove now-unused "input" argument of cmd_results_new
Patch tested by compiling with `__attribute__ ((format (printf, 2, 3)))` applied to `cmd_results_new`. String usage constants have been converted from pointers to arrays when encountered. General handler format strings were sometimes modified to include the old input string, especially for unknown command errors.
Diffstat (limited to 'sway/commands/output')
-rw-r--r--sway/commands/output/background.c17
-rw-r--r--sway/commands/output/disable.c2
-rw-r--r--sway/commands/output/dpms.c4
-rw-r--r--sway/commands/output/enable.c2
-rw-r--r--sway/commands/output/mode.c17
-rw-r--r--sway/commands/output/position.c17
-rw-r--r--sway/commands/output/scale.c7
-rw-r--r--sway/commands/output/transform.c12
8 files changed, 33 insertions, 45 deletions
diff --git a/sway/commands/output/background.c b/sway/commands/output/background.c
index 2cd1b76a..ae2f0640 100644
--- a/sway/commands/output/background.c
+++ b/sway/commands/output/background.c
@@ -20,14 +20,14 @@ static const char *bg_options[] = {
20 20
21struct cmd_results *output_cmd_background(int argc, char **argv) { 21struct cmd_results *output_cmd_background(int argc, char **argv) {
22 if (!config->handler_context.output_config) { 22 if (!config->handler_context.output_config) {
23 return cmd_results_new(CMD_FAILURE, "output", "Missing output config"); 23 return cmd_results_new(CMD_FAILURE, "Missing output config");
24 } 24 }
25 if (!argc) { 25 if (!argc) {
26 return cmd_results_new(CMD_INVALID, "output", 26 return cmd_results_new(CMD_INVALID,
27 "Missing background file or color specification."); 27 "Missing background file or color specification.");
28 } 28 }
29 if (argc < 2) { 29 if (argc < 2) {
30 return cmd_results_new(CMD_INVALID, "output", 30 return cmd_results_new(CMD_INVALID,
31 "Missing background scaling mode or `solid_color`."); 31 "Missing background scaling mode or `solid_color`.");
32 } 32 }
33 33
@@ -57,7 +57,7 @@ struct cmd_results *output_cmd_background(int argc, char **argv) {
57 } 57 }
58 } 58 }
59 if (!valid) { 59 if (!valid) {
60 return cmd_results_new(CMD_INVALID, "output", 60 return cmd_results_new(CMD_INVALID,
61 "Missing background scaling mode."); 61 "Missing background scaling mode.");
62 } 62 }
63 63
@@ -70,7 +70,7 @@ struct cmd_results *output_cmd_background(int argc, char **argv) {
70 *ptr = '\\'; 70 *ptr = '\\';
71 } 71 }
72 if (wordexp(src, &p, 0) != 0 || p.we_wordv[0] == NULL) { 72 if (wordexp(src, &p, 0) != 0 || p.we_wordv[0] == NULL) {
73 struct cmd_results *cmd_res = cmd_results_new(CMD_INVALID, "output", 73 struct cmd_results *cmd_res = cmd_results_new(CMD_INVALID,
74 "Invalid syntax (%s)", src); 74 "Invalid syntax (%s)", src);
75 free(src); 75 free(src);
76 wordfree(&p); 76 wordfree(&p);
@@ -81,8 +81,7 @@ struct cmd_results *output_cmd_background(int argc, char **argv) {
81 wordfree(&p); 81 wordfree(&p);
82 if (!src) { 82 if (!src) {
83 wlr_log(WLR_ERROR, "Failed to duplicate string"); 83 wlr_log(WLR_ERROR, "Failed to duplicate string");
84 return cmd_results_new(CMD_FAILURE, "output", 84 return cmd_results_new(CMD_FAILURE, "Unable to allocate resource");
85 "Unable to allocate resource");
86 } 85 }
87 86
88 if (config->reading && *src != '/') { 87 if (config->reading && *src != '/') {
@@ -92,7 +91,7 @@ struct cmd_results *output_cmd_background(int argc, char **argv) {
92 if (!conf) { 91 if (!conf) {
93 wlr_log(WLR_ERROR, "Failed to duplicate string"); 92 wlr_log(WLR_ERROR, "Failed to duplicate string");
94 free(src); 93 free(src);
95 return cmd_results_new(CMD_FAILURE, "output", 94 return cmd_results_new(CMD_FAILURE,
96 "Unable to allocate resources"); 95 "Unable to allocate resources");
97 } 96 }
98 97
@@ -103,7 +102,7 @@ struct cmd_results *output_cmd_background(int argc, char **argv) {
103 free(rel_path); 102 free(rel_path);
104 free(conf); 103 free(conf);
105 wlr_log(WLR_ERROR, "Unable to allocate memory"); 104 wlr_log(WLR_ERROR, "Unable to allocate memory");
106 return cmd_results_new(CMD_FAILURE, "output", 105 return cmd_results_new(CMD_FAILURE,
107 "Unable to allocate resources"); 106 "Unable to allocate resources");
108 } 107 }
109 108
diff --git a/sway/commands/output/disable.c b/sway/commands/output/disable.c
index 65517c49..624f4056 100644
--- a/sway/commands/output/disable.c
+++ b/sway/commands/output/disable.c
@@ -3,7 +3,7 @@
3 3
4struct cmd_results *output_cmd_disable(int argc, char **argv) { 4struct cmd_results *output_cmd_disable(int argc, char **argv) {
5 if (!config->handler_context.output_config) { 5 if (!config->handler_context.output_config) {
6 return cmd_results_new(CMD_FAILURE, "output", "Missing output config"); 6 return cmd_results_new(CMD_FAILURE, "Missing output config");
7 } 7 }
8 config->handler_context.output_config->enabled = 0; 8 config->handler_context.output_config->enabled = 0;
9 9
diff --git a/sway/commands/output/dpms.c b/sway/commands/output/dpms.c
index 3492061e..9d75a80e 100644
--- a/sway/commands/output/dpms.c
+++ b/sway/commands/output/dpms.c
@@ -4,10 +4,10 @@
4 4
5struct cmd_results *output_cmd_dpms(int argc, char **argv) { 5struct cmd_results *output_cmd_dpms(int argc, char **argv) {
6 if (!config->handler_context.output_config) { 6 if (!config->handler_context.output_config) {
7 return cmd_results_new(CMD_FAILURE, "output", "Missing output config"); 7 return cmd_results_new(CMD_FAILURE, "Missing output config");
8 } 8 }
9 if (!argc) { 9 if (!argc) {
10 return cmd_results_new(CMD_INVALID, "output", "Missing dpms argument."); 10 return cmd_results_new(CMD_INVALID, "Missing dpms argument.");
11 } 11 }
12 12
13 if (parse_boolean(argv[0], true)) { 13 if (parse_boolean(argv[0], true)) {
diff --git a/sway/commands/output/enable.c b/sway/commands/output/enable.c
index 8e3314f8..71a7d75a 100644
--- a/sway/commands/output/enable.c
+++ b/sway/commands/output/enable.c
@@ -3,7 +3,7 @@
3 3
4struct cmd_results *output_cmd_enable(int argc, char **argv) { 4struct cmd_results *output_cmd_enable(int argc, char **argv) {
5 if (!config->handler_context.output_config) { 5 if (!config->handler_context.output_config) {
6 return cmd_results_new(CMD_FAILURE, "output", "Missing output config"); 6 return cmd_results_new(CMD_FAILURE, "Missing output config");
7 } 7 }
8 config->handler_context.output_config->enabled = 1; 8 config->handler_context.output_config->enabled = 1;
9 9
diff --git a/sway/commands/output/mode.c b/sway/commands/output/mode.c
index ef56ae9e..bcfce372 100644
--- a/sway/commands/output/mode.c
+++ b/sway/commands/output/mode.c
@@ -4,10 +4,10 @@
4 4
5struct cmd_results *output_cmd_mode(int argc, char **argv) { 5struct cmd_results *output_cmd_mode(int argc, char **argv) {
6 if (!config->handler_context.output_config) { 6 if (!config->handler_context.output_config) {
7 return cmd_results_new(CMD_FAILURE, "output", "Missing output config"); 7 return cmd_results_new(CMD_FAILURE, "Missing output config");
8 } 8 }
9 if (!argc) { 9 if (!argc) {
10 return cmd_results_new(CMD_INVALID, "output", "Missing mode argument."); 10 return cmd_results_new(CMD_INVALID, "Missing mode argument.");
11 } 11 }
12 12
13 struct output_config *output = config->handler_context.output_config; 13 struct output_config *output = config->handler_context.output_config;
@@ -17,20 +17,18 @@ struct cmd_results *output_cmd_mode(int argc, char **argv) {
17 if (*end) { 17 if (*end) {
18 // Format is 1234x4321 18 // Format is 1234x4321
19 if (*end != 'x') { 19 if (*end != 'x') {
20 return cmd_results_new(CMD_INVALID, "output", 20 return cmd_results_new(CMD_INVALID, "Invalid mode width.");
21 "Invalid mode width.");
22 } 21 }
23 ++end; 22 ++end;
24 output->height = strtol(end, &end, 10); 23 output->height = strtol(end, &end, 10);
25 if (*end) { 24 if (*end) {
26 if (*end != '@') { 25 if (*end != '@') {
27 return cmd_results_new(CMD_INVALID, "output", 26 return cmd_results_new(CMD_INVALID, "Invalid mode height.");
28 "Invalid mode height.");
29 } 27 }
30 ++end; 28 ++end;
31 output->refresh_rate = strtof(end, &end); 29 output->refresh_rate = strtof(end, &end);
32 if (strcasecmp("Hz", end) != 0) { 30 if (strcasecmp("Hz", end) != 0) {
33 return cmd_results_new(CMD_INVALID, "output", 31 return cmd_results_new(CMD_INVALID,
34 "Invalid mode refresh rate."); 32 "Invalid mode refresh rate.");
35 } 33 }
36 } 34 }
@@ -38,13 +36,12 @@ struct cmd_results *output_cmd_mode(int argc, char **argv) {
38 // Format is 1234 4321 36 // Format is 1234 4321
39 argc--; argv++; 37 argc--; argv++;
40 if (!argc) { 38 if (!argc) {
41 return cmd_results_new(CMD_INVALID, "output", 39 return cmd_results_new(CMD_INVALID,
42 "Missing mode argument (height)."); 40 "Missing mode argument (height).");
43 } 41 }
44 output->height = strtol(*argv, &end, 10); 42 output->height = strtol(*argv, &end, 10);
45 if (*end) { 43 if (*end) {
46 return cmd_results_new(CMD_INVALID, "output", 44 return cmd_results_new(CMD_INVALID, "Invalid mode height.");
47 "Invalid mode height.");
48 } 45 }
49 } 46 }
50 47
diff --git a/sway/commands/output/position.c b/sway/commands/output/position.c
index 449767b1..689462cb 100644
--- a/sway/commands/output/position.c
+++ b/sway/commands/output/position.c
@@ -4,11 +4,10 @@
4 4
5struct cmd_results *output_cmd_position(int argc, char **argv) { 5struct cmd_results *output_cmd_position(int argc, char **argv) {
6 if (!config->handler_context.output_config) { 6 if (!config->handler_context.output_config) {
7 return cmd_results_new(CMD_FAILURE, "output", "Missing output config"); 7 return cmd_results_new(CMD_FAILURE, "Missing output config");
8 } 8 }
9 if (!argc) { 9 if (!argc) {
10 return cmd_results_new(CMD_INVALID, "output", 10 return cmd_results_new(CMD_INVALID, "Missing position argument.");
11 "Missing position argument.");
12 } 11 }
13 12
14 char *end; 13 char *end;
@@ -16,26 +15,22 @@ struct cmd_results *output_cmd_position(int argc, char **argv) {
16 if (*end) { 15 if (*end) {
17 // Format is 1234,4321 16 // Format is 1234,4321
18 if (*end != ',') { 17 if (*end != ',') {
19 return cmd_results_new(CMD_INVALID, "output", 18 return cmd_results_new(CMD_INVALID, "Invalid position x.");
20 "Invalid position x.");
21 } 19 }
22 ++end; 20 ++end;
23 config->handler_context.output_config->y = strtol(end, &end, 10); 21 config->handler_context.output_config->y = strtol(end, &end, 10);
24 if (*end) { 22 if (*end) {
25 return cmd_results_new(CMD_INVALID, "output", 23 return cmd_results_new(CMD_INVALID, "Invalid position y.");
26 "Invalid position y.");
27 } 24 }
28 } else { 25 } else {
29 // Format is 1234 4321 (legacy) 26 // Format is 1234 4321 (legacy)
30 argc--; argv++; 27 argc--; argv++;
31 if (!argc) { 28 if (!argc) {
32 return cmd_results_new(CMD_INVALID, "output", 29 return cmd_results_new(CMD_INVALID, "Missing position argument (y).");
33 "Missing position argument (y).");
34 } 30 }
35 config->handler_context.output_config->y = strtol(*argv, &end, 10); 31 config->handler_context.output_config->y = strtol(*argv, &end, 10);
36 if (*end) { 32 if (*end) {
37 return cmd_results_new(CMD_INVALID, "output", 33 return cmd_results_new(CMD_INVALID, "Invalid position y.");
38 "Invalid position y.");
39 } 34 }
40 } 35 }
41 36
diff --git a/sway/commands/output/scale.c b/sway/commands/output/scale.c
index 0b4cc131..9398e06a 100644
--- a/sway/commands/output/scale.c
+++ b/sway/commands/output/scale.c
@@ -4,17 +4,16 @@
4 4
5struct cmd_results *output_cmd_scale(int argc, char **argv) { 5struct cmd_results *output_cmd_scale(int argc, char **argv) {
6 if (!config->handler_context.output_config) { 6 if (!config->handler_context.output_config) {
7 return cmd_results_new(CMD_FAILURE, "output", "Missing output config"); 7 return cmd_results_new(CMD_FAILURE, "Missing output config");
8 } 8 }
9 if (!argc) { 9 if (!argc) {
10 return cmd_results_new(CMD_INVALID, "output", 10 return cmd_results_new(CMD_INVALID, "Missing scale argument.");
11 "Missing scale argument.");
12 } 11 }
13 12
14 char *end; 13 char *end;
15 config->handler_context.output_config->scale = strtof(*argv, &end); 14 config->handler_context.output_config->scale = strtof(*argv, &end);
16 if (*end) { 15 if (*end) {
17 return cmd_results_new(CMD_INVALID, "output", "Invalid scale."); 16 return cmd_results_new(CMD_INVALID, "Invalid scale.");
18 } 17 }
19 18
20 config->handler_context.leftovers.argc = argc - 1; 19 config->handler_context.leftovers.argc = argc - 1;
diff --git a/sway/commands/output/transform.c b/sway/commands/output/transform.c
index ca6f73a4..8613a8e7 100644
--- a/sway/commands/output/transform.c
+++ b/sway/commands/output/transform.c
@@ -6,11 +6,10 @@
6 6
7struct cmd_results *output_cmd_transform(int argc, char **argv) { 7struct cmd_results *output_cmd_transform(int argc, char **argv) {
8 if (!config->handler_context.output_config) { 8 if (!config->handler_context.output_config) {
9 return cmd_results_new(CMD_FAILURE, "output", "Missing output config"); 9 return cmd_results_new(CMD_FAILURE, "Missing output config");
10 } 10 }
11 if (!argc) { 11 if (!argc) {
12 return cmd_results_new(CMD_INVALID, "output", 12 return cmd_results_new(CMD_INVALID, "Missing transform argument.");
13 "Missing transform argument.");
14 } 13 }
15 enum wl_output_transform transform; 14 enum wl_output_transform transform;
16 if (strcmp(*argv, "normal") == 0) { 15 if (strcmp(*argv, "normal") == 0) {
@@ -30,8 +29,7 @@ struct cmd_results *output_cmd_transform(int argc, char **argv) {
30 } else if (strcmp(*argv, "flipped-270") == 0) { 29 } else if (strcmp(*argv, "flipped-270") == 0) {
31 transform = WL_OUTPUT_TRANSFORM_FLIPPED_270; 30 transform = WL_OUTPUT_TRANSFORM_FLIPPED_270;
32 } else { 31 } else {
33 return cmd_results_new(CMD_INVALID, "output", 32 return cmd_results_new(CMD_INVALID, "Invalid output transform.");
34 "Invalid output transform.");
35 } 33 }
36 struct output_config *output = config->handler_context.output_config; 34 struct output_config *output = config->handler_context.output_config;
37 config->handler_context.leftovers.argc = argc - 1; 35 config->handler_context.leftovers.argc = argc - 1;
@@ -42,12 +40,12 @@ struct cmd_results *output_cmd_transform(int argc, char **argv) {
42 return NULL; 40 return NULL;
43 } 41 }
44 if (strcmp(output->name, "*") == 0) { 42 if (strcmp(output->name, "*") == 0) {
45 return cmd_results_new(CMD_INVALID, "output", 43 return cmd_results_new(CMD_INVALID,
46 "Cannot apply relative transform to all outputs."); 44 "Cannot apply relative transform to all outputs.");
47 } 45 }
48 struct sway_output *s_output = output_by_name_or_id(output->name); 46 struct sway_output *s_output = output_by_name_or_id(output->name);
49 if (s_output == NULL) { 47 if (s_output == NULL) {
50 return cmd_results_new(CMD_INVALID, "output", 48 return cmd_results_new(CMD_INVALID,
51 "Cannot apply relative transform to unknown output %s", output->name); 49 "Cannot apply relative transform to unknown output %s", output->name);
52 } 50 }
53 if (strcmp(argv[1], "anticlockwise") == 0) { 51 if (strcmp(argv[1], "anticlockwise") == 0) {