]> granicus.if.org Git - vim/commitdiff
patch 8.1.1032: warnings from clang static analyzer v8.1.1032
authorBram Moolenaar <Bram@vim.org>
Thu, 21 Mar 2019 20:45:34 +0000 (21:45 +0100)
committerBram Moolenaar <Bram@vim.org>
Thu, 21 Mar 2019 20:45:34 +0000 (21:45 +0100)
Problem:    Warnings from clang static analyzer. (Yegappan Lakshmanan)
Solution:   Fix relevant warnings.

13 files changed:
src/arabic.c
src/channel.c
src/charset.c
src/edit.c
src/eval.c
src/fileio.c
src/message.c
src/normal.c
src/option.c
src/os_unix.c
src/regexp.c
src/screen.c
src/version.c

index 6c15221f66b045ce1aa86b8c79148a7bf8897902..adf414712c25b3d57f8474eb4249586efd6d7902 100644 (file)
@@ -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);
 
index 176a3d7e1ededfa588a495afc47d52ea85111e31..9ce47d3a470d0bfe429c8b8aa72d2df56b800c81 100644 (file)
@@ -1720,7 +1720,7 @@ channel_get(channel_T *channel, ch_part_T part, int *outlen)
 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;
index 1d66d617ad7fb3a40d0796c80a7aeebbbbf6a35a..3eb5b5805556632331f5de7bbbe7739666a91e81 100644 (file)
@@ -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
index 2f81b52dffbb255265ebf767b32adc7a6c217c9e..452d4a6dc7a49b60940f7b287b71d9155b48ae78 100644 (file)
@@ -4109,11 +4109,11 @@ ins_compl_fixRedoBufForLeader(char_u *ptr_arg)
     static buf_T *
 ins_compl_next_buf(buf_T *buf, int flag)
 {
-    static win_T *wp;
+    static win_T *wp = NULL;
 
-    if (flag == 'w')           /* just windows */
+    if (flag == 'w')           // just windows
     {
-       if (buf == curbuf)      /* first call for this flag/expansion */
+       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)
index 62fe3b5bf2fd0fc1d80d20dd19aa5a94bf8c28a5..2a138d56cf8a760e48af914367e7db2a0c845ac3 100644 (file)
@@ -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;
index 4060f69d3fb58eade9b2ebae0a3b934e4cb11a16..22a735f5597aa2e4b71427ed8d170a031ed30333 100644 (file)
@@ -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)
index d6acb0991006a00274fafbcf1199d7ac05648642..fa37df12bb25e27936dafbe31d03ba07dace472a 100644 (file)
@@ -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? */
index 5ae9ff1aeec7b1d7f4605c9fca27599b095b87ed..477907520bcf806bbe49d74a8cdb411e562cb929 100644 (file)
@@ -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)
index b71093b86a8e714df291db79e8d4024e6a3c6586..f9cbcbd7b89ab78f07dd8ad267aa22d6e96e8a1f 100644 (file)
@@ -4405,7 +4405,6 @@ do_set(
            key = 0;
            if (*arg == '<')
            {
-               nextchar = 0;
                opt_idx = -1;
                /* look out for <t_>;> */
                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");
index 47b27cf0e4b52ca6c8ea274a6e77e9d6a323d819..0d9f69e53fc3e8615ae54325536c7085817bac0f 100644 (file)
@@ -6147,9 +6147,9 @@ RealWaitForChar(int fd, long msec, int *check_for_gpm UNUSED, int *interrupted)
        }
 # 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 */
index 5557987d5862066fd10b0095ec0bebd5b35afc4f..0a6695cef54b9eb76a543ce0fbf8dd376984e464 100644 (file)
@@ -2785,7 +2785,7 @@ reginsert_nr(int op, long val, char_u *opnd)
     *place++ = op;
     *place++ = NUL;
     *place++ = NUL;
-    place = re_put_long(place, (long_u)val);
+    re_put_long(place, (long_u)val);
 }
 
 /*
index 111c77d8a0c740ce861fd7670969beb5c9a107f7..c01a74c44e2ba8d3cede6a1b1b6d5d2334163324 100644 (file)
@@ -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, int ignore_pum)
     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)
index 686a7bd0544f0d913268bd58e2716001e469cff6..0ccf490fb93868da7154858e30c6708b9f3289dc 100644 (file)
@@ -779,6 +779,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1032,
 /**/
     1031,
 /**/