diff --git a/cli/commands.c b/cli/commands.c index 8ea4199a7..c9d66dd04 100644 --- a/cli/commands.c +++ b/cli/commands.c @@ -201,7 +201,7 @@ static void cli_ntf_clb(struct nc_session *session, const struct nc_notif *notif) { FILE *output = nc_session_get_data(session); - int was_rawmode; + int was_rawmode = 0; if (output == stdout) { if (ls.rawmode) { @@ -504,7 +504,7 @@ static char * trim_top_elem(char *data, const char *top_elem, const char *top_elem_ns) { char *ptr, *prefix = NULL, *buf; - int pref_len, state = 0, quote; + int pref_len = 0, state = 0, quote; /* state: -2 - syntax error, * -1 - top_elem not found, diff --git a/cli/completion.c b/cli/completion.c index 46842e986..e1f14b084 100644 --- a/cli/completion.c +++ b/cli/completion.c @@ -8,7 +8,7 @@ * This source code is licensed under BSD 3-Clause License (the "License"). * You may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * https://opensource.org/licenses/BSD-3-Clause */ @@ -115,9 +115,11 @@ complete_cmd(const char *buf, const char *hint, linenoiseCompletions *lc) char * readinput(const char *instruction, const char *old_tmp, char **new_tmp) { - int tmpfd = -1, ret, size, oldfd; + volatile int tmpfd = -1; + int ret, size, oldfd; pid_t pid, wait_pid; - char* tmpname = NULL, *input = NULL, *old_content = NULL, *ptr, *ptr2; + char* volatile input = NULL, * volatile old_content = NULL; + char *tmpname = NULL, *ptr, *ptr2; /* Create a unique temporary file */ #ifdef HAVE_MKSTEMPS @@ -226,7 +228,7 @@ readinput(const char *instruction, const char *old_tmp, char **new_tmp) lseek(tmpfd, 0, SEEK_SET); /* Read the input */ - input = malloc(size+1); + input = malloc(size + 1); ret = read(tmpfd, input, size); if (ret < size) { ERROR(__func__, "Failed to read from the temporary file (%s).", strerror(errno)); @@ -244,7 +246,7 @@ readinput(const char *instruction, const char *old_tmp, char **new_tmp) /* The user could have deleted or modified the comment, ignore it then */ if (ptr2) { ptr2 += 5; - memmove(ptr, ptr2, strlen(ptr2)+1); + memmove(ptr, ptr2, strlen(ptr2) + 1); /* Save the modified content */ if (ftruncate(tmpfd, 0) == -1) { diff --git a/server/log.c b/server/log.c index 7ce431779..ccd1fc80b 100644 --- a/server/log.c +++ b/server/log.c @@ -149,7 +149,7 @@ void np2log_clb_nc2(NC_VERB_LEVEL level, const char *msg) { struct np2err *e; - int priority; + int priority = LOG_ERR; if (level == NC_VERB_ERROR) { e = np2_err_location();