aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
authorM Stoeckl <code@mstoeckl.com>2019-01-22 10:07:38 -0500
committerM Stoeckl <code@mstoeckl.com>2019-01-22 10:12:04 -0500
commit0af5b26e41c5141d4094652133c230d76bf82e56 (patch)
tree75c61907f094838e23899231ec5ec955c530f692 /sway
parent71a37ad186ba3080338b2ecb5a3e640600aefc1f (diff)
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.c1
-rw-r--r--sway/commands/resize.c11
-rw-r--r--sway/desktop/layer_shell.c2
-rw-r--r--sway/desktop/xdg_shell.c3
-rw-r--r--sway/desktop/xdg_shell_v6.c3
-rw-r--r--sway/desktop/xwayland.c3
-rw-r--r--sway/tree/root.c9
-rw-r--r--sway/tree/view.c4
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,
if (can_move) {
if (desired < 0 || desired >= siblings->length) {
- can_move = false;
int len = siblings->length;
if (config->focus_wrapping != WRAP_NO && !wrap_candidate
&& 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) {
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;
}
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(
void handle_layer_shell_surface(struct wl_listener *listener, void *data) {
struct wlr_layer_surface_v1 *layer_surface = data;
- struct sway_server *server =
- wl_container_of(listener, server, layer_shell_surface);
sway_log(SWAY_DEBUG, "new layer surface: namespace %s layer %d anchor %d "
"size %dx%d margin %d,%d,%d,%d",
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 @@
#include "sway/input/input-manager.h"
#include "sway/input/seat.h"
#include "sway/output.h"
-#include "sway/server.h"
#include "sway/tree/arrange.h"
#include "sway/tree/container.h"
#include "sway/tree/view.h"
@@ -480,8 +479,6 @@ struct sway_view *view_from_wlr_xdg_surface(
}
void handle_xdg_shell_surface(struct wl_listener *listener, void *data) {
- struct sway_server *server = wl_container_of(listener, server,
- xdg_shell_surface);
struct wlr_xdg_surface *xdg_surface = data;
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 @@
#include "sway/input/input-manager.h"
#include "sway/input/seat.h"
#include "sway/output.h"
-#include "sway/server.h"
#include "sway/tree/arrange.h"
#include "sway/tree/container.h"
#include "sway/tree/view.h"
@@ -464,8 +463,6 @@ struct sway_view *view_from_wlr_xdg_surface_v6(
}
void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
- struct sway_server *server = wl_container_of(listener, server,
- xdg_shell_v6_surface);
struct wlr_xdg_surface_v6 *xdg_surface = data;
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 @@
#include "sway/input/input-manager.h"
#include "sway/input/seat.h"
#include "sway/output.h"
-#include "sway/server.h"
#include "sway/tree/arrange.h"
#include "sway/tree/container.h"
#include "sway/tree/view.h"
@@ -573,8 +572,6 @@ struct sway_view *view_from_wlr_xwayland_surface(
}
void handle_xwayland_surface(struct wl_listener *listener, void *data) {
- struct sway_server *server = wl_container_of(listener, server,
- xwayland_surface);
struct wlr_xwayland_surface *xsurface = data;
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) {
pid_t parent = -1;
char file_name[100];
char *buffer = NULL;
- char *token = NULL;
const char *sep = " ";
FILE *stat = NULL;
size_t buf_size = 0;
@@ -178,10 +177,10 @@ static pid_t get_parent_pid(pid_t child) {
if ((stat = fopen(file_name, "r"))) {
if (getline(&buffer, &buf_size, stat) != -1) {
- token = strtok(buffer, sep); // pid
- token = strtok(NULL, sep); // executable name
- token = strtok(NULL, sep); // state
- token = strtok(NULL, sep); // parent pid
+ strtok(buffer, sep); // pid
+ strtok(NULL, sep); // executable name
+ strtok(NULL, sep); // state
+ char *token = strtok(NULL, sep); // parent pid
parent = strtol(token, NULL, 10);
}
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) {
con->border_bottom = bottom_y != ws->y + ws->height;
}
- double x, y, width, height;
- x = y = width = height = 0;
double y_offset = 0;
// 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) {
con->border_top = false;
}
+ double x, y, width, height;
switch (con->border) {
+ default:
case B_CSD:
case B_NONE:
x = con->x;