diff options
author | emersion <contact@emersion.fr> | 2018-04-15 07:42:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-15 07:42:38 +0200 |
commit | 3ea2a9a85e7db6e9858ccf68a67b312cd6db36c5 (patch) | |
tree | 9d81001776f4e095de76a63d540ab1ab0ca45caf | |
parent | Merge pull request #1815 from ascent12/posix_source (diff) | |
parent | Merge branch 'master' into gcc_warnings (diff) | |
download | sway-3ea2a9a85e7db6e9858ccf68a67b312cd6db36c5.tar.gz sway-3ea2a9a85e7db6e9858ccf68a67b312cd6db36c5.tar.zst sway-3ea2a9a85e7db6e9858ccf68a67b312cd6db36c5.zip |
Merge pull request #1811 from martinetd/gcc_warnings
Fix gcc warnings
-rw-r--r-- | common/ipc-client.c | 2 | ||||
-rw-r--r-- | sway/commands.c | 2 | ||||
-rw-r--r-- | sway/commands/exec_always.c | 2 | ||||
-rw-r--r-- | sway/ipc-server.c | 2 | ||||
-rw-r--r-- | sway/tree/layout.c | 7 |
5 files changed, 9 insertions, 6 deletions
diff --git a/common/ipc-client.c b/common/ipc-client.c index 117e9910..a88df080 100644 --- a/common/ipc-client.c +++ b/common/ipc-client.c | |||
@@ -48,7 +48,7 @@ int ipc_open_socket(const char *socket_path) { | |||
48 | sway_abort("Unable to open Unix socket"); | 48 | sway_abort("Unable to open Unix socket"); |
49 | } | 49 | } |
50 | addr.sun_family = AF_UNIX; | 50 | addr.sun_family = AF_UNIX; |
51 | strncpy(addr.sun_path, socket_path, sizeof(addr.sun_path)); | 51 | strncpy(addr.sun_path, socket_path, sizeof(addr.sun_path) - 1); |
52 | addr.sun_path[sizeof(addr.sun_path) - 1] = 0; | 52 | addr.sun_path[sizeof(addr.sun_path) - 1] = 0; |
53 | int l = sizeof(struct sockaddr_un); | 53 | int l = sizeof(struct sockaddr_un); |
54 | if (connect(socketfd, (struct sockaddr *)&addr, l) == -1) { | 54 | if (connect(socketfd, (struct sockaddr *)&addr, l) == -1) { |
diff --git a/sway/commands.c b/sway/commands.c index 54d84450..99f42524 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -601,7 +601,7 @@ struct cmd_results *add_color(const char *name, | |||
601 | "Invalid color definition %s", color); | 601 | "Invalid color definition %s", color); |
602 | } | 602 | } |
603 | } | 603 | } |
604 | strncpy(buffer, color, len); | 604 | strcpy(buffer, color); |
605 | // add default alpha channel if color was defined without it | 605 | // add default alpha channel if color was defined without it |
606 | if (len == 7) { | 606 | if (len == 7) { |
607 | buffer[7] = 'f'; | 607 | buffer[7] = 'f'; |
diff --git a/sway/commands/exec_always.c b/sway/commands/exec_always.c index 954950e7..af4e4965 100644 --- a/sway/commands/exec_always.c +++ b/sway/commands/exec_always.c | |||
@@ -32,7 +32,7 @@ struct cmd_results *cmd_exec_always(int argc, char **argv) { | |||
32 | 32 | ||
33 | // Put argument into cmd array | 33 | // Put argument into cmd array |
34 | char cmd[4096]; | 34 | char cmd[4096]; |
35 | strncpy(cmd, tmp, sizeof(cmd)); | 35 | strncpy(cmd, tmp, sizeof(cmd) - 1); |
36 | cmd[sizeof(cmd) - 1] = 0; | 36 | cmd[sizeof(cmd) - 1] = 0; |
37 | free(tmp); | 37 | free(tmp); |
38 | wlr_log(L_DEBUG, "Executing %s", cmd); | 38 | wlr_log(L_DEBUG, "Executing %s", cmd); |
diff --git a/sway/ipc-server.c b/sway/ipc-server.c index 045802e1..39d1d0a7 100644 --- a/sway/ipc-server.c +++ b/sway/ipc-server.c | |||
@@ -64,7 +64,7 @@ void ipc_init(struct sway_server *server) { | |||
64 | 64 | ||
65 | // We want to use socket name set by user, not existing socket from another sway instance. | 65 | // We want to use socket name set by user, not existing socket from another sway instance. |
66 | if (getenv("SWAYSOCK") != NULL && access(getenv("SWAYSOCK"), F_OK) == -1) { | 66 | if (getenv("SWAYSOCK") != NULL && access(getenv("SWAYSOCK"), F_OK) == -1) { |
67 | strncpy(ipc_sockaddr->sun_path, getenv("SWAYSOCK"), sizeof(ipc_sockaddr->sun_path)); | 67 | strncpy(ipc_sockaddr->sun_path, getenv("SWAYSOCK"), sizeof(ipc_sockaddr->sun_path) - 1); |
68 | ipc_sockaddr->sun_path[sizeof(ipc_sockaddr->sun_path) - 1] = 0; | 68 | ipc_sockaddr->sun_path[sizeof(ipc_sockaddr->sun_path) - 1] = 0; |
69 | } | 69 | } |
70 | 70 | ||
diff --git a/sway/tree/layout.c b/sway/tree/layout.c index ae76ca26..0b637822 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c | |||
@@ -288,8 +288,11 @@ void container_move(struct sway_container *container, | |||
288 | 288 | ||
289 | switch (current->type) { | 289 | switch (current->type) { |
290 | case C_OUTPUT: { | 290 | case C_OUTPUT: { |
291 | enum wlr_direction wlr_dir; | 291 | enum wlr_direction wlr_dir = 0; |
292 | sway_dir_to_wlr(move_dir, &wlr_dir); | 292 | if (!sway_assert(sway_dir_to_wlr(move_dir, &wlr_dir), |
293 | "got invalid direction: %d", move_dir)) { | ||
294 | return; | ||
295 | } | ||
293 | double ref_lx = current->x + current->width / 2; | 296 | double ref_lx = current->x + current->width / 2; |
294 | double ref_ly = current->y + current->height / 2; | 297 | double ref_ly = current->y + current->height / 2; |
295 | struct wlr_output *next = wlr_output_layout_adjacent_output( | 298 | struct wlr_output *next = wlr_output_layout_adjacent_output( |