From 3d57bcee7d0783f554497b7e3b1dda06df4ea40c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eliseo=20Marti=CC=81nez?= Date: Tue, 11 Nov 2014 21:59:20 +0100 Subject: [PATCH 01/15] Fix warnings: option.c: do_set(): Dead assignment: HI. Problem : Dead assignment @ 2566. Diagnostic : Harmless issue. Rationale : `nextchar` is used as a lookahead buffer for the character next to the currently examined token. Sometimes it also saves that char while original string is modified (original position of nextchar is nullified for the string to terminate there). In summary, it's an auxiliary variable with no particular complex meaning. Safe to remove if not used. Resolution : Remove dead assignment. --- src/nvim/option.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/nvim/option.c b/src/nvim/option.c index 14b26fbc34..31f5ab7788 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -2563,7 +2563,6 @@ do_set ( /* find end of name */ key = 0; if (*arg == '<') { - nextchar = 0; opt_idx = -1; /* look out for ;> */ if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4]) From 83a32aad82f87fda3d8a5984ebf627213c18177a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eliseo=20Marti=CC=81nez?= Date: Wed, 12 Nov 2014 10:39:44 +0100 Subject: [PATCH 02/15] Fix warnings: quickfix.c: qf_add_entry(): Np dereference: FP. Problem : Dereference of null pointer @ 921. Diagnostic : False positive. Rationale : If `qi->qf_lists[qi->qf_curlist].qf_count == 0` doesn't hold, we should be calling function with nonnull `*prevp`. Resolution : Assert nonnull. --- src/nvim/quickfix.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 5ffd5ea263..3de7f73339 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -10,6 +10,7 @@ * quickfix.c: functions for quickfix mode, using a file with error messages */ +#include #include #include #include @@ -880,7 +881,7 @@ void qf_free_all(win_T *wp) static int qf_add_entry ( qf_info_T *qi, /* quickfix list */ - qfline_T **prevp, /* pointer to previously added entry or NULL */ + qfline_T **prevp, /* nonnull pointer (to previously added entry or NULL) */ char_u *dir, /* optional directory name */ char_u *fname, /* file name or NULL */ int bufnum, /* buffer number or zero */ @@ -920,6 +921,7 @@ qf_add_entry ( qi->qf_lists[qi->qf_curlist].qf_start = qfp; qfp->qf_prev = qfp; /* first element points to itself */ } else { + assert(*prevp); qfp->qf_prev = *prevp; (*prevp)->qf_next = qfp; } From 78b49ce950b31df8b5ee6788c84b3d439a982d59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eliseo=20Marti=CC=81nez?= Date: Wed, 12 Nov 2014 11:22:10 +0100 Subject: [PATCH 03/15] Fix warnings: regexp_nfa.c: nfa_regatom(): Dead assignment: HI. Problem : Dead assignment @ 1554. Diagnostic : Harmless issue. Rationale : `result` is used when analyzing if a bracketed expresion `[]` can be condensed into a character class. Not used for anything else anywhere. So, it's safe to remove. Resolution : Remove dead assingment and move declaration of `result` to the scope where it's used. --- src/nvim/regexp_nfa.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c index 9ae1740627..60cdc12c92 100644 --- a/src/nvim/regexp_nfa.c +++ b/src/nvim/regexp_nfa.c @@ -1084,7 +1084,6 @@ static int nfa_regatom(void) int extra = 0; int emit_range; int negated; - int result; int startc = -1; int endc = -1; int oldstartc = -1; @@ -1452,8 +1451,8 @@ collection: * recognize that [0-9] stands for \d and [A-Za-z_] for \h, * and perform the necessary substitutions in the NFA. */ - result = nfa_recognize_char_class(regparse, endp, - extra == NFA_ADD_NL); + int result = nfa_recognize_char_class(regparse, endp, + extra == NFA_ADD_NL); if (result != FAIL) { if (result >= NFA_FIRST_NL && result <= NFA_LAST_NL) { EMIT(result - NFA_ADD_NL); @@ -1557,7 +1556,6 @@ collection: /* Try equivalence class [=a=] and the like */ if (equiclass != 0) { nfa_emit_equi_class(equiclass); - result = OK; continue; } /* Try collating class like [. .] */ From b02905bdd7555b2016930c2e802f79656bada9fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eliseo=20Marti=CC=81nez?= Date: Wed, 12 Nov 2014 11:32:50 +0100 Subject: [PATCH 04/15] Fix warnings: search.c: find_pattern_in_path(): Np dereference: MI. Problem : Dereference of null pointer @ 4395. Diagnostic : Multithreading issue. Rationale : Problem occurs only if global g_do_tagpreview changed while funcion is executing. Resolution : Use local copy of global var. --- src/nvim/search.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/nvim/search.c b/src/nvim/search.c index 1e275e9753..bd1811c7fb 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -3973,6 +3973,7 @@ find_pattern_in_path ( char_u *startp = NULL; char_u *inc_opt = NULL; win_T *curwin_save = NULL; + const int l_g_do_tagpreview = g_do_tagpreview; regmatch.regprog = NULL; incl_regmatch.regprog = NULL; @@ -4370,7 +4371,7 @@ search_line: } else if (--count <= 0) { found = TRUE; if (depth == -1 && lnum == curwin->w_cursor.lnum - && g_do_tagpreview == 0 + && l_g_do_tagpreview == 0 ) EMSG(_("E387: Match is on current line")); else if (action == ACTION_SHOW) { @@ -4380,7 +4381,7 @@ search_line: did_show = TRUE; } else { /* ":psearch" uses the preview window */ - if (g_do_tagpreview != 0) { + if (l_g_do_tagpreview != 0) { curwin_save = curwin; prepare_tagpreview(true); } @@ -4391,7 +4392,7 @@ search_line: } if (depth == -1) { /* match in current file */ - if (g_do_tagpreview != 0) { + if (l_g_do_tagpreview != 0) { if (getfile(0, curwin_save->w_buffer->b_fname, NULL, TRUE, lnum, FALSE) > 0) break; /* failed to jump to file */ @@ -4412,7 +4413,7 @@ search_line: curwin->w_set_curswant = TRUE; } - if (g_do_tagpreview != 0 + if (l_g_do_tagpreview != 0 && curwin != curwin_save && win_valid(curwin_save)) { /* Return cursor to where we were */ validate_cursor(); From 7d3aac2d7111138b288a83005171b7900b8bcddd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eliseo=20Marti=CC=81nez?= Date: Wed, 12 Nov 2014 13:49:11 +0100 Subject: [PATCH 05/15] Fix warnings: spell.c: find_word(): Dead assignment: HI. Problem : Dead assignment @ 1602. Diagnostic : Harmless issue. Rationale : Code using this assignment (line 1666) was disabled. Vim's tip at Wed Nov 12 13:07:54 2014 +0100 (changeset 6352:2f7bf5f90f57) hasn't changed this yet. Resolution : Disable assignment. Directive processors are used for that in order to match the way the other code was disabled. --- src/nvim/spell.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/nvim/spell.c b/src/nvim/spell.c index 342f121c48..38d52a7f53 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -1599,7 +1599,9 @@ static void find_word(matchinf_T *mip, int mode) mip->mi_compoff = (int)(p - mip->mi_fword); } } +#if 0 c = mip->mi_compoff; +#endif ++mip->mi_complen; if (flags & WF_COMPROOT) ++mip->mi_compextra; From faa000edcb97482c4f8adc3f436344584ceca326 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eliseo=20Marti=CC=81nez?= Date: Wed, 12 Nov 2014 22:49:29 +0100 Subject: [PATCH 06/15] Fix warnings: spell.c: spell_move_to(): Null arg: FP. Problem : Argument with 'nonnull' attribute passed null @ 2118. Diagnostic : False positive. Rationale : Error happens when `if (buflen < len + MAXWLEN + 2) {` is not entered on the first iteration, which cannot happen because buflen is 0 on the first iteration, so the condition should always hold. Resolution : Assert existence of buffer with appropiate length after conditional (which prevents previous error path). --- src/nvim/spell.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/nvim/spell.c b/src/nvim/spell.c index 38d52a7f53..d52961b799 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -284,6 +284,7 @@ // stored as an offset to the previous number in as // few bytes as possible, see offset2bytes()) +#include #include #include #include @@ -2096,6 +2097,7 @@ spell_move_to ( buflen = len + MAXWLEN + 2; buf = xmalloc(buflen); } + assert(buf && buflen >= len + MAXWLEN + 2); // In first line check first word for Capital. if (lnum == 1) From 40cf1a1e749ab825e99ed948bc463bd0d8fa495e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eliseo=20Marti=CC=81nez?= Date: Thu, 13 Nov 2014 13:02:10 +0100 Subject: [PATCH 07/15] Fix warnings: spell.c: spell_move_to(): Garbage value: RI. Problem : Result of operation is garbage or undefined @ 2238. Diagnostic : Real issue. Rationale : Problem occurs when searching forward starting on an empty line. This is, at 2127: ``` p = buf + skip; endp = buf + len; while (p < endp) { ``` when skip == 0, len == 0, implying p == endp and therefore not entering the loop. Under those conditions, comparison ``` if (attr == HLF_COUNT) ``` at line 2242 is really using a garbage value for `attr`. Most of the time the error doesn't produce visible problems as it only affects when dealing with wrapped words. Resolution : Initialize `attr` at declaration to `HLF_COUNT`, which is used in the code when no bad word found yet. --- src/nvim/spell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nvim/spell.c b/src/nvim/spell.c index d52961b799..1a173cb8df 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -2061,7 +2061,7 @@ spell_move_to ( char_u *line; char_u *p; char_u *endp; - hlf_T attr; + hlf_T attr = HLF_COUNT; int len; int has_syntax = syntax_present(wp); int col; From a09b7f2e2e248e967e100018944e65dfe781c84d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eliseo=20Marti=CC=81nez?= Date: Thu, 13 Nov 2014 17:49:10 +0100 Subject: [PATCH 08/15] Fix warnings: spell.c: spell_read_aff(): Uninitialized arg: RI. Problem : Uninitialized argument value @ 4469. Diagnostic : Real issue. Rationale : Happens when a line contains a spell info item (NAME, HOME, VERSION, AUTHOR, EMAIL, COPYRIGHT), which expect a second item, but then the second item is not present. Resolution : Add guard (item count > 1) to failing branch. --- src/nvim/spell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nvim/spell.c b/src/nvim/spell.c index 1a173cb8df..a760691ad3 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -4466,7 +4466,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname) || aff->af_pref.ht_used > 0) smsg((char_u *)_("FLAG after using flags in %s line %d: %s"), fname, lnum, items[1]); - } else if (spell_info_item(items[0])) { + } else if (spell_info_item(items[0]) && itemcnt > 1) { p = (char_u *)getroom(spin, (spin->si_info == NULL ? 0 : STRLEN(spin->si_info)) + STRLEN(items[0]) From 5f9cacbf326cacb8162f2a5b5fd7ca839f09ae52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eliseo=20Marti=CC=81nez?= Date: Thu, 13 Nov 2014 19:17:52 +0100 Subject: [PATCH 09/15] Fix warnings: spell.c: store_aff_word(): Garbage value: RI. Problem : Result of operation is garbage or undefined @ 5809. Diagnostic : Real issue. Rationale : When copying flags, first access to `use_pfxlist[use_pfxlen]` was garbage if `spin->si_compflags` was null. Resolution : Make sure `use_pfxlist[use_pfxlen]` always has a value (NUL if `spin->si_compflags` is NULL). --- src/nvim/spell.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/nvim/spell.c b/src/nvim/spell.c index a760691ad3..c3059d6b0b 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -5804,6 +5804,8 @@ store_aff_word ( // Get compound IDS from the affix list. get_compflags(affile, ae->ae_flags, use_pfxlist + use_pfxlen); + else + use_pfxlist[use_pfxlen] = NUL; // Combine the list of compound flags. // Concatenate them to the prefix IDs list. From 1adfb558f52f0d8b24140a992ec8e3368e481229 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eliseo=20Marti=CC=81nez?= Date: Thu, 13 Nov 2014 20:27:33 +0100 Subject: [PATCH 10/15] Fix warnings: spell.c: getroom(): Np dereference: FP/RI. Problem : Dereference of null pointer @ 6089. Diagnostic : False positive / Real issue. Rationale : From the code, it seems the intent is that len parameter should never exceed SBLOCKSIZE. But the code checking for that does in fact cause a null pointer dereference just immediately after. Resolution : State precondition in doc and assert it at entry. --- src/nvim/spell.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/nvim/spell.c b/src/nvim/spell.c index c3059d6b0b..0e76fc4b92 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -304,6 +304,7 @@ #include "nvim/ex_cmds2.h" #include "nvim/ex_docmd.h" #include "nvim/fileio.h" +#include "nvim/func_attr.h" #include "nvim/getchar.h" #include "nvim/hashtab.h" #include "nvim/mbyte.h" @@ -6072,14 +6073,17 @@ static int spell_read_wordfile(spellinfo_T *spin, char_u *fname) /// track of them). /// The memory is cleared to all zeros. /// -/// @param len Length needed. +/// @param len Length needed (<= SBLOCKSIZE). /// @param align Align for pointer. -/// @return NULL when out of memory. +/// @return Pointer into block data. static void *getroom(spellinfo_T *spin, size_t len, bool align) + FUNC_ATTR_NONNULL_RET { char_u *p; sblock_T *bl = spin->si_blocks; + assert(len <= SBLOCKSIZE); + if (align && bl != NULL) // Round size up for alignment. On some systems structures need to be // aligned to the size of a pointer (e.g., SPARC). @@ -6087,11 +6091,8 @@ static void *getroom(spellinfo_T *spin, size_t len, bool align) & ~(sizeof(char *) - 1); if (bl == NULL || bl->sb_used + len > SBLOCKSIZE) { - if (len >= SBLOCKSIZE) - bl = NULL; - else - // Allocate a block of memory. It is not freed until much later. - bl = xcalloc(1, (sizeof(sblock_T) + SBLOCKSIZE)); + // Allocate a block of memory. It is not freed until much later. + bl = xcalloc(1, (sizeof(sblock_T) + SBLOCKSIZE)); bl->sb_next = spin->si_blocks; spin->si_blocks = bl; bl->sb_used = 0; From 2aa8c7c41fd49c5763b4552c92b174851c595267 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eliseo=20Marti=CC=81nez?= Date: Thu, 13 Nov 2014 20:41:19 +0100 Subject: [PATCH 11/15] Fix warnings: spell.c: spell_edit_score(): Garbage value: MI. Problem : Assigned value is garbage or undefined @ 12526. Diagnostic : Multithreading issue. Rationale : Error only occurs if global has_mbyte is modified while function is executing. Resolution : Use local copy of global. --- src/nvim/spell.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/nvim/spell.c b/src/nvim/spell.c index 0e76fc4b92..ea5ce7ee0d 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -12503,8 +12503,9 @@ static int spell_edit_score(slang_T *slang, char_u *badword, char_u *goodword) char_u *p; int wbadword[MAXWLEN]; int wgoodword[MAXWLEN]; + const int l_has_mbyte = has_mbyte; - if (has_mbyte) { + if (l_has_mbyte) { // Get the characters from the multi-byte strings and put them in an // int array for easy access. for (p = badword, badlen = 0; *p != NUL; ) @@ -12529,7 +12530,7 @@ static int spell_edit_score(slang_T *slang, char_u *badword, char_u *goodword) for (i = 1; i <= badlen; ++i) { CNT(i, 0) = CNT(i - 1, 0) + SCORE_DEL; for (j = 1; j <= goodlen; ++j) { - if (has_mbyte) { + if (l_has_mbyte) { bc = wbadword[i - 1]; gc = wgoodword[j - 1]; } else { @@ -12553,7 +12554,7 @@ static int spell_edit_score(slang_T *slang, char_u *badword, char_u *goodword) } if (i > 1 && j > 1) { - if (has_mbyte) { + if (l_has_mbyte) { pbc = wbadword[i - 2]; pgc = wgoodword[j - 2]; } else { From ce9c4e9a6f253b1540a5367f834f6dd31e6db0c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eliseo=20Marti=CC=81nez?= Date: Thu, 13 Nov 2014 23:27:49 +0100 Subject: [PATCH 12/15] Fix warnings: syntax.c: syn_regexec(): Uninitialized arg: MI. Problem : Uninitialized argument value @ 2863. Diagnostic : Multithreading issue. Rationale : Error can only occur if global `syn_time_on` is changed while the function is executing. Resolution : Use local copy of gloval var. --- src/nvim/syntax.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index e0c9628985..4a3ab46e75 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -2851,15 +2851,16 @@ static int syn_regexec(regmmatch_T *rmp, linenr_T lnum, colnr_T col, syn_time_T { int r; proftime_T pt; + const int l_syn_time_on = syn_time_on; - if (syn_time_on) { + if (l_syn_time_on) { pt = profile_start(); } rmp->rmm_maxcol = syn_buf->b_p_smc; r = vim_regexec_multi(rmp, syn_win, syn_buf, lnum, col, NULL); - if (syn_time_on) { + if (l_syn_time_on) { pt = profile_end(pt); st->total = profile_add(st->total, pt); if (profile_cmp(pt, st->slowest) < 0) { From fcd5a8643c2022f20f5225614fd5dc39775af486 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eliseo=20Marti=CC=81nez?= Date: Thu, 13 Nov 2014 23:30:43 +0100 Subject: [PATCH 13/15] Fix warnings: syntax.c: get_id_list(): Double free: FP. Problem : Double free @ 5213. Diagnostic : False positive. Rationale : Suggested error path contains two consecutive invocations of `ends_excmd(*p)` having different results, which is not possible. First invocation is before the while loop. Second invocation is the while loop condition itsef. Resolution : Refactor while loop into do-while loop. That removes the impossible path from analysis, and, in addition, is a bit more efficient. --- src/nvim/ex_docmd.c | 3 ++- src/nvim/syntax.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 134def0c2c..3e9b889253 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -31,6 +31,7 @@ #include "nvim/ex_getln.h" #include "nvim/fileio.h" #include "nvim/fold.h" +#include "nvim/func_attr.h" #include "nvim/getchar.h" #include "nvim/hardcopy.h" #include "nvim/if_cscope.h" @@ -4025,7 +4026,7 @@ static void ex_blast(exarg_T *eap) goto_buffer(eap, DOBUF_LAST, BACKWARD, 0); } -int ends_excmd(int c) +int ends_excmd(int c) FUNC_ATTR_CONST { return c == NUL || c == '|' || c == '"' || c == '\n'; } diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 4a3ab46e75..6c5c0f37b1 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -5106,7 +5106,7 @@ get_id_list ( * parse the arguments after "contains" */ count = 0; - while (!ends_excmd(*p)) { + do { for (end = p; *end && !vim_iswhite(*end) && *end != ','; ++end) ; name = xmalloc((int)(end - p + 3)); /* leave room for "^$" */ @@ -5199,7 +5199,7 @@ get_id_list ( if (*p != ',') break; p = skipwhite(p + 1); /* skip comma in between arguments */ - } + } while (!ends_excmd(*p)); if (failed) break; if (round == 1) { From 4a8af9cc99cd97032d85819601dc44d6de852c1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eliseo=20Marti=CC=81nez?= Date: Fri, 14 Nov 2014 09:17:16 +0100 Subject: [PATCH 14/15] Fix warnings: undo.c: u_blockfree(): Use after free: FP. Problem : Use-after-free @ 2686. Diagnostic : False positive. Rationale : Suggested error path is taking false branch `uhp->uh_next.ptr != NULL` @ 2506, which cannot happen when `uhp == buf->b_u_oldhead`. Resolution : Assert `buf->b_u_oldhead` is changed after freeing old one. --- src/nvim/undo.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/nvim/undo.c b/src/nvim/undo.c index b72d8ddb4f..2ab31b6cfd 100644 --- a/src/nvim/undo.c +++ b/src/nvim/undo.c @@ -80,6 +80,7 @@ #define UH_MAGIC 0x18dade /* value for uh_magic when in use */ #define UE_MAGIC 0xabc123 /* value for ue_magic when in use */ +#include #include #include #include @@ -2682,8 +2683,11 @@ void u_undoline(void) */ void u_blockfree(buf_T *buf) { - while (buf->b_u_oldhead != NULL) + while (buf->b_u_oldhead != NULL) { + u_header_T *previous_oldhead = buf->b_u_oldhead; u_freeheader(buf, buf->b_u_oldhead, NULL); + assert(buf->b_u_oldhead != previous_oldhead); + } free(buf->b_u_line_ptr); } From 150b0d66e11dc69b1a4fc3daad3016fa74bee4d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eliseo=20Marti=CC=81nez?= Date: Fri, 14 Nov 2014 09:51:43 +0100 Subject: [PATCH 15/15] Fix warnings: charset.c: win_lbr_chartabsize(): Dead assignment: HI. Problem : Dead assignment @ 1037. Diagnostic : Harmless issue. Rationale : `tab_corr` is in effect unused after signaled point. Previous code using it after that point was removed at 24ebb018e28187c61900b1616e4f79fec9d70878. Resolution : Remove dead assignment. As only one usage remains, remove variable and inline the only usage. --- src/nvim/charset.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/nvim/charset.c b/src/nvim/charset.c index e7ecf05880..f3bb3d8c73 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -978,7 +978,6 @@ int win_lbr_chartabsize(win_T *wp, char_u *line, char_u *s, colnr_T col, int *he int mb_added = 0; int numberextra; char_u *ps; - int tab_corr = (*s == TAB); int n; // No 'linebreak', 'showbreak' and 'breakindent': return quickly. @@ -992,7 +991,7 @@ int win_lbr_chartabsize(win_T *wp, char_u *line, char_u *s, colnr_T col, int *he // First get normal size, without 'linebreak' int size = win_chartabsize(wp, s, col); int c = *s; - if (tab_corr) { + if (*s == TAB) { col_adj = size - 1; } @@ -1034,7 +1033,6 @@ int win_lbr_chartabsize(win_T *wp, char_u *line, char_u *s, colnr_T col, int *he if (col2 >= colmax) { /* doesn't fit */ size = colmax - col + col_adj; - tab_corr = FALSE; break; } }