From 9e9ba14e0e443beff4c1418cdaff412c394852c0 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 16 Apr 2017 19:38:16 +0300 Subject: edit: Fix strange code Based on the flow it looks like ptr could not be NULL here: if ptr_arg is NULL ptr is compl_leader, if compl_leader is NULL function exits. This also applies to Vim as far as I see. --- src/nvim/edit.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/nvim/edit.c') diff --git a/src/nvim/edit.c b/src/nvim/edit.c index fe00027dec..1ca5424736 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -3427,10 +3427,11 @@ static void ins_compl_fixRedoBufForLeader(char_u *ptr_arg) len -= (*mb_head_off)(p, p + len); for (p += len; *p != NUL; mb_ptr_adv(p)) AppendCharToRedobuff(K_BS); - } else + } else { len = 0; - if (ptr != NULL) - AppendToRedobuffLit(ptr + len, -1); + } + assert(ptr != NULL); + AppendToRedobuffLit(ptr + len, -1); } /* -- cgit From dd5b0cc17a1ec6925c6cd7a5be23eb78bf953f76 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 16 Apr 2017 19:50:23 +0300 Subject: edit: Copy assert to before the warning --- src/nvim/edit.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/edit.c') diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 1ca5424736..51d0847bc7 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -3419,6 +3419,7 @@ static void ins_compl_fixRedoBufForLeader(char_u *ptr_arg) else return; /* nothing to do */ } + assert(ptr != NULL); if (compl_orig_text != NULL) { p = compl_orig_text; for (len = 0; p[len] != NUL && p[len] == ptr[len]; ++len) -- cgit From c2f3e361c52ec4e7149ea1d8c6a1202e0873da8e Mon Sep 17 00:00:00 2001 From: ZyX Date: Wed, 19 Apr 2017 19:11:50 +0300 Subject: *: Add comment to all C files --- src/nvim/edit.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/nvim/edit.c') diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 51d0847bc7..678fa851eb 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -1,3 +1,6 @@ +// This is an open source non-commercial project. Dear PVS-Studio, please check +// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com + /* * edit.c: functions for Insert mode */ -- cgit