From 2a684cad5fc8e12a8e47a7fd00e2b7c66b43afb0 Mon Sep 17 00:00:00 2001 From: M Stoeckl Date: Thu, 10 Jan 2019 18:27:21 -0500 Subject: 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. --- sway/commands/swap.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'sway/commands/swap.c') diff --git a/sway/commands/swap.c b/sway/commands/swap.c index 670d6bca..a8beb162 100644 --- a/sway/commands/swap.c +++ b/sway/commands/swap.c @@ -11,7 +11,7 @@ #include "sway/tree/workspace.h" #include "stringop.h" -static const char* EXPECTED_SYNTAX = +static const char expected_syntax[] = "Expected 'swap container with id|con_id|mark '"; static void swap_places(struct sway_container *con1, @@ -171,12 +171,12 @@ struct cmd_results *cmd_swap(int argc, char **argv) { return error; } if (!root->outputs->length) { - return cmd_results_new(CMD_INVALID, "swap", + return cmd_results_new(CMD_INVALID, "Can't run this command while there's no outputs connected."); } if (strcasecmp(argv[0], "container") || strcasecmp(argv[1], "with")) { - return cmd_results_new(CMD_INVALID, "swap", EXPECTED_SYNTAX); + return cmd_results_new(CMD_INVALID, expected_syntax); } struct sway_container *current = config->handler_context.container; @@ -195,21 +195,21 @@ struct cmd_results *cmd_swap(int argc, char **argv) { other = root_find_container(test_mark, value); } else { free(value); - return cmd_results_new(CMD_INVALID, "swap", EXPECTED_SYNTAX); + return cmd_results_new(CMD_INVALID, expected_syntax); } if (!other) { - error = cmd_results_new(CMD_FAILURE, "swap", + error = cmd_results_new(CMD_FAILURE, "Failed to find %s '%s'", argv[2], value); } else if (!current) { - error = cmd_results_new(CMD_FAILURE, "swap", + error = cmd_results_new(CMD_FAILURE, "Can only swap with containers and views"); } else if (container_has_ancestor(current, other) || container_has_ancestor(other, current)) { - error = cmd_results_new(CMD_FAILURE, "swap", + error = cmd_results_new(CMD_FAILURE, "Cannot swap ancestor and descendant"); } else if (container_is_floating(current) || container_is_floating(other)) { - error = cmd_results_new(CMD_FAILURE, "swap", + error = cmd_results_new(CMD_FAILURE, "Swapping with floating containers is not supported"); } @@ -226,5 +226,5 @@ struct cmd_results *cmd_swap(int argc, char **argv) { arrange_node(node_get_parent(&other->node)); } - return cmd_results_new(CMD_SUCCESS, NULL, NULL); + return cmd_results_new(CMD_SUCCESS, NULL); } -- cgit v1.2.3