aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/resize.c
diff options
context:
space:
mode:
authorLibravatar M Stoeckl <code@mstoeckl.com>2019-01-22 10:07:38 -0500
committerLibravatar M Stoeckl <code@mstoeckl.com>2019-01-22 10:12:04 -0500
commit0af5b26e41c5141d4094652133c230d76bf82e56 (patch)
tree75c61907f094838e23899231ec5ec955c530f692 /sway/commands/resize.c
parentMerge pull request #3494 from ianyfan/commands (diff)
downloadsway-0af5b26e41c5141d4094652133c230d76bf82e56.tar.gz
sway-0af5b26e41c5141d4094652133c230d76bf82e56.tar.zst
sway-0af5b26e41c5141d4094652133c230d76bf82e56.zip
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.
Diffstat (limited to 'sway/commands/resize.c')
-rw-r--r--sway/commands/resize.c11
1 files changed, 7 insertions, 4 deletions
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) {
478 argc--; argv++; 478 argc--; argv++;
479 } 479 }
480 int num_consumed_args = parse_resize_amount(argc, argv, &height); 480 int num_consumed_args = parse_resize_amount(argc, argv, &height);
481 argc -= num_consumed_args; 481 if (argc > num_consumed_args) {
482 argv += num_consumed_args; 482 return cmd_results_new(CMD_INVALID, usage);
483 }
483 if (width.unit == RESIZE_UNIT_INVALID) { 484 if (width.unit == RESIZE_UNIT_INVALID) {
484 return cmd_results_new(CMD_INVALID, usage); 485 return cmd_results_new(CMD_INVALID, usage);
485 } 486 }
@@ -543,12 +544,14 @@ static struct cmd_results *cmd_resize_adjust(int argc, char **argv,
543 struct resize_amount second_amount; 544 struct resize_amount second_amount;
544 if (argc) { 545 if (argc) {
545 int num_consumed_args = parse_resize_amount(argc, argv, &second_amount); 546 int num_consumed_args = parse_resize_amount(argc, argv, &second_amount);
546 argc -= num_consumed_args; 547 if (argc > num_consumed_args) {
547 argv += num_consumed_args; 548 return cmd_results_new(CMD_INVALID, usage);
549 }
548 if (second_amount.unit == RESIZE_UNIT_INVALID) { 550 if (second_amount.unit == RESIZE_UNIT_INVALID) {
549 return cmd_results_new(CMD_INVALID, usage); 551 return cmd_results_new(CMD_INVALID, usage);
550 } 552 }
551 } else { 553 } else {
554 second_amount.amount = 0;
552 second_amount.unit = RESIZE_UNIT_INVALID; 555 second_amount.unit = RESIZE_UNIT_INVALID;
553 } 556 }
554 557