commit f0658fd552ec2d72cdd3f09942fe104bc6265115
parent 5c9baa6f35262f75b73a82e4b2eba8f7cdf9db0a
Author: zeertzjq <zeertzjq@outlook.com>
Date: Thu, 25 Aug 2022 15:20:54 +0800
refactor: suppress clang and PVS warnings (#19940)
Diffstat:
4 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
@@ -8148,6 +8148,7 @@ repeat:
// Only replace it when it starts with '~'
if (*dirname == '~') {
s = xstrdup(dirname);
+ assert(s != NULL); // suppress clang "Argument with 'nonnull' attribute passed null"
*fnamep = s;
xfree(*bufp);
*bufp = s;
diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c
@@ -1252,7 +1252,7 @@ static void do_sort_uniq(typval_T *argvars, typval_T *rettv, bool sort)
idx++;
li = TV_LIST_ITEM_NEXT(l, li);
}
- if (info.item_compare_func_err) {
+ if (info.item_compare_func_err) { // -V547
emsg(_("E882: Uniq compare function failed"));
break;
}
diff --git a/src/nvim/eval/vars.c b/src/nvim/eval/vars.c
@@ -791,6 +791,7 @@ static void ex_unletlock(exarg_T *eap, char *argstart, int deep, ex_unletlock_ca
semsg(_(e_invarg2), arg - 1);
return;
}
+ assert(*lv.ll_name == '$'); // suppress clang "Uninitialized argument value"
if (!error && !eap->skip && callback(&lv, arg, eap, deep) == FAIL) {
error = true;
}
diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c
@@ -640,6 +640,7 @@ static char_u *ins_compl_infercase_gettext(char_u *str, int char_len, int compl_
while (i < char_len) {
if (gap.ga_data != NULL) {
ga_grow(&gap, 10);
+ assert(gap.ga_data != NULL); // suppress clang "Dereference of NULL pointer"
p = (char *)gap.ga_data + gap.ga_len;
gap.ga_len += utf_char2bytes(wca[i++], p);
} else if ((p - (char *)IObuff) + 6 >= IOSIZE) {