diff options
author | M Stoeckl <code@mstoeckl.com> | 2019-01-10 18:27:21 -0500 |
---|---|---|
committer | M Stoeckl <code@mstoeckl.com> | 2019-01-14 08:05:29 -0500 |
commit | 2a684cad5fc8e12a8e47a7fd00e2b7c66b43afb0 (patch) | |
tree | 56332b9c150459beb5aef94605372ef179ec8854 /sway/commands/output | |
parent | 6d392150a72ecc3b69fcfb48865f625e2c7b79d6 (diff) |
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.c | 17 | ||||
-rw-r--r-- | sway/commands/output/disable.c | 2 | ||||
-rw-r--r-- | sway/commands/output/dpms.c | 4 | ||||
-rw-r--r-- | sway/commands/output/enable.c | 2 | ||||
-rw-r--r-- | sway/commands/output/mode.c | 17 | ||||
-rw-r--r-- | sway/commands/output/position.c | 17 | ||||
-rw-r--r-- | sway/commands/output/scale.c | 7 | ||||
-rw-r--r-- | sway/commands/output/transform.c | 12 |
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[] = { struct cmd_results *output_cmd_background(int argc, char **argv) { if (!config->handler_context.output_config) { - return cmd_results_new(CMD_FAILURE, "output", "Missing output config"); + return cmd_results_new(CMD_FAILURE, "Missing output config"); } if (!argc) { - return cmd_results_new(CMD_INVALID, "output", + return cmd_results_new(CMD_INVALID, "Missing background file or color specification."); } if (argc < 2) { - return cmd_results_new(CMD_INVALID, "output", + return cmd_results_new(CMD_INVALID, "Missing background scaling mode or `solid_color`."); } @@ -57,7 +57,7 @@ struct cmd_results *output_cmd_background(int argc, char **argv) { } } if (!valid) { - return cmd_results_new(CMD_INVALID, "output", + return cmd_results_new(CMD_INVALID, "Missing background scaling mode."); } @@ -70,7 +70,7 @@ struct cmd_results *output_cmd_background(int argc, char **argv) { *ptr = '\\'; } if (wordexp(src, &p, 0) != 0 || p.we_wordv[0] == NULL) { - struct cmd_results *cmd_res = cmd_results_new(CMD_INVALID, "output", + struct cmd_results *cmd_res = cmd_results_new(CMD_INVALID, "Invalid syntax (%s)", src); free(src); wordfree(&p); @@ -81,8 +81,7 @@ struct cmd_results *output_cmd_background(int argc, char **argv) { wordfree(&p); if (!src) { wlr_log(WLR_ERROR, "Failed to duplicate string"); - return cmd_results_new(CMD_FAILURE, "output", - "Unable to allocate resource"); + return cmd_results_new(CMD_FAILURE, "Unable to allocate resource"); } if (config->reading && *src != '/') { @@ -92,7 +91,7 @@ struct cmd_results *output_cmd_background(int argc, char **argv) { if (!conf) { wlr_log(WLR_ERROR, "Failed to duplicate string"); free(src); - return cmd_results_new(CMD_FAILURE, "output", + return cmd_results_new(CMD_FAILURE, "Unable to allocate resources"); } @@ -103,7 +102,7 @@ struct cmd_results *output_cmd_background(int argc, char **argv) { free(rel_path); free(conf); wlr_log(WLR_ERROR, "Unable to allocate memory"); - return cmd_results_new(CMD_FAILURE, "output", + return cmd_results_new(CMD_FAILURE, "Unable to allocate resources"); } 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 @@ struct cmd_results *output_cmd_disable(int argc, char **argv) { if (!config->handler_context.output_config) { - return cmd_results_new(CMD_FAILURE, "output", "Missing output config"); + return cmd_results_new(CMD_FAILURE, "Missing output config"); } config->handler_context.output_config->enabled = 0; 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 @@ struct cmd_results *output_cmd_dpms(int argc, char **argv) { if (!config->handler_context.output_config) { - return cmd_results_new(CMD_FAILURE, "output", "Missing output config"); + return cmd_results_new(CMD_FAILURE, "Missing output config"); } if (!argc) { - return cmd_results_new(CMD_INVALID, "output", "Missing dpms argument."); + return cmd_results_new(CMD_INVALID, "Missing dpms argument."); } 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 @@ struct cmd_results *output_cmd_enable(int argc, char **argv) { if (!config->handler_context.output_config) { - return cmd_results_new(CMD_FAILURE, "output", "Missing output config"); + return cmd_results_new(CMD_FAILURE, "Missing output config"); } config->handler_context.output_config->enabled = 1; 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 @@ struct cmd_results *output_cmd_mode(int argc, char **argv) { if (!config->handler_context.output_config) { - return cmd_results_new(CMD_FAILURE, "output", "Missing output config"); + return cmd_results_new(CMD_FAILURE, "Missing output config"); } if (!argc) { - return cmd_results_new(CMD_INVALID, "output", "Missing mode argument."); + return cmd_results_new(CMD_INVALID, "Missing mode argument."); } struct output_config *output = config->handler_context.output_config; @@ -17,20 +17,18 @@ struct cmd_results *output_cmd_mode(int argc, char **argv) { if (*end) { // Format is 1234x4321 if (*end != 'x') { - return cmd_results_new(CMD_INVALID, "output", - "Invalid mode width."); + return cmd_results_new(CMD_INVALID, "Invalid mode width."); } ++end; output->height = strtol(end, &end, 10); if (*end) { if (*end != '@') { - return cmd_results_new(CMD_INVALID, "output", - "Invalid mode height."); + return cmd_results_new(CMD_INVALID, "Invalid mode height."); } ++end; output->refresh_rate = strtof(end, &end); if (strcasecmp("Hz", end) != 0) { - return cmd_results_new(CMD_INVALID, "output", + return cmd_results_new(CMD_INVALID, "Invalid mode refresh rate."); } } @@ -38,13 +36,12 @@ struct cmd_results *output_cmd_mode(int argc, char **argv) { // Format is 1234 4321 argc--; argv++; if (!argc) { - return cmd_results_new(CMD_INVALID, "output", + return cmd_results_new(CMD_INVALID, "Missing mode argument (height)."); } output->height = strtol(*argv, &end, 10); if (*end) { - return cmd_results_new(CMD_INVALID, "output", - "Invalid mode height."); + return cmd_results_new(CMD_INVALID, "Invalid mode height."); } } 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 @@ struct cmd_results *output_cmd_position(int argc, char **argv) { if (!config->handler_context.output_config) { - return cmd_results_new(CMD_FAILURE, "output", "Missing output config"); + return cmd_results_new(CMD_FAILURE, "Missing output config"); } if (!argc) { - return cmd_results_new(CMD_INVALID, "output", - "Missing position argument."); + return cmd_results_new(CMD_INVALID, "Missing position argument."); } char *end; @@ -16,26 +15,22 @@ struct cmd_results *output_cmd_position(int argc, char **argv) { if (*end) { // Format is 1234,4321 if (*end != ',') { - return cmd_results_new(CMD_INVALID, "output", - "Invalid position x."); + return cmd_results_new(CMD_INVALID, "Invalid position x."); } ++end; config->handler_context.output_config->y = strtol(end, &end, 10); if (*end) { - return cmd_results_new(CMD_INVALID, "output", - "Invalid position y."); + return cmd_results_new(CMD_INVALID, "Invalid position y."); } } else { // Format is 1234 4321 (legacy) argc--; argv++; if (!argc) { - return cmd_results_new(CMD_INVALID, "output", - "Missing position argument (y)."); + return cmd_results_new(CMD_INVALID, "Missing position argument (y)."); } config->handler_context.output_config->y = strtol(*argv, &end, 10); if (*end) { - return cmd_results_new(CMD_INVALID, "output", - "Invalid position y."); + return cmd_results_new(CMD_INVALID, "Invalid position y."); } } 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 @@ struct cmd_results *output_cmd_scale(int argc, char **argv) { if (!config->handler_context.output_config) { - return cmd_results_new(CMD_FAILURE, "output", "Missing output config"); + return cmd_results_new(CMD_FAILURE, "Missing output config"); } if (!argc) { - return cmd_results_new(CMD_INVALID, "output", - "Missing scale argument."); + return cmd_results_new(CMD_INVALID, "Missing scale argument."); } char *end; config->handler_context.output_config->scale = strtof(*argv, &end); if (*end) { - return cmd_results_new(CMD_INVALID, "output", "Invalid scale."); + return cmd_results_new(CMD_INVALID, "Invalid scale."); } 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 @@ struct cmd_results *output_cmd_transform(int argc, char **argv) { if (!config->handler_context.output_config) { - return cmd_results_new(CMD_FAILURE, "output", "Missing output config"); + return cmd_results_new(CMD_FAILURE, "Missing output config"); } if (!argc) { - return cmd_results_new(CMD_INVALID, "output", - "Missing transform argument."); + return cmd_results_new(CMD_INVALID, "Missing transform argument."); } enum wl_output_transform transform; if (strcmp(*argv, "normal") == 0) { @@ -30,8 +29,7 @@ struct cmd_results *output_cmd_transform(int argc, char **argv) { } else if (strcmp(*argv, "flipped-270") == 0) { transform = WL_OUTPUT_TRANSFORM_FLIPPED_270; } else { - return cmd_results_new(CMD_INVALID, "output", - "Invalid output transform."); + return cmd_results_new(CMD_INVALID, "Invalid output transform."); } struct output_config *output = config->handler_context.output_config; config->handler_context.leftovers.argc = argc - 1; @@ -42,12 +40,12 @@ struct cmd_results *output_cmd_transform(int argc, char **argv) { return NULL; } if (strcmp(output->name, "*") == 0) { - return cmd_results_new(CMD_INVALID, "output", + return cmd_results_new(CMD_INVALID, "Cannot apply relative transform to all outputs."); } struct sway_output *s_output = output_by_name_or_id(output->name); if (s_output == NULL) { - return cmd_results_new(CMD_INVALID, "output", + return cmd_results_new(CMD_INVALID, "Cannot apply relative transform to unknown output %s", output->name); } if (strcmp(argv[1], "anticlockwise") == 0) { |