diff options
author | M Stoeckl <code@mstoeckl.com> | 2019-01-22 10:07:38 -0500 |
---|---|---|
committer | M Stoeckl <code@mstoeckl.com> | 2019-01-22 10:12:04 -0500 |
commit | 0af5b26e41c5141d4094652133c230d76bf82e56 (patch) | |
tree | 75c61907f094838e23899231ec5ec955c530f692 /sway | |
parent | Merge pull request #3494 from ianyfan/commands (diff) | |
download | sway-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')
-rw-r--r-- | sway/commands/focus.c | 1 | ||||
-rw-r--r-- | sway/commands/resize.c | 11 | ||||
-rw-r--r-- | sway/desktop/layer_shell.c | 2 | ||||
-rw-r--r-- | sway/desktop/xdg_shell.c | 3 | ||||
-rw-r--r-- | sway/desktop/xdg_shell_v6.c | 3 | ||||
-rw-r--r-- | sway/desktop/xwayland.c | 3 | ||||
-rw-r--r-- | sway/tree/root.c | 9 | ||||
-rw-r--r-- | sway/tree/view.c | 4 |
8 files changed, 13 insertions, 23 deletions
diff --git a/sway/commands/focus.c b/sway/commands/focus.c index e7680062..0622f2e8 100644 --- a/sway/commands/focus.c +++ b/sway/commands/focus.c | |||
@@ -123,7 +123,6 @@ static struct sway_node *node_get_in_direction(struct sway_container *container, | |||
123 | 123 | ||
124 | if (can_move) { | 124 | if (can_move) { |
125 | if (desired < 0 || desired >= siblings->length) { | 125 | if (desired < 0 || desired >= siblings->length) { |
126 | can_move = false; | ||
127 | int len = siblings->length; | 126 | int len = siblings->length; |
128 | if (config->focus_wrapping != WRAP_NO && !wrap_candidate | 127 | if (config->focus_wrapping != WRAP_NO && !wrap_candidate |
129 | && len > 1) { | 128 | && len > 1) { |
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 | ||
diff --git a/sway/desktop/layer_shell.c b/sway/desktop/layer_shell.c index a870bb9a..de8db75d 100644 --- a/sway/desktop/layer_shell.c +++ b/sway/desktop/layer_shell.c | |||
@@ -354,8 +354,6 @@ struct sway_layer_surface *layer_from_wlr_layer_surface_v1( | |||
354 | 354 | ||
355 | void handle_layer_shell_surface(struct wl_listener *listener, void *data) { | 355 | void handle_layer_shell_surface(struct wl_listener *listener, void *data) { |
356 | struct wlr_layer_surface_v1 *layer_surface = data; | 356 | struct wlr_layer_surface_v1 *layer_surface = data; |
357 | struct sway_server *server = | ||
358 | wl_container_of(listener, server, layer_shell_surface); | ||
359 | sway_log(SWAY_DEBUG, "new layer surface: namespace %s layer %d anchor %d " | 357 | sway_log(SWAY_DEBUG, "new layer surface: namespace %s layer %d anchor %d " |
360 | "size %dx%d margin %d,%d,%d,%d", | 358 | "size %dx%d margin %d,%d,%d,%d", |
361 | layer_surface->namespace, layer_surface->layer, layer_surface->layer, | 359 | layer_surface->namespace, layer_surface->layer, layer_surface->layer, |
diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index b4ac3a68..e2c614b3 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #include "sway/input/input-manager.h" | 13 | #include "sway/input/input-manager.h" |
14 | #include "sway/input/seat.h" | 14 | #include "sway/input/seat.h" |
15 | #include "sway/output.h" | 15 | #include "sway/output.h" |
16 | #include "sway/server.h" | ||
17 | #include "sway/tree/arrange.h" | 16 | #include "sway/tree/arrange.h" |
18 | #include "sway/tree/container.h" | 17 | #include "sway/tree/container.h" |
19 | #include "sway/tree/view.h" | 18 | #include "sway/tree/view.h" |
@@ -480,8 +479,6 @@ struct sway_view *view_from_wlr_xdg_surface( | |||
480 | } | 479 | } |
481 | 480 | ||
482 | void handle_xdg_shell_surface(struct wl_listener *listener, void *data) { | 481 | void handle_xdg_shell_surface(struct wl_listener *listener, void *data) { |
483 | struct sway_server *server = wl_container_of(listener, server, | ||
484 | xdg_shell_surface); | ||
485 | struct wlr_xdg_surface *xdg_surface = data; | 482 | struct wlr_xdg_surface *xdg_surface = data; |
486 | 483 | ||
487 | if (xdg_surface->role == WLR_XDG_SURFACE_ROLE_POPUP) { | 484 | if (xdg_surface->role == WLR_XDG_SURFACE_ROLE_POPUP) { |
diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index 553d532d..f11c00b1 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c | |||
@@ -12,7 +12,6 @@ | |||
12 | #include "sway/input/input-manager.h" | 12 | #include "sway/input/input-manager.h" |
13 | #include "sway/input/seat.h" | 13 | #include "sway/input/seat.h" |
14 | #include "sway/output.h" | 14 | #include "sway/output.h" |
15 | #include "sway/server.h" | ||
16 | #include "sway/tree/arrange.h" | 15 | #include "sway/tree/arrange.h" |
17 | #include "sway/tree/container.h" | 16 | #include "sway/tree/container.h" |
18 | #include "sway/tree/view.h" | 17 | #include "sway/tree/view.h" |
@@ -464,8 +463,6 @@ struct sway_view *view_from_wlr_xdg_surface_v6( | |||
464 | } | 463 | } |
465 | 464 | ||
466 | void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) { | 465 | void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) { |
467 | struct sway_server *server = wl_container_of(listener, server, | ||
468 | xdg_shell_v6_surface); | ||
469 | struct wlr_xdg_surface_v6 *xdg_surface = data; | 466 | struct wlr_xdg_surface_v6 *xdg_surface = data; |
470 | 467 | ||
471 | if (xdg_surface->role == WLR_XDG_SURFACE_V6_ROLE_POPUP) { | 468 | if (xdg_surface->role == WLR_XDG_SURFACE_V6_ROLE_POPUP) { |
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 8dcf4bd6..4ea661f8 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c | |||
@@ -12,7 +12,6 @@ | |||
12 | #include "sway/input/input-manager.h" | 12 | #include "sway/input/input-manager.h" |
13 | #include "sway/input/seat.h" | 13 | #include "sway/input/seat.h" |
14 | #include "sway/output.h" | 14 | #include "sway/output.h" |
15 | #include "sway/server.h" | ||
16 | #include "sway/tree/arrange.h" | 15 | #include "sway/tree/arrange.h" |
17 | #include "sway/tree/container.h" | 16 | #include "sway/tree/container.h" |
18 | #include "sway/tree/view.h" | 17 | #include "sway/tree/view.h" |
@@ -573,8 +572,6 @@ struct sway_view *view_from_wlr_xwayland_surface( | |||
573 | } | 572 | } |
574 | 573 | ||
575 | void handle_xwayland_surface(struct wl_listener *listener, void *data) { | 574 | void handle_xwayland_surface(struct wl_listener *listener, void *data) { |
576 | struct sway_server *server = wl_container_of(listener, server, | ||
577 | xwayland_surface); | ||
578 | struct wlr_xwayland_surface *xsurface = data; | 575 | struct wlr_xwayland_surface *xsurface = data; |
579 | 576 | ||
580 | if (xsurface->override_redirect) { | 577 | if (xsurface->override_redirect) { |
diff --git a/sway/tree/root.c b/sway/tree/root.c index c4d1145d..99cf91a7 100644 --- a/sway/tree/root.c +++ b/sway/tree/root.c | |||
@@ -169,7 +169,6 @@ static pid_t get_parent_pid(pid_t child) { | |||
169 | pid_t parent = -1; | 169 | pid_t parent = -1; |
170 | char file_name[100]; | 170 | char file_name[100]; |
171 | char *buffer = NULL; | 171 | char *buffer = NULL; |
172 | char *token = NULL; | ||
173 | const char *sep = " "; | 172 | const char *sep = " "; |
174 | FILE *stat = NULL; | 173 | FILE *stat = NULL; |
175 | size_t buf_size = 0; | 174 | size_t buf_size = 0; |
@@ -178,10 +177,10 @@ static pid_t get_parent_pid(pid_t child) { | |||
178 | 177 | ||
179 | if ((stat = fopen(file_name, "r"))) { | 178 | if ((stat = fopen(file_name, "r"))) { |
180 | if (getline(&buffer, &buf_size, stat) != -1) { | 179 | if (getline(&buffer, &buf_size, stat) != -1) { |
181 | token = strtok(buffer, sep); // pid | 180 | strtok(buffer, sep); // pid |
182 | token = strtok(NULL, sep); // executable name | 181 | strtok(NULL, sep); // executable name |
183 | token = strtok(NULL, sep); // state | 182 | strtok(NULL, sep); // state |
184 | token = strtok(NULL, sep); // parent pid | 183 | char *token = strtok(NULL, sep); // parent pid |
185 | parent = strtol(token, NULL, 10); | 184 | parent = strtol(token, NULL, 10); |
186 | } | 185 | } |
187 | free(buffer); | 186 | free(buffer); |
diff --git a/sway/tree/view.c b/sway/tree/view.c index edbfca97..8795e04f 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c | |||
@@ -236,8 +236,6 @@ void view_autoconfigure(struct sway_view *view) { | |||
236 | con->border_bottom = bottom_y != ws->y + ws->height; | 236 | con->border_bottom = bottom_y != ws->y + ws->height; |
237 | } | 237 | } |
238 | 238 | ||
239 | double x, y, width, height; | ||
240 | x = y = width = height = 0; | ||
241 | double y_offset = 0; | 239 | double y_offset = 0; |
242 | 240 | ||
243 | // In a tabbed or stacked container, the container's y is the top of the | 241 | // In a tabbed or stacked container, the container's y is the top of the |
@@ -253,7 +251,9 @@ void view_autoconfigure(struct sway_view *view) { | |||
253 | con->border_top = false; | 251 | con->border_top = false; |
254 | } | 252 | } |
255 | 253 | ||
254 | double x, y, width, height; | ||
256 | switch (con->border) { | 255 | switch (con->border) { |
256 | default: | ||
257 | case B_CSD: | 257 | case B_CSD: |
258 | case B_NONE: | 258 | case B_NONE: |
259 | x = con->x; | 259 | x = con->x; |