Merge pull request #92 from z33ky/master

A couple of cppcheck issues
This commit is contained in:
Drew DeVault 2015-08-19 19:30:26 -04:00
commit 057d2e529d
3 changed files with 11 additions and 7 deletions

View file

@ -290,8 +290,8 @@ static void handle_view_state_request(wlc_handle view, enum wlc_view_state_bit s
// i3 just lets it become fullscreen // i3 just lets it become fullscreen
wlc_view_set_state(view, state, toggle); wlc_view_set_state(view, state, toggle);
c = get_swayc_for_handle(view, &root_container); c = get_swayc_for_handle(view, &root_container);
sway_log(L_DEBUG, "setting view %ld %s, fullscreen %d", view, c->name, toggle);
if (c) { if (c) {
sway_log(L_DEBUG, "setting view %ld %s, fullscreen %d", view, c->name, toggle);
arrange_windows(c->parent, -1, -1); arrange_windows(c->parent, -1, -1);
// Set it as focused window for that workspace if its going fullscreen // Set it as focused window for that workspace if its going fullscreen
if (toggle) { if (toggle) {

View file

@ -19,10 +19,10 @@ static const char *verbosity_colors[] = {
void init_log(int verbosity) { void init_log(int verbosity) {
v = verbosity; v = verbosity;
/* set FD_CLOEXEC flag to prevent programs called with exec to write into logs */ /* set FD_CLOEXEC flag to prevent programs called with exec to write into logs */
int i, flag; int i;
int fd[] = { STDOUT_FILENO, STDIN_FILENO, STDERR_FILENO }; int fd[] = { STDOUT_FILENO, STDIN_FILENO, STDERR_FILENO };
for (i = 0; i < 3; ++i) { for (i = 0; i < 3; ++i) {
flag = fcntl(fd[i], F_GETFD); int flag = fcntl(fd[i], F_GETFD);
if (flag != -1) { if (flag != -1) {
fcntl(fd[i], F_SETFD, flag | FD_CLOEXEC); fcntl(fd[i], F_SETFD, flag | FD_CLOEXEC);
} }

View file

@ -17,18 +17,22 @@ char *read_line(FILE *file) {
continue; continue;
} }
if (length == size) { if (length == size) {
string = realloc(string, size *= 2); char *new_string = realloc(string, size *= 2);
if (!string) { if (!new_string) {
free(string);
return NULL; return NULL;
} }
string = new_string;
} }
string[length++] = c; string[length++] = c;
} }
if (length + 1 == size) { if (length + 1 == size) {
string = realloc(string, length + 1); char *new_string = realloc(string, length + 1);
if (!string) { if (!new_string) {
free(string);
return NULL; return NULL;
} }
string = new_string;
} }
string[length] = '\0'; string[length] = '\0';
return string; return string;