diff options
author | Drew DeVault <sir@cmpwn.com> | 2015-08-19 19:30:26 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2015-08-19 19:30:26 -0400 |
commit | 057d2e529d5cb22722b68aad759bdf0a48af6f20 (patch) | |
tree | 82ab38635b0207d99b53d8a2168865681d1babbd | |
parent | Fix error with workspace/output name matching (diff) | |
parent | Fix potential memory leak (diff) | |
download | sway-057d2e529d5cb22722b68aad759bdf0a48af6f20.tar.gz sway-057d2e529d5cb22722b68aad759bdf0a48af6f20.tar.zst sway-057d2e529d5cb22722b68aad759bdf0a48af6f20.zip |
Merge pull request #92 from z33ky/master
A couple of cppcheck issues
-rw-r--r-- | sway/handlers.c | 2 | ||||
-rw-r--r-- | sway/log.c | 4 | ||||
-rw-r--r-- | sway/readline.c | 12 |
3 files changed, 11 insertions, 7 deletions
diff --git a/sway/handlers.c b/sway/handlers.c index a6dbf94c..0bb181cc 100644 --- a/sway/handlers.c +++ b/sway/handlers.c | |||
@@ -290,8 +290,8 @@ static void handle_view_state_request(wlc_handle view, enum wlc_view_state_bit s | |||
290 | // i3 just lets it become fullscreen | 290 | // i3 just lets it become fullscreen |
291 | wlc_view_set_state(view, state, toggle); | 291 | wlc_view_set_state(view, state, toggle); |
292 | c = get_swayc_for_handle(view, &root_container); | 292 | c = get_swayc_for_handle(view, &root_container); |
293 | sway_log(L_DEBUG, "setting view %ld %s, fullscreen %d", view, c->name, toggle); | ||
294 | if (c) { | 293 | if (c) { |
294 | sway_log(L_DEBUG, "setting view %ld %s, fullscreen %d", view, c->name, toggle); | ||
295 | arrange_windows(c->parent, -1, -1); | 295 | arrange_windows(c->parent, -1, -1); |
296 | // Set it as focused window for that workspace if its going fullscreen | 296 | // Set it as focused window for that workspace if its going fullscreen |
297 | if (toggle) { | 297 | if (toggle) { |
@@ -19,10 +19,10 @@ static const char *verbosity_colors[] = { | |||
19 | void init_log(int verbosity) { | 19 | void init_log(int verbosity) { |
20 | v = verbosity; | 20 | v = verbosity; |
21 | /* set FD_CLOEXEC flag to prevent programs called with exec to write into logs */ | 21 | /* set FD_CLOEXEC flag to prevent programs called with exec to write into logs */ |
22 | int i, flag; | 22 | int i; |
23 | int fd[] = { STDOUT_FILENO, STDIN_FILENO, STDERR_FILENO }; | 23 | int fd[] = { STDOUT_FILENO, STDIN_FILENO, STDERR_FILENO }; |
24 | for (i = 0; i < 3; ++i) { | 24 | for (i = 0; i < 3; ++i) { |
25 | flag = fcntl(fd[i], F_GETFD); | 25 | int flag = fcntl(fd[i], F_GETFD); |
26 | if (flag != -1) { | 26 | if (flag != -1) { |
27 | fcntl(fd[i], F_SETFD, flag | FD_CLOEXEC); | 27 | fcntl(fd[i], F_SETFD, flag | FD_CLOEXEC); |
28 | } | 28 | } |
diff --git a/sway/readline.c b/sway/readline.c index dfdc3fe8..e75b183f 100644 --- a/sway/readline.c +++ b/sway/readline.c | |||
@@ -17,18 +17,22 @@ char *read_line(FILE *file) { | |||
17 | continue; | 17 | continue; |
18 | } | 18 | } |
19 | if (length == size) { | 19 | if (length == size) { |
20 | string = realloc(string, size *= 2); | 20 | char *new_string = realloc(string, size *= 2); |
21 | if (!string) { | 21 | if (!new_string) { |
22 | free(string); | ||
22 | return NULL; | 23 | return NULL; |
23 | } | 24 | } |
25 | string = new_string; | ||
24 | } | 26 | } |
25 | string[length++] = c; | 27 | string[length++] = c; |
26 | } | 28 | } |
27 | if (length + 1 == size) { | 29 | if (length + 1 == size) { |
28 | string = realloc(string, length + 1); | 30 | char *new_string = realloc(string, length + 1); |
29 | if (!string) { | 31 | if (!new_string) { |
32 | free(string); | ||
30 | return NULL; | 33 | return NULL; |
31 | } | 34 | } |
35 | string = new_string; | ||
32 | } | 36 | } |
33 | string[length] = '\0'; | 37 | string[length] = '\0'; |
34 | return string; | 38 | return string; |