commands: add printf attribute to cmd_results_new()

And fix the resulting build failures.
This commit is contained in:
Simon Ser 2023-02-28 16:24:03 +01:00
parent d6915f6428
commit a7b50f6c9c
19 changed files with 63 additions and 58 deletions

View file

@ -3,6 +3,7 @@
#include <wlr/util/edges.h> #include <wlr/util/edges.h>
#include "config.h" #include "config.h"
#include "stringop.h"
struct sway_container; struct sway_container;
@ -76,7 +77,7 @@ struct cmd_results *config_commands_command(char *exec);
/** /**
* Allocates a cmd_results object. * Allocates a cmd_results object.
*/ */
struct cmd_results *cmd_results_new(enum cmd_status status, const char *error, ...); struct cmd_results *cmd_results_new(enum cmd_status status, const char *error, ...) _SWAY_ATTRIB_PRINTF(2, 3);
/** /**
* Frees a cmd_results object. * Frees a cmd_results object.
*/ */

View file

@ -381,10 +381,13 @@ struct cmd_results *config_command(char *exec, char **new_block) {
sway_log(SWAY_INFO, "Config command: %s", exec); sway_log(SWAY_INFO, "Config command: %s", exec);
const struct cmd_handler *handler = find_core_handler(argv[0]); const struct cmd_handler *handler = find_core_handler(argv[0]);
if (!handler || !handler->handle) { if (!handler || !handler->handle) {
const char *error = handler if (handler) {
? "Command '%s' is shimmed, but unimplemented" results = cmd_results_new(CMD_INVALID,
: "Unknown/invalid command '%s'"; "Command '%s' is shimmed, but unimplemented", argv[0]);
results = cmd_results_new(CMD_INVALID, error, argv[0]); } else {
results = cmd_results_new(CMD_INVALID,
"Unknown/invalid command '%s'", argv[0]);
}
goto cleanup; goto cleanup;
} }

View file

@ -17,7 +17,7 @@ struct cmd_results *cmd_assign(int argc, char **argv) {
char *err_str = NULL; char *err_str = NULL;
struct criteria *criteria = criteria_parse(argv[0], &err_str); struct criteria *criteria = criteria_parse(argv[0], &err_str);
if (!criteria) { if (!criteria) {
error = cmd_results_new(CMD_INVALID, err_str); error = cmd_results_new(CMD_INVALID, "%s", err_str);
free(err_str); free(err_str);
return error; return error;
} }

View file

@ -96,7 +96,7 @@ static struct cmd_results *bar_cmd_bind(int argc, char **argv, bool code,
} }
if (message) { if (message) {
free_bar_binding(binding); free_bar_binding(binding);
error = cmd_results_new(CMD_INVALID, message); error = cmd_results_new(CMD_INVALID, "%s", message);
free(message); free(message);
return error; return error;
} else if (!binding->button) { } else if (!binding->button) {

View file

@ -26,7 +26,7 @@ static struct cmd_results *tray_bind(int argc, char **argv, bool code) {
} }
if (message) { if (message) {
free(binding); free(binding);
error = cmd_results_new(CMD_INVALID, message); error = cmd_results_new(CMD_INVALID, "%s", message);
free(message); free(message);
return error; return error;
} else if (!binding->button) { } else if (!binding->button) {

View file

@ -127,7 +127,7 @@ static struct cmd_results *identify_key(const char* name, bool first_key,
if (!button) { if (!button) {
if (message) { if (message) {
struct cmd_results *error = struct cmd_results *error =
cmd_results_new(CMD_INVALID, message); cmd_results_new(CMD_INVALID, "%s", message);
free(message); free(message);
return error; return error;
} else { } else {
@ -143,7 +143,7 @@ static struct cmd_results *identify_key(const char* name, bool first_key,
if (!button) { if (!button) {
if (message) { if (message) {
struct cmd_results *error = struct cmd_results *error =
cmd_results_new(CMD_INVALID, message); cmd_results_new(CMD_INVALID, "%s", message);
free(message); free(message);
return error; return error;
} else { } else {
@ -182,7 +182,7 @@ static struct cmd_results *identify_key(const char* name, bool first_key,
uint32_t button = get_mouse_bindsym(name, &message); uint32_t button = get_mouse_bindsym(name, &message);
if (message) { if (message) {
struct cmd_results *error = struct cmd_results *error =
cmd_results_new(CMD_INVALID, message); cmd_results_new(CMD_INVALID, "%s", message);
free(message); free(message);
return error; return error;
} else if (button) { } else if (button) {
@ -539,7 +539,7 @@ struct cmd_results *cmd_bind_or_unbind_switch(int argc, char **argv,
free_switch_binding(binding); free_switch_binding(binding);
return cmd_results_new(CMD_FAILURE, return cmd_results_new(CMD_FAILURE,
"Invalid %s command (expected binding with the form " "Invalid %s command (expected binding with the form "
"<switch>:<state>)", bindtype, argc); "<switch>:<state>)", bindtype);
} }
if (strcmp(split->items[0], "tablet") == 0) { if (strcmp(split->items[0], "tablet") == 0) {
binding->type = WLR_SWITCH_TYPE_TABLET_MODE; binding->type = WLR_SWITCH_TYPE_TABLET_MODE;
@ -549,7 +549,8 @@ struct cmd_results *cmd_bind_or_unbind_switch(int argc, char **argv,
free_switch_binding(binding); free_switch_binding(binding);
return cmd_results_new(CMD_FAILURE, return cmd_results_new(CMD_FAILURE,
"Invalid %s command (expected switch binding: " "Invalid %s command (expected switch binding: "
"unknown switch %s)", bindtype, split->items[0]); "unknown switch %s)", bindtype,
(const char *)split->items[0]);
} }
if (strcmp(split->items[1], "on") == 0) { if (strcmp(split->items[1], "on") == 0) {
binding->trigger = SWAY_SWITCH_TRIGGER_ON; binding->trigger = SWAY_SWITCH_TRIGGER_ON;
@ -562,7 +563,7 @@ struct cmd_results *cmd_bind_or_unbind_switch(int argc, char **argv,
return cmd_results_new(CMD_FAILURE, return cmd_results_new(CMD_FAILURE,
"Invalid %s command " "Invalid %s command "
"(expected switch state: unknown state %s)", "(expected switch state: unknown state %s)",
bindtype, split->items[1]); bindtype, (const char *)split->items[1]);
} }
list_free_items_and_destroy(split); list_free_items_and_destroy(split);

View file

@ -23,16 +23,16 @@ static struct cmd_results *handle_command(int argc, char **argv, char *cmd_name,
char *err; char *err;
int width = (int)strtol(argv[0], &err, 10); int width = (int)strtol(argv[0], &err, 10);
if (*err) { if (*err) {
return cmd_results_new(CMD_INVALID, usage); return cmd_results_new(CMD_INVALID, "%s", usage);
} }
if (strcmp(argv[1], "x") != 0) { if (strcmp(argv[1], "x") != 0) {
return cmd_results_new(CMD_INVALID, usage); return cmd_results_new(CMD_INVALID, "%s", usage);
} }
int height = (int)strtol(argv[2], &err, 10); int height = (int)strtol(argv[2], &err, 10);
if (*err) { if (*err) {
return cmd_results_new(CMD_INVALID, usage); return cmd_results_new(CMD_INVALID, "%s", usage);
} }
*config_width = width; *config_width = width;

View file

@ -14,7 +14,7 @@ struct cmd_results *cmd_for_window(int argc, char **argv) {
char *err_str = NULL; char *err_str = NULL;
struct criteria *criteria = criteria_parse(argv[0], &err_str); struct criteria *criteria = criteria_parse(argv[0], &err_str);
if (!criteria) { if (!criteria) {
error = cmd_results_new(CMD_INVALID, err_str); error = cmd_results_new(CMD_INVALID, "%s", err_str);
free(err_str); free(err_str);
return error; return error;
} }

View file

@ -20,7 +20,7 @@ struct cmd_results *cmd_hide_edge_borders(int argc, char **argv) {
} }
if (!argc) { if (!argc) {
return cmd_results_new(CMD_INVALID, expected_syntax); return cmd_results_new(CMD_INVALID, "%s", expected_syntax);
} }
if (strcmp(argv[0], "none") == 0) { if (strcmp(argv[0], "none") == 0) {
@ -38,7 +38,7 @@ struct cmd_results *cmd_hide_edge_borders(int argc, char **argv) {
config->hide_edge_borders = E_NONE; config->hide_edge_borders = E_NONE;
config->hide_edge_borders_smart = ESMART_NO_GAPS; config->hide_edge_borders_smart = ESMART_NO_GAPS;
} else { } else {
return cmd_results_new(CMD_INVALID, expected_syntax); return cmd_results_new(CMD_INVALID, "%s", expected_syntax);
} }
config->hide_lone_tab = hide_lone_tab; config->hide_lone_tab = hide_lone_tab;

View file

@ -49,5 +49,5 @@ struct cmd_results *input_cmd_map_to_region(int argc, char **argv) {
error: error:
free(ic->mapped_to_region); free(ic->mapped_to_region);
ic->mapped_to_region = NULL; ic->mapped_to_region = NULL;
return cmd_results_new(CMD_FAILURE, errstr); return cmd_results_new(CMD_FAILURE, "%s", errstr);
} }

View file

@ -21,7 +21,7 @@ struct cmd_results *input_cmd_scroll_button(int argc, char **argv) {
char *message = NULL; char *message = NULL;
uint32_t button = get_mouse_button(*argv, &message); uint32_t button = get_mouse_button(*argv, &message);
if (message) { if (message) {
error = cmd_results_new(CMD_INVALID, message); error = cmd_results_new(CMD_INVALID, "%s", message);
free(message); free(message);
return error; return error;
} else if (button == SWAY_SCROLL_UP || button == SWAY_SCROLL_DOWN } else if (button == SWAY_SCROLL_UP || button == SWAY_SCROLL_DOWN

View file

@ -153,7 +153,7 @@ struct cmd_results *cmd_layout(int argc, char **argv) {
workspace->output); workspace->output);
} }
if (new_layout == L_NONE) { if (new_layout == L_NONE) {
return cmd_results_new(CMD_INVALID, expected_syntax); return cmd_results_new(CMD_INVALID, "%s", expected_syntax);
} }
if (new_layout != old_layout) { if (new_layout != old_layout) {
if (container) { if (container) {

View file

@ -470,7 +470,7 @@ static struct cmd_results *cmd_move_container(bool no_auto_back_and_forth,
if (strcasecmp(argv[1], "number") == 0) { if (strcasecmp(argv[1], "number") == 0) {
// move [window|container] [to] "workspace number x" // move [window|container] [to] "workspace number x"
if (argc < 3) { if (argc < 3) {
return cmd_results_new(CMD_INVALID, expected_syntax); return cmd_results_new(CMD_INVALID, "%s", expected_syntax);
} }
if (!isdigit(argv[2][0])) { if (!isdigit(argv[2][0])) {
return cmd_results_new(CMD_INVALID, return cmd_results_new(CMD_INVALID,
@ -530,7 +530,7 @@ static struct cmd_results *cmd_move_container(bool no_auto_back_and_forth,
} }
destination = &dest_con->node; destination = &dest_con->node;
} else { } else {
return cmd_results_new(CMD_INVALID, expected_syntax); return cmd_results_new(CMD_INVALID, "%s", expected_syntax);
} }
if (destination->type == N_CONTAINER && if (destination->type == N_CONTAINER &&
@ -829,7 +829,7 @@ static struct cmd_results *cmd_move_to_position(int argc, char **argv) {
} }
if (!argc) { if (!argc) {
return cmd_results_new(CMD_INVALID, expected_position_syntax); return cmd_results_new(CMD_INVALID, "%s", expected_position_syntax);
} }
bool absolute = false; bool absolute = false;
@ -839,19 +839,19 @@ static struct cmd_results *cmd_move_to_position(int argc, char **argv) {
++argv; ++argv;
} }
if (!argc) { if (!argc) {
return cmd_results_new(CMD_INVALID, expected_position_syntax); return cmd_results_new(CMD_INVALID, "%s", expected_position_syntax);
} }
if (strcmp(argv[0], "position") == 0) { if (strcmp(argv[0], "position") == 0) {
--argc; --argc;
++argv; ++argv;
} }
if (!argc) { if (!argc) {
return cmd_results_new(CMD_INVALID, expected_position_syntax); return cmd_results_new(CMD_INVALID, "%s", expected_position_syntax);
} }
if (strcmp(argv[0], "cursor") == 0 || strcmp(argv[0], "mouse") == 0 || if (strcmp(argv[0], "cursor") == 0 || strcmp(argv[0], "mouse") == 0 ||
strcmp(argv[0], "pointer") == 0) { strcmp(argv[0], "pointer") == 0) {
if (absolute) { if (absolute) {
return cmd_results_new(CMD_INVALID, expected_position_syntax); return cmd_results_new(CMD_INVALID, "%s", expected_position_syntax);
} }
return cmd_move_to_position_pointer(container); return cmd_move_to_position_pointer(container);
} else if (strcmp(argv[0], "center") == 0) { } else if (strcmp(argv[0], "center") == 0) {
@ -873,7 +873,7 @@ static struct cmd_results *cmd_move_to_position(int argc, char **argv) {
} }
if (argc < 2) { if (argc < 2) {
return cmd_results_new(CMD_FAILURE, expected_position_syntax); return cmd_results_new(CMD_FAILURE, "%s", expected_position_syntax);
} }
struct movement_amount lx = { .amount = 0, .unit = MOVEMENT_UNIT_INVALID }; struct movement_amount lx = { .amount = 0, .unit = MOVEMENT_UNIT_INVALID };
@ -886,7 +886,7 @@ static struct cmd_results *cmd_move_to_position(int argc, char **argv) {
} }
if (argc < 1) { if (argc < 1) {
return cmd_results_new(CMD_FAILURE, expected_position_syntax); return cmd_results_new(CMD_FAILURE, "%s", expected_position_syntax);
} }
struct movement_amount ly = { .amount = 0, .unit = MOVEMENT_UNIT_INVALID }; struct movement_amount ly = { .amount = 0, .unit = MOVEMENT_UNIT_INVALID };
@ -895,7 +895,7 @@ static struct cmd_results *cmd_move_to_position(int argc, char **argv) {
argc -= num_consumed_args; argc -= num_consumed_args;
argv += num_consumed_args; argv += num_consumed_args;
if (argc > 0) { if (argc > 0) {
return cmd_results_new(CMD_INVALID, expected_position_syntax); return cmd_results_new(CMD_INVALID, "%s", expected_position_syntax);
} }
if (ly.unit == MOVEMENT_UNIT_INVALID) { if (ly.unit == MOVEMENT_UNIT_INVALID) {
return cmd_results_new(CMD_INVALID, "Invalid y position specified"); return cmd_results_new(CMD_INVALID, "Invalid y position specified");
@ -1041,13 +1041,13 @@ struct cmd_results *cmd_move(int argc, char **argv) {
} }
if (!argc) { if (!argc) {
return cmd_results_new(CMD_INVALID, expected_full_syntax); return cmd_results_new(CMD_INVALID, "%s", expected_full_syntax);
} }
// Only `move [window|container] [to] workspace` supports // Only `move [window|container] [to] workspace` supports
// `--no-auto-back-and-forth` so treat others as invalid syntax // `--no-auto-back-and-forth` so treat others as invalid syntax
if (no_auto_back_and_forth && strcasecmp(argv[0], "workspace") != 0) { if (no_auto_back_and_forth && strcasecmp(argv[0], "workspace") != 0) {
return cmd_results_new(CMD_INVALID, expected_full_syntax); return cmd_results_new(CMD_INVALID, "%s", expected_full_syntax);
} }
if (strcasecmp(argv[0], "workspace") == 0 || if (strcasecmp(argv[0], "workspace") == 0 ||
@ -1061,5 +1061,5 @@ struct cmd_results *cmd_move(int argc, char **argv) {
strcasecmp(argv[1], "position") == 0)) { strcasecmp(argv[1], "position") == 0)) {
return cmd_move_to_position(argc, argv); return cmd_move_to_position(argc, argv);
} }
return cmd_results_new(CMD_INVALID, expected_full_syntax); return cmd_results_new(CMD_INVALID, "%s", expected_full_syntax);
} }

View file

@ -13,7 +13,7 @@ struct cmd_results *cmd_no_focus(int argc, char **argv) {
char *err_str = NULL; char *err_str = NULL;
struct criteria *criteria = criteria_parse(argv[0], &err_str); struct criteria *criteria = criteria_parse(argv[0], &err_str);
if (!criteria) { if (!criteria) {
error = cmd_results_new(CMD_INVALID, err_str); error = cmd_results_new(CMD_INVALID, "%s", err_str);
free(err_str); free(err_str);
return error; return error;
} }

View file

@ -26,7 +26,7 @@ struct cmd_results *cmd_rename(int argc, char **argv) {
"Can't run this command while there's no outputs connected."); "Can't run this command while there's no outputs connected.");
} }
if (strcasecmp(argv[0], "workspace") != 0) { if (strcasecmp(argv[0], "workspace") != 0) {
return cmd_results_new(CMD_INVALID, expected_syntax); return cmd_results_new(CMD_INVALID, "%s", expected_syntax);
} }
int argn = 1; int argn = 1;
@ -65,7 +65,7 @@ struct cmd_results *cmd_rename(int argc, char **argv) {
++argn; // move past "to" ++argn; // move past "to"
if (argn >= argc) { if (argn >= argc) {
return cmd_results_new(CMD_INVALID, expected_syntax); return cmd_results_new(CMD_INVALID, "%s", expected_syntax);
} }
char *new_name = join_args(argv + argn, argc - argn); char *new_name = join_args(argv + argn, argc - argn);

View file

@ -415,7 +415,7 @@ static struct cmd_results *cmd_resize_set(int argc, char **argv) {
argc -= num_consumed_args; argc -= num_consumed_args;
argv += num_consumed_args; argv += num_consumed_args;
if (width.unit == MOVEMENT_UNIT_INVALID) { if (width.unit == MOVEMENT_UNIT_INVALID) {
return cmd_results_new(CMD_INVALID, usage); return cmd_results_new(CMD_INVALID, "%s", usage);
} }
} }
@ -427,10 +427,10 @@ static struct cmd_results *cmd_resize_set(int argc, char **argv) {
} }
int num_consumed_args = parse_movement_amount(argc, argv, &height); int num_consumed_args = parse_movement_amount(argc, argv, &height);
if (argc > num_consumed_args) { if (argc > num_consumed_args) {
return cmd_results_new(CMD_INVALID, usage); return cmd_results_new(CMD_INVALID, "%s", usage);
} }
if (width.unit == MOVEMENT_UNIT_INVALID) { if (width.unit == MOVEMENT_UNIT_INVALID) {
return cmd_results_new(CMD_INVALID, usage); return cmd_results_new(CMD_INVALID, "%s", usage);
} }
} }
@ -462,7 +462,7 @@ static struct cmd_results *cmd_resize_adjust(int argc, char **argv,
"[<amount> px|ppt [or <amount> px|ppt]]'"; "[<amount> px|ppt [or <amount> px|ppt]]'";
uint32_t axis = parse_resize_axis(*argv); uint32_t axis = parse_resize_axis(*argv);
if (axis == WLR_EDGE_NONE) { if (axis == WLR_EDGE_NONE) {
return cmd_results_new(CMD_INVALID, usage); return cmd_results_new(CMD_INVALID, "%s", usage);
} }
--argc; ++argv; --argc; ++argv;
@ -473,7 +473,7 @@ static struct cmd_results *cmd_resize_adjust(int argc, char **argv,
argc -= num_consumed_args; argc -= num_consumed_args;
argv += num_consumed_args; argv += num_consumed_args;
if (first_amount.unit == MOVEMENT_UNIT_INVALID) { if (first_amount.unit == MOVEMENT_UNIT_INVALID) {
return cmd_results_new(CMD_INVALID, usage); return cmd_results_new(CMD_INVALID, "%s", usage);
} }
} else { } else {
first_amount.amount = 10; first_amount.amount = 10;
@ -483,7 +483,7 @@ static struct cmd_results *cmd_resize_adjust(int argc, char **argv,
// "or" // "or"
if (argc) { if (argc) {
if (strcmp(*argv, "or") != 0) { if (strcmp(*argv, "or") != 0) {
return cmd_results_new(CMD_INVALID, usage); return cmd_results_new(CMD_INVALID, "%s", usage);
} }
--argc; ++argv; --argc; ++argv;
} }
@ -493,10 +493,10 @@ static struct cmd_results *cmd_resize_adjust(int argc, char **argv,
if (argc) { if (argc) {
int num_consumed_args = parse_movement_amount(argc, argv, &second_amount); int num_consumed_args = parse_movement_amount(argc, argv, &second_amount);
if (argc > num_consumed_args) { if (argc > num_consumed_args) {
return cmd_results_new(CMD_INVALID, usage); return cmd_results_new(CMD_INVALID, "%s", usage);
} }
if (second_amount.unit == MOVEMENT_UNIT_INVALID) { if (second_amount.unit == MOVEMENT_UNIT_INVALID) {
return cmd_results_new(CMD_INVALID, usage); return cmd_results_new(CMD_INVALID, "%s", usage);
} }
} else { } else {
second_amount.amount = 0; second_amount.amount = 0;
@ -566,5 +566,5 @@ struct cmd_results *cmd_resize(int argc, char **argv) {
const char usage[] = "Expected 'resize <shrink|grow> " const char usage[] = "Expected 'resize <shrink|grow> "
"<width|height|up|down|left|right> [<amount>] [px|ppt]'"; "<width|height|up|down|left|right> [<amount>] [px|ppt]'";
return cmd_results_new(CMD_INVALID, usage); return cmd_results_new(CMD_INVALID, "%s", usage);
} }

View file

@ -18,7 +18,7 @@ static struct cmd_results *handle_command(struct sway_cursor *cursor,
int argc, char **argv) { int argc, char **argv) {
if (strcasecmp(argv[0], "move") == 0) { if (strcasecmp(argv[0], "move") == 0) {
if (argc < 3) { if (argc < 3) {
return cmd_results_new(CMD_INVALID, expected_syntax); return cmd_results_new(CMD_INVALID, "%s", expected_syntax);
} }
int delta_x = strtol(argv[1], NULL, 10); int delta_x = strtol(argv[1], NULL, 10);
int delta_y = strtol(argv[2], NULL, 10); int delta_y = strtol(argv[2], NULL, 10);
@ -27,7 +27,7 @@ static struct cmd_results *handle_command(struct sway_cursor *cursor,
wlr_seat_pointer_notify_frame(cursor->seat->wlr_seat); wlr_seat_pointer_notify_frame(cursor->seat->wlr_seat);
} else if (strcasecmp(argv[0], "set") == 0) { } else if (strcasecmp(argv[0], "set") == 0) {
if (argc < 3) { if (argc < 3) {
return cmd_results_new(CMD_INVALID, expected_syntax); return cmd_results_new(CMD_INVALID, "%s", expected_syntax);
} }
// map absolute coords (0..1,0..1) to root container coords // map absolute coords (0..1,0..1) to root container coords
float x = strtof(argv[1], NULL) / root->width; float x = strtof(argv[1], NULL) / root->width;
@ -37,7 +37,7 @@ static struct cmd_results *handle_command(struct sway_cursor *cursor,
wlr_seat_pointer_notify_frame(cursor->seat->wlr_seat); wlr_seat_pointer_notify_frame(cursor->seat->wlr_seat);
} else { } else {
if (argc < 2) { if (argc < 2) {
return cmd_results_new(CMD_INVALID, expected_syntax); return cmd_results_new(CMD_INVALID, "%s", expected_syntax);
} }
struct cmd_results *error = NULL; struct cmd_results *error = NULL;
if ((error = press_or_release(cursor, argv[0], argv[1]))) { if ((error = press_or_release(cursor, argv[0], argv[1]))) {
@ -92,14 +92,14 @@ static struct cmd_results *press_or_release(struct sway_cursor *cursor,
} else if (strcasecmp(action, "release") == 0) { } else if (strcasecmp(action, "release") == 0) {
state = WLR_BUTTON_RELEASED; state = WLR_BUTTON_RELEASED;
} else { } else {
return cmd_results_new(CMD_INVALID, expected_syntax); return cmd_results_new(CMD_INVALID, "%s", expected_syntax);
} }
char *message = NULL; char *message = NULL;
button = get_mouse_button(button_str, &message); button = get_mouse_button(button_str, &message);
if (message) { if (message) {
struct cmd_results *error = struct cmd_results *error =
cmd_results_new(CMD_INVALID, message); cmd_results_new(CMD_INVALID, "%s", message);
free(message); free(message);
return error; return error;
} else if (button == SWAY_SCROLL_UP || button == SWAY_SCROLL_DOWN } else if (button == SWAY_SCROLL_UP || button == SWAY_SCROLL_DOWN

View file

@ -46,7 +46,7 @@ struct cmd_results *cmd_swap(int argc, char **argv) {
} }
if (strcasecmp(argv[0], "container") || strcasecmp(argv[1], "with")) { if (strcasecmp(argv[0], "container") || strcasecmp(argv[1], "with")) {
return cmd_results_new(CMD_INVALID, expected_syntax); return cmd_results_new(CMD_INVALID, "%s", expected_syntax);
} }
struct sway_container *current = config->handler_context.container; struct sway_container *current = config->handler_context.container;
@ -65,7 +65,7 @@ struct cmd_results *cmd_swap(int argc, char **argv) {
other = root_find_container(test_mark, value); other = root_find_container(test_mark, value);
} else { } else {
free(value); free(value);
return cmd_results_new(CMD_INVALID, expected_syntax); return cmd_results_new(CMD_INVALID, "%s", expected_syntax);
} }
if (!other) { if (!other) {

View file

@ -61,7 +61,7 @@ static struct cmd_results *cmd_workspace_gaps(int argc, char **argv,
const char expected[] = "Expected 'workspace <name> gaps " const char expected[] = "Expected 'workspace <name> gaps "
"inner|outer|horizontal|vertical|top|right|bottom|left <px>'"; "inner|outer|horizontal|vertical|top|right|bottom|left <px>'";
if (gaps_location == 0) { if (gaps_location == 0) {
return cmd_results_new(CMD_INVALID, expected); return cmd_results_new(CMD_INVALID, "%s", expected);
} }
struct cmd_results *error = NULL; struct cmd_results *error = NULL;
if ((error = checkarg(argc, "workspace", EXPECTED_EQUAL_TO, if ((error = checkarg(argc, "workspace", EXPECTED_EQUAL_TO,
@ -79,7 +79,7 @@ static struct cmd_results *cmd_workspace_gaps(int argc, char **argv,
char *end; char *end;
int amount = strtol(argv[gaps_location + 2], &end, 10); int amount = strtol(argv[gaps_location + 2], &end, 10);
if (strlen(end)) { if (strlen(end)) {
return cmd_results_new(CMD_FAILURE, expected); return cmd_results_new(CMD_FAILURE, "%s", expected);
} }
bool valid = false; bool valid = false;
@ -110,7 +110,7 @@ static struct cmd_results *cmd_workspace_gaps(int argc, char **argv,
} }
} }
if (!valid) { if (!valid) {
return cmd_results_new(CMD_INVALID, expected); return cmd_results_new(CMD_INVALID, "%s", expected);
} }
// Prevent invalid gaps configurations. // Prevent invalid gaps configurations.
@ -174,7 +174,7 @@ struct cmd_results *cmd_workspace(int argc, char **argv) {
} }
if (root->fullscreen_global) { if (root->fullscreen_global) {
return cmd_results_new(CMD_FAILURE, "workspace", return cmd_results_new(CMD_FAILURE,
"Can't switch workspaces while fullscreen global"); "Can't switch workspaces while fullscreen global");
} }