aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-06-30 21:13:08 +0800
committerGitHub <noreply@github.com>2023-06-30 21:13:08 +0800
commit2493815290c4cb5b1fb97b6d010c10bdf2d47a58 (patch)
treee329e58c238f2d091b37fb7593718446a8d01088
parentd191bdf9d5e54722e28ddb0cccc8eb2312a234df (diff)
downloadrneovim-2493815290c4cb5b1fb97b6d010c10bdf2d47a58.tar.gz
rneovim-2493815290c4cb5b1fb97b6d010c10bdf2d47a58.tar.bz2
rneovim-2493815290c4cb5b1fb97b6d010c10bdf2d47a58.zip
refactor: fix clang/PVS warnings (#24213)
-rw-r--r--src/nvim/api/deprecated.c2
-rw-r--r--src/nvim/drawline.c6
-rw-r--r--src/nvim/eval/typval.c4
-rw-r--r--src/nvim/spellsuggest.c2
4 files changed, 7 insertions, 7 deletions
diff --git a/src/nvim/api/deprecated.c b/src/nvim/api/deprecated.c
index 83c33db5d3..2e3ebd7c39 100644
--- a/src/nvim/api/deprecated.c
+++ b/src/nvim/api/deprecated.c
@@ -709,7 +709,7 @@ static void set_option_to(uint64_t channel_id, void *to, int type, String name,
}
}
- OptVal optval = NIL_OPTVAL;
+ OptVal optval;
if (flags & SOPT_BOOL) {
VALIDATE(value.type == kObjectTypeBoolean, "Option '%s' value must be Boolean", name.data, {
diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c
index 7aad47df00..c04ee0c222 100644
--- a/src/nvim/drawline.c
+++ b/src/nvim/drawline.c
@@ -735,10 +735,10 @@ static void get_statuscol_display_info(statuscol_T *stcp, winlinevars_T *wlv)
wlv->draw_state = WL_STC;
wlv->char_attr = stcp->cur_attr;
wlv->p_extra = stcp->textp;
- wlv->n_extra =
- (int)((stcp->hlrecp->start ? stcp->hlrecp->start : stcp->text_end) - stcp->textp);
+ char *const section_end = stcp->hlrecp->start ? stcp->hlrecp->start : stcp->text_end;
+ wlv->n_extra = (int)(section_end - stcp->textp);
// Prepare for next highlight section if not yet at the end
- if (stcp->textp + wlv->n_extra < stcp->text_end) {
+ if (section_end < stcp->text_end) {
int hl = stcp->hlrecp->userhl;
stcp->textp = stcp->hlrecp->start;
stcp->cur_attr = hl < 0 ? syn_id2attr(-hl) : stcp->num_attr;
diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c
index bae9880377..abe31aab75 100644
--- a/src/nvim/eval/typval.c
+++ b/src/nvim/eval/typval.c
@@ -673,6 +673,7 @@ int tv_list_assign_range(list_T *const dest, list_T *const src, const long idx1_
idx = idx1;
dest_li = first_li;
for (src_li = tv_list_first(src); src_li != NULL;) {
+ assert(dest_li != NULL);
if (op != NULL && *op != '=') {
eexe_mod_op(TV_LIST_ITEM_TV(dest_li), TV_LIST_ITEM_TV(src_li), op);
} else {
@@ -683,7 +684,6 @@ int tv_list_assign_range(list_T *const dest, list_T *const src, const long idx1_
if (src_li == NULL || (!empty_idx2 && idx2 == idx)) {
break;
}
- assert(dest_li != NULL);
if (TV_LIST_ITEM_NEXT(dest, dest_li) == NULL) {
// Need to add an empty item.
tv_list_append_number(dest, 0);
@@ -1622,7 +1622,7 @@ const char *tv_list_find_str(list_T *const l, const int n)
/// Like tv_list_find() but when a negative index is used that is not found use
/// zero and set "idx" to zero. Used for first index of a range.
-listitem_T *tv_list_find_index(list_T *const l, long *const idx)
+static listitem_T *tv_list_find_index(list_T *const l, long *const idx)
FUNC_ATTR_WARN_UNUSED_RESULT
{
listitem_T *li = tv_list_find(l, (int)(*idx));
diff --git a/src/nvim/spellsuggest.c b/src/nvim/spellsuggest.c
index 1c34c2487f..e68a90c982 100644
--- a/src/nvim/spellsuggest.c
+++ b/src/nvim/spellsuggest.c
@@ -1175,7 +1175,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
// word).
int depth = 0;
trystate_T *sp = &stack[0];
- CLEAR_POINTER(sp); // -V1068
+ CLEAR_POINTER(sp); // -V1086
sp->ts_curi = 1;
if (soundfold) {