diff options
author | James McCoy <jamessan@jamessan.com> | 2017-03-31 07:52:45 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-31 07:52:45 -0400 |
commit | 77539eef9baa0d070a1d07360dda2177c2ae41a7 (patch) | |
tree | c7e9e05dc4ba6e019e38610507440a75c8945fb5 | |
parent | 1097ba53f806c6f4f3e542af23332c556d38783f (diff) | |
parent | 338da727cdb19a15a0b001707e8778e10977e65c (diff) | |
download | rneovim-77539eef9baa0d070a1d07360dda2177c2ae41a7.tar.gz rneovim-77539eef9baa0d070a1d07360dda2177c2ae41a7.tar.bz2 rneovim-77539eef9baa0d070a1d07360dda2177c2ae41a7.zip |
Merge pull request #6397 from jamessan/coverity
Fix latest Coverity issues
-rw-r--r-- | src/coverity-model.c | 2 | ||||
-rw-r--r-- | src/nvim/eval.c | 5 | ||||
-rw-r--r-- | src/nvim/normal.c | 7 | ||||
-rw-r--r-- | src/nvim/option.c | 8 | ||||
-rw-r--r-- | src/nvim/os/env.c | 2 |
5 files changed, 15 insertions, 9 deletions
diff --git a/src/coverity-model.c b/src/coverity-model.c index a01ea6d316..3c38e4ae4d 100644 --- a/src/coverity-model.c +++ b/src/coverity-model.c @@ -64,7 +64,7 @@ void *je_realloc(void *ptr, size_t size) // of the memory allocated for item. typedef struct {} dictitem_T; typedef struct {} dict_T; -int dict_add(dict_T *d, dictitem_T *item) +int tv_dict_add(dict_T *const d, dictitem_T *const item) { __coverity_escape__(item); } diff --git a/src/nvim/eval.c b/src/nvim/eval.c index a83e93090a..15b712e7de 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -11008,18 +11008,19 @@ static void get_user_input(typval_T *argvars, typval_T *rettv, int inputdialog) cmdline_row = msg_row; const char *defstr = ""; + char buf[NUMBUFLEN]; if (argvars[1].v_type != VAR_UNKNOWN) { - char buf[NUMBUFLEN]; defstr = tv_get_string_buf_chk(&argvars[1], buf); if (defstr != NULL) { stuffReadbuffSpec(defstr); } if (!inputdialog && argvars[2].v_type != VAR_UNKNOWN) { + char buf2[NUMBUFLEN]; // input() with a third argument: completion rettv->vval.v_string = NULL; - const char *const xp_name = tv_get_string_buf_chk(&argvars[2], buf); + const char *const xp_name = tv_get_string_buf_chk(&argvars[2], buf2); if (xp_name == NULL) { return; } diff --git a/src/nvim/normal.c b/src/nvim/normal.c index d4919dc3b6..388ddfc8bb 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -4670,6 +4670,7 @@ static void nv_ident(cmdarg_T *cap) char_u *kp = *curbuf->b_p_kp == NUL ? p_kp : curbuf->b_p_kp; // 'keywordprg' assert(*kp != NUL); // option.c:do_set() should default to ":help" if empty. bool kp_ex = (*kp == ':'); // 'keywordprg' is an ex command + bool kp_help = (STRCMP(kp, ":he") == 0 || STRCMP(kp, ":help") == 0); size_t buf_size = n * 2 + 30 + STRLEN(kp); char *buf = xmalloc(buf_size); buf[0] = NUL; @@ -4692,7 +4693,9 @@ static void nv_ident(cmdarg_T *cap) break; case 'K': - if (kp_ex) { + if (kp_help) { + STRCPY(buf, "he! "); + } else if (kp_ex) { if (cap->count0 != 0) { // Send the count to the ex command. snprintf(buf, buf_size, "%" PRId64, (int64_t)(cap->count0)); } @@ -4755,7 +4758,7 @@ static void nv_ident(cmdarg_T *cap) } // Now grab the chars in the identifier - if (cmdchar == 'K') { + if (cmdchar == 'K' && !kp_help) { ptr = vim_strnsave(ptr, n); if (kp_ex) { // Escape the argument properly for an Ex command diff --git a/src/nvim/option.c b/src/nvim/option.c index 0bf81b4d3a..0b4d9aae5d 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -1054,13 +1054,15 @@ void set_init_3(void) */ void set_helplang_default(const char *lang) { - int idx; + if (lang == NULL) { + return; + } const size_t lang_len = strlen(lang); - if (lang == NULL || lang_len < 2) { // safety check + if (lang_len < 2) { // safety check return; } - idx = findoption("hlg"); + int idx = findoption("hlg"); if (idx >= 0 && !(options[idx].flags & P_WAS_SET)) { if (options[idx].flags & P_ALLOCED) free_string_option(p_hlg); diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c index a73d753e46..a10c835591 100644 --- a/src/nvim/os/env.c +++ b/src/nvim/os/env.c @@ -615,9 +615,9 @@ char *vim_getenv(const char *name) vim_path = (char *)p_hf; } + char exe_name[MAXPATHL]; // Find runtime path relative to the nvim binary: ../share/nvim/runtime if (vim_path == NULL) { - char exe_name[MAXPATHL]; size_t exe_name_len = MAXPATHL; if (os_exepath(exe_name, &exe_name_len) == 0) { char *path_end = (char *)path_tail_with_sep((char_u *)exe_name); |