From 0af5b26e41c5141d4094652133c230d76bf82e56 Mon Sep 17 00:00:00 2001 From: M Stoeckl Date: Tue, 22 Jan 2019 10:07:38 -0500 Subject: Fix dead stores found by scan-build In addition to removing unused code, two minor problems are fixed: (1) `resize set` and `resize adjust` did not error when given too many arguments. (2) `orientation` was incorrectly overridden to be 'U' for scroll events in the swaybar tray `handle_click` function. --- sway/commands/resize.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'sway/commands/resize.c') diff --git a/sway/commands/resize.c b/sway/commands/resize.c index 0e497239..204de539 100644 --- a/sway/commands/resize.c +++ b/sway/commands/resize.c @@ -478,8 +478,9 @@ static struct cmd_results *cmd_resize_set(int argc, char **argv) { argc--; argv++; } int num_consumed_args = parse_resize_amount(argc, argv, &height); - argc -= num_consumed_args; - argv += num_consumed_args; + if (argc > num_consumed_args) { + return cmd_results_new(CMD_INVALID, usage); + } if (width.unit == RESIZE_UNIT_INVALID) { return cmd_results_new(CMD_INVALID, usage); } @@ -543,12 +544,14 @@ static struct cmd_results *cmd_resize_adjust(int argc, char **argv, struct resize_amount second_amount; if (argc) { int num_consumed_args = parse_resize_amount(argc, argv, &second_amount); - argc -= num_consumed_args; - argv += num_consumed_args; + if (argc > num_consumed_args) { + return cmd_results_new(CMD_INVALID, usage); + } if (second_amount.unit == RESIZE_UNIT_INVALID) { return cmd_results_new(CMD_INVALID, usage); } } else { + second_amount.amount = 0; second_amount.unit = RESIZE_UNIT_INVALID; } -- cgit v1.2.3