# HG changeset patch # User Bram Moolenaar # Date 1553202005 -3600 # Node ID 78faa25f9698b451bc47b1badf403f1573deb3e6 # Parent b6ce2c4d15a874aca80cb1db3bf397f99e8f9248 patch 8.1.1032: warnings from clang static analyzer commit https://github.com/vim/vim/commit/2c519cf3bfe76083767ac94c674d2e161ed36587 Author: Bram Moolenaar Date: Thu Mar 21 21:45:34 2019 +0100 patch 8.1.1032: warnings from clang static analyzer Problem: Warnings from clang static analyzer. (Yegappan Lakshmanan) Solution: Fix relevant warnings. diff --git a/src/arabic.c b/src/arabic.c --- a/src/arabic.c +++ b/src/arabic.c @@ -578,9 +578,6 @@ arabic_shape( /* half-shape current and previous character */ shape_c = half_shape(prev_c); - /* Save away current character */ - curr_c = c; - curr_laa = A_firstc_laa(c, *c1p); prev_laa = A_firstc_laa(prev_c, prev_c1); diff --git a/src/channel.c b/src/channel.c --- a/src/channel.c +++ b/src/channel.c @@ -1720,7 +1720,7 @@ channel_get(channel_T *channel, ch_part_ channel_get_all(channel_T *channel, ch_part_T part, int *outlen) { readq_T *head = &channel->ch_part[part].ch_head; - readq_T *node = head->rq_next; + readq_T *node; long_u len = 0; char_u *res; char_u *p; diff --git a/src/charset.c b/src/charset.c --- a/src/charset.c +++ b/src/charset.c @@ -1055,7 +1055,6 @@ win_lbr_chartabsize( if (col2 >= colmax) /* doesn't fit */ { size = colmax - col + col_adj; - tab_corr = FALSE; break; } } @@ -1108,7 +1107,8 @@ win_lbr_chartabsize( { /* calculate effective window width */ int width = (colnr_T)wp->w_width - sbrlen - numberwidth; - int prev_width = col ? ((colnr_T)wp->w_width - (sbrlen + col)) : 0; + int prev_width = col + ? ((colnr_T)wp->w_width - (sbrlen + col)) : 0; if (width == 0) width = (colnr_T)wp->w_width; added += ((size - prev_width) / width) * vim_strsize(p_sbr); @@ -1963,7 +1963,7 @@ hexhex2nr(char_u *p) /* * Return TRUE if "str" starts with a backslash that should be removed. - * For MS-DOS, WIN32 and OS/2 this is only done when the character after the + * For MS-DOS, MSWIN and OS/2 this is only done when the character after the * backslash is not a normal file name character. * '$' is a valid file name character, we don't remove the backslash before * it. This means it is not possible to use an environment variable after a diff --git a/src/edit.c b/src/edit.c --- a/src/edit.c +++ b/src/edit.c @@ -4109,11 +4109,11 @@ ins_compl_fixRedoBufForLeader(char_u *pt static buf_T * ins_compl_next_buf(buf_T *buf, int flag) { - static win_T *wp; - - if (flag == 'w') /* just windows */ - { - if (buf == curbuf) /* first call for this flag/expansion */ + static win_T *wp = NULL; + + if (flag == 'w') // just windows + { + if (buf == curbuf || wp == NULL) // first call for this flag/expansion wp = curwin; while ((wp = (wp->w_next != NULL ? wp->w_next : firstwin)) != curwin && wp->w_buffer->b_scanned) diff --git a/src/eval.c b/src/eval.c --- a/src/eval.c +++ b/src/eval.c @@ -8544,7 +8544,7 @@ ex_execute(exarg_T *eap) char_u *p; garray_T ga; int len; - int save_did_emsg = did_emsg; + int save_did_emsg; ga_init2(&ga, 1, 80); @@ -8552,7 +8552,6 @@ ex_execute(exarg_T *eap) ++emsg_skip; while (*arg != NUL && *arg != '|' && *arg != '\n') { - p = arg; ret = eval1_emsg(&arg, &rettv, !eap->skip); if (ret == FAIL) break; diff --git a/src/fileio.c b/src/fileio.c --- a/src/fileio.c +++ b/src/fileio.c @@ -2322,10 +2322,7 @@ failed: vim_free(fenc); #ifdef USE_ICONV if (iconv_fd != (iconv_t)-1) - { iconv_close(iconv_fd); - iconv_fd = (iconv_t)-1; - } #endif if (!read_buffer && !read_stdin) diff --git a/src/message.c b/src/message.c --- a/src/message.c +++ b/src/message.c @@ -4491,7 +4491,6 @@ vim_vsnprintf_typval( case 'c': case 's': case 'S': - length_modifier = '\0'; str_arg_l = 1; switch (fmt_spec) { @@ -4872,7 +4871,6 @@ vim_vsnprintf_typval( * zero value is formatted with an * explicit precision of zero */ precision = num_of_digits + 1; - precision_specified = 1; } } /* zero padding to specified precision? */ diff --git a/src/normal.c b/src/normal.c --- a/src/normal.c +++ b/src/normal.c @@ -214,7 +214,7 @@ static const struct nv_cmd {NL, nv_down, 0, FALSE}, {Ctrl_K, nv_error, 0, 0}, {Ctrl_L, nv_clear, 0, 0}, - {Ctrl_M, nv_down, 0, TRUE}, + {CAR, nv_down, 0, TRUE}, {Ctrl_N, nv_down, NV_STS, FALSE}, {Ctrl_O, nv_ctrlo, 0, 0}, {Ctrl_P, nv_up, NV_STS, FALSE}, @@ -4263,7 +4263,6 @@ find_decl( CLEAR_POS(&found_pos); for (;;) { - valid = FALSE; t = searchit(curwin, curbuf, &curwin->w_cursor, NULL, FORWARD, pat, 1L, searchflags, RE_LAST, (linenr_T)0, NULL, NULL); if (curwin->w_cursor.lnum >= old_pos.lnum) diff --git a/src/option.c b/src/option.c --- a/src/option.c +++ b/src/option.c @@ -4405,7 +4405,6 @@ do_set( key = 0; if (*arg == '<') { - nextchar = 0; opt_idx = -1; /* look out for ;> */ if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4]) @@ -7945,7 +7944,7 @@ set_chars_option(char_u **varp) && p[len] == ':' && p[len + 1] != NUL) { - c1 = c2 = c3 = 0; + c2 = c3 = 0; s = p + len + 1; c1 = mb_ptr2char_adv(&s); if (mb_char2cells(c1) > 1) @@ -9379,6 +9378,7 @@ set_num_option( if (!starting && errmsg == NULL && *get_vim_var_str(VV_OPTION_TYPE) == NUL) { char_u buf_old[11], buf_new[11], buf_type[7]; + vim_snprintf((char *)buf_old, 10, "%ld", old_value); vim_snprintf((char *)buf_new, 10, "%ld", value); vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global"); diff --git a/src/os_unix.c b/src/os_unix.c --- a/src/os_unix.c +++ b/src/os_unix.c @@ -6147,9 +6147,9 @@ RealWaitForChar(int fd, long msec, int * } # endif #ifdef FEAT_JOB_CHANNEL - /* also call when ret == 0, we may be polling a keep-open channel */ + // also call when ret == 0, we may be polling a keep-open channel if (ret >= 0) - ret = channel_poll_check(ret, &fds); + channel_poll_check(ret, &fds); #endif #else /* HAVE_SELECT */ diff --git a/src/regexp.c b/src/regexp.c --- a/src/regexp.c +++ b/src/regexp.c @@ -2785,7 +2785,7 @@ reginsert_nr(int op, long val, char_u *o *place++ = op; *place++ = NUL; *place++ = NUL; - place = re_put_long(place, (long_u)val); + re_put_long(place, (long_u)val); } /* diff --git a/src/screen.c b/src/screen.c --- a/src/screen.c +++ b/src/screen.c @@ -4900,7 +4900,7 @@ win_line( else { char_u *p; - int len = n_extra; + int len; int i; int saved_nextra = n_extra; @@ -5505,8 +5505,8 @@ win_line( if (vcol < v + col - win_col_off(wp)) vcol = v + col - win_col_off(wp); #ifdef FEAT_CONCEAL - /* Get rid of the boguscols now, we want to draw until the right - * edge for 'cursorcolumn'. */ + // Get rid of the boguscols now, we want to draw until the right + // edge for 'cursorcolumn'. col -= boguscols; boguscols = 0; #endif @@ -10466,7 +10466,6 @@ draw_tabline(void) attr = attr_nosel; tabcount = 0; - scol = 0; for (tp = first_tabpage; tp != NULL && col < Columns - 4; tp = tp->tp_next) { @@ -10799,7 +10798,7 @@ win_redr_ruler(win_T *wp, int always, in int o; int this_ru_col; int off = 0; - int width = Columns; + int width; /* If 'ruler' off or redrawing disabled, don't do anything */ if (!p_ru) diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -780,6 +780,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1032, +/**/ 1031, /**/ 1030,