]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.1.0377: xdiff doesn't use the Vim memory allocation functions v8.1.0377
authorBram Moolenaar <Bram@vim.org>
Thu, 13 Sep 2018 13:33:43 +0000 (15:33 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 13 Sep 2018 13:33:43 +0000 (15:33 +0200)
Problem:    Xdiff doesn't use the Vim memory allocation functions.
Solution:   Change the xdl_ defines.  Check for out-of-memory.  Rename
            "ignored" to "vim_ignored".

18 files changed:
src/channel.c
src/diff.c
src/evalfunc.c
src/ex_cmds.c
src/fileio.c
src/globals.h
src/main.c
src/mbyte.c
src/netbeans.c
src/os_unix.c
src/os_win32.c
src/term.c
src/ui.c
src/version.c
src/window.c
src/xdiff/xdiff.h
src/xdiff/xdiffi.c
src/xdiff/xpatience.c

index 793dbaa8336e50f0b742745246e2ffacc14cadc5..aa0a0d38cae97bd753e203843613be9fdd5c9628 100644 (file)
@@ -1858,7 +1858,7 @@ channel_save(channel_T *channel, ch_part_T part, char_u *buf, int len,
     {
        ch_log_lead(lead, channel, part);
        fprintf(log_fd, "'");
-       ignored = (int)fwrite(buf, len, 1, log_fd);
+       vim_ignored = (int)fwrite(buf, len, 1, log_fd);
        fprintf(log_fd, "'\n");
     }
     return OK;
@@ -2388,7 +2388,7 @@ append_to_buffer(buf_T *buffer, char_u *msg, channel_T *channel, ch_part_T part)
 
     u_sync(TRUE);
     /* ignore undo failure, undo is not very useful here */
-    ignored = u_save(lnum - empty, lnum + 1);
+    vim_ignored = u_save(lnum - empty, lnum + 1);
 
     if (empty)
     {
@@ -3730,7 +3730,7 @@ channel_send(
     {
        ch_log_lead("SEND ", channel, part);
        fprintf(log_fd, "'");
-       ignored = (int)fwrite(buf_arg, len_arg, 1, log_fd);
+       vim_ignored = (int)fwrite(buf_arg, len_arg, 1, log_fd);
        fprintf(log_fd, "'\n");
        fflush(log_fd);
        did_log_msg = TRUE;
index 59daf1eeb03a665d5a80154b5ca7cd2ff0ede50c..0bf0ef2cfaa6b8a84f502beb60da461344b3de5f 100644 (file)
@@ -1203,10 +1203,10 @@ ex_diffpatch(exarg_T *eap)
     {
 # ifdef TEMPDIRNAMES
        if (vim_tempdir != NULL)
-           ignored = mch_chdir((char *)vim_tempdir);
+           vim_ignored = mch_chdir((char *)vim_tempdir);
        else
 # endif
-           ignored = mch_chdir("/tmp");
+           vim_ignored = mch_chdir("/tmp");
        shorten_fnames(TRUE);
     }
 #endif
index 19e2657bac423fd6bb42a9e564c2071235b16a96..ff545893e90286b35ccab5ac9d9d1542ad2c23a2 100644 (file)
@@ -14016,7 +14016,7 @@ f_writefile(typval_T *argvars, typval_T *rettv)
        else if (do_fsync)
            /* Ignore the error, the user wouldn't know what to do about it.
             * May happen for a device. */
-           ignored = fsync(fileno(fd));
+           vim_ignored = fsync(fileno(fd));
 #endif
        fclose(fd);
     }
index 6e713c49a38eaaad55bdfcf85b2817bc36bbda91..0a87f7b38fcc9d3ef86a0d828227faa5c73a69bf 100644 (file)
@@ -2117,7 +2117,7 @@ write_viminfo(char_u *file, int forceit)
                if (st_old.st_uid != tmp_st.st_uid)
                    /* Changing the owner might fail, in which case the
                     * file will now owned by the current user, oh well. */
-                   ignored = fchown(fileno(fp_out), st_old.st_uid, -1);
+                   vim_ignored = fchown(fileno(fp_out), st_old.st_uid, -1);
                if (st_old.st_gid != tmp_st.st_gid
                        && fchown(fileno(fp_out), -1, st_old.st_gid) == -1)
                    /* can't set the group to what it should be, remove
index 056ac914d75e591e0c7cfe3ee4008af9dedb723e..d7e05bfbe03c17ac342829ade366fcc3feb5d369 100644 (file)
@@ -2408,7 +2408,7 @@ failed:
     {
        /* Use stderr for stdin, makes shell commands work. */
        close(0);
-       ignored = dup(2);
+       vim_ignored = dup(2);
     }
 #endif
 
@@ -3751,7 +3751,7 @@ buf_write(
                {
 # ifdef UNIX
 #  ifdef HAVE_FCHOWN
-                   ignored = fchown(fd, st_old.st_uid, st_old.st_gid);
+                   vim_ignored = fchown(fd, st_old.st_uid, st_old.st_gid);
 #  endif
                    if (mch_stat((char *)IObuff, &st) < 0
                            || st.st_uid != st_old.st_uid
@@ -4509,7 +4509,7 @@ restore_backup:
 #endif
 #ifdef HAVE_FTRUNCATE
            if (!append)
-               ignored = ftruncate(fd, (off_t)0);
+               vim_ignored = ftruncate(fd, (off_t)0);
 #endif
 
 #if defined(WIN3264)
@@ -4789,7 +4789,7 @@ restore_backup:
                    || st.st_gid != st_old.st_gid)
            {
                /* changing owner might not be possible */
-               ignored = fchown(fd, st_old.st_uid, -1);
+               vim_ignored = fchown(fd, st_old.st_uid, -1);
                /* if changing group fails clear the group permissions */
                if (fchown(fd, -1, st_old.st_gid) == -1 && perm > 0)
                    perm &= ~070;
@@ -6482,9 +6482,9 @@ vim_fgets(char_u *buf, int size, FILE *fp)
        {
            tbuf[FGETS_SIZE - 2] = NUL;
 #ifdef USE_CR
-           ignoredp = fgets_cr((char *)tbuf, FGETS_SIZE, fp);
+           vim_ignoredp = fgets_cr((char *)tbuf, FGETS_SIZE, fp);
 #else
-           ignoredp = fgets((char *)tbuf, FGETS_SIZE, fp);
+           vim_ignoredp = fgets((char *)tbuf, FGETS_SIZE, fp);
 #endif
        } while (tbuf[FGETS_SIZE - 2] != NUL && tbuf[FGETS_SIZE - 2] != '\n');
     }
index 3f5b61ff787d36358a2cf8eb570985b72e089bc5..511479d862288d11c419770c796c5d95534021c8 100644 (file)
@@ -1621,8 +1621,8 @@ EXTERN FILE *time_fd INIT(= NULL);  /* where to write startup timing */
  * can't do anything useful with the value.  Assign to this variable to avoid
  * the warning.
  */
-EXTERN int ignored;
-EXTERN char *ignoredp;
+EXTERN int vim_ignored;
+EXTERN char *vim_ignoredp;
 
 #ifdef FEAT_EVAL
 /* set by alloc_fail(): ID */
index cb0676ce565f121d36ca9bed5dc7d0f510a4098c..bf9b842f542d80d6643fc5a105f628aad2810aba 100644 (file)
@@ -2632,7 +2632,7 @@ read_stdin(void)
      * Is there any other system that cannot do this?
      */
     close(0);
-    ignored = dup(2);
+    vim_ignored = dup(2);
 #endif
 }
 
index 0014119ad79cb6fdbdebb7dd754db60d99ac306d..895f3b799b9094c056637e7a84a13f1dd9b5a6d2 100644 (file)
@@ -756,7 +756,7 @@ codepage_invalid:
                     * where mblen() returns 0 for invalid character.
                     * Therefore, following condition includes 0.
                     */
-                   ignored = mblen(NULL, 0);   /* First reset the state. */
+                   vim_ignored = mblen(NULL, 0);  // First reset the state.
                    if (mblen(buf, (size_t)1) <= 0)
                        n = 2;
                    else
index a753a4f9740a63df4193d072d5ac3a8e84b5d49b..1c916b5bf6fafcc6760ccce5fe977f1e8c85943c 100644 (file)
@@ -1988,10 +1988,10 @@ nb_do_cmd(
            pos = get_off_or_lnum(buf->bufp, &args);
 
            cp = (char *)args;
-           ignored = (int)strtol(cp, &cp, 10);
+           vim_ignored = (int)strtol(cp, &cp, 10);
            args = (char_u *)cp;
 # ifdef NBDEBUG
-           if (ignored != -1)
+           if (vim_ignored != -1)
            {
                nbdebug(("    partial line annotation -- Not Yet Implemented!\n"));
            }
index aee3a35ff7b1b7030559e2fe7f3b030653474af0..bd7b2199619f9a8352cc8a75b372525c7a406f9d 100644 (file)
@@ -357,7 +357,7 @@ mch_chdir(char *path)
     void
 mch_write(char_u *s, int len)
 {
-    ignored = (int)write(1, (char *)s, len);
+    vim_ignored = (int)write(1, (char *)s, len);
     if (p_wd)          /* Unix is too fast, slow down a bit more */
        RealWaitForChar(read_cmd_fd, p_wd, NULL, NULL);
 }
@@ -4693,9 +4693,9 @@ mch_call_shell_fork(
                 */
                if (fd >= 0)
                {
-                   ignored = dup(fd); /* To replace stdin  (fd 0) */
-                   ignored = dup(fd); /* To replace stdout (fd 1) */
-                   ignored = dup(fd); /* To replace stderr (fd 2) */
+                   vim_ignored = dup(fd); /* To replace stdin  (fd 0) */
+                   vim_ignored = dup(fd); /* To replace stdout (fd 1) */
+                   vim_ignored = dup(fd); /* To replace stderr (fd 2) */
 
                    /* Don't need this now that we've duplicated it */
                    close(fd);
@@ -4752,13 +4752,13 @@ mch_call_shell_fork(
 
                    /* set up stdin/stdout/stderr for the child */
                    close(0);
-                   ignored = dup(pty_slave_fd);
+                   vim_ignored = dup(pty_slave_fd);
                    close(1);
-                   ignored = dup(pty_slave_fd);
+                   vim_ignored = dup(pty_slave_fd);
                    if (gui.in_use)
                    {
                        close(2);
-                       ignored = dup(pty_slave_fd);
+                       vim_ignored = dup(pty_slave_fd);
                    }
 
                    close(pty_slave_fd);    /* has been dupped, close it now */
@@ -4769,13 +4769,13 @@ mch_call_shell_fork(
                    /* set up stdin for the child */
                    close(fd_toshell[1]);
                    close(0);
-                   ignored = dup(fd_toshell[0]);
+                   vim_ignored = dup(fd_toshell[0]);
                    close(fd_toshell[0]);
 
                    /* set up stdout for the child */
                    close(fd_fromshell[0]);
                    close(1);
-                   ignored = dup(fd_fromshell[1]);
+                   vim_ignored = dup(fd_fromshell[1]);
                    close(fd_fromshell[1]);
 
 # ifdef FEAT_GUI
@@ -4783,7 +4783,7 @@ mch_call_shell_fork(
                    {
                        /* set up stderr for the child */
                        close(2);
-                       ignored = dup(1);
+                       vim_ignored = dup(1);
                    }
 # endif
                }
@@ -4920,7 +4920,7 @@ mch_call_shell_fork(
                                            && (lnum !=
                                                    curbuf->b_ml.ml_line_count
                                                    || curbuf->b_p_eol)))
-                                   ignored = write(toshell_fd, "\n",
+                                   vim_ignored = write(toshell_fd, "\n",
                                                                   (size_t)1);
                                ++lnum;
                                if (lnum > curbuf->b_op_end.lnum)
@@ -5611,34 +5611,34 @@ mch_job_start(char **argv, job_T *job, jobopt_T *options, int is_terminal)
        /* set up stdin for the child */
        close(0);
        if (use_null_for_in && null_fd >= 0)
-           ignored = dup(null_fd);
+           vim_ignored = dup(null_fd);
        else if (fd_in[0] < 0)
-           ignored = dup(pty_slave_fd);
+           vim_ignored = dup(pty_slave_fd);
        else
-           ignored = dup(fd_in[0]);
+           vim_ignored = dup(fd_in[0]);
 
        /* set up stderr for the child */
        close(2);
        if (use_null_for_err && null_fd >= 0)
        {
-           ignored = dup(null_fd);
+           vim_ignored = dup(null_fd);
            stderr_works = FALSE;
        }
        else if (use_out_for_err)
-           ignored = dup(fd_out[1]);
+           vim_ignored = dup(fd_out[1]);
        else if (fd_err[1] < 0)
-           ignored = dup(pty_slave_fd);
+           vim_ignored = dup(pty_slave_fd);
        else
-           ignored = dup(fd_err[1]);
+           vim_ignored = dup(fd_err[1]);
 
        /* set up stdout for the child */
        close(1);
        if (use_null_for_out && null_fd >= 0)
-           ignored = dup(null_fd);
+           vim_ignored = dup(null_fd);
        else if (fd_out[1] < 0)
-           ignored = dup(pty_slave_fd);
+           vim_ignored = dup(pty_slave_fd);
        else
-           ignored = dup(fd_out[1]);
+           vim_ignored = dup(fd_out[1]);
 
        if (fd_in[0] >= 0)
            close(fd_in[0]);
index 9d36dec4a5e2b77cc0882170fca92508c5db7709..b665815f802ebf344edd0849aa6740146bf20219 100644 (file)
@@ -4388,7 +4388,8 @@ sub_process_writer(LPVOID param)
                    && (lnum != curbuf->b_ml.ml_line_count
                        || curbuf->b_p_eol)))
            {
-               WriteFile(g_hChildStd_IN_Wr, "\n", 1, (LPDWORD)&ignored, NULL);
+               WriteFile(g_hChildStd_IN_Wr, "\n", 1,
+                                                 (LPDWORD)&vim_ignored, NULL);
            }
 
            ++lnum;
index b2e2b0381c32cf6c329f70e5c2b676c2cd2f2dcb..a92f04ec3711863228b8374fa84ba671c7d27956 100644 (file)
@@ -7013,7 +7013,7 @@ gui_get_color_cmn(char_u *name)
                size_t  len;
                int     pos;
 
-               ignoredp = fgets(line, LINE_LEN, fd);
+               vim_ignoredp = fgets(line, LINE_LEN, fd);
                len = strlen(line);
 
                if (len <= 1 || line[len - 1] != '\n')
index 8e3f0deee1c1955938c7ae4726fce4b50c384c06..176562055c892428fe1425b808d232349a59f3a4 100644 (file)
--- a/src/ui.c
+++ b/src/ui.c
@@ -403,7 +403,7 @@ ui_breakcheck(void)
     void
 ui_breakcheck_force(int force)
 {
-    int save_us = updating_screen;
+    int save_updating_screen = updating_screen;
 
     /* We do not want gui_resize_shell() to redraw the screen here. */
     ++updating_screen;
@@ -415,8 +415,8 @@ ui_breakcheck_force(int force)
 #endif
        mch_breakcheck(force);
 
-    if (save_us)
-       updating_screen = save_us;
+    if (save_updating_screen)
+       updating_screen = TRUE;
     else
        reset_updating_screen(FALSE);
 }
@@ -1885,7 +1885,7 @@ fill_input_buf(int exit_on_error UNUSED)
 #ifdef HAVE_DUP
            /* Use stderr for stdin, also works for shell commands. */
            close(0);
-           ignored = dup(2);
+           vim_ignored = dup(2);
 #else
            read_cmd_fd = 2;    /* read from stderr instead of stdin */
 #endif
index 89a134bf8234685e5522247b8b69b3d1dcd5a458..18acc39b300f8481ef81c35373c92027ed0dd21c 100644 (file)
@@ -794,6 +794,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    377,
 /**/
     376,
 /**/
index 5671cf900e33c2ca7cf736b6a62878c1f83c5fd3..a481af8b95f89bd3965ebaf99c053ecda3e2d0f0 100644 (file)
@@ -4436,7 +4436,7 @@ win_enter_ext(
     {
        /* Window doesn't have a local directory and we are not in the global
         * directory: Change to the global directory. */
-       ignored = mch_chdir((char *)globaldir);
+       vim_ignored = mch_chdir((char *)globaldir);
        VIM_CLEAR(globaldir);
        shorten_fnames(TRUE);
     }
index 2356da5f784fbe5670b3f9e8bbc6d6419b4fa9d3..476b20c72c5446e0cf9523757eef3fb5d94a6c3a 100644 (file)
@@ -108,10 +108,11 @@ typedef struct s_bdiffparam {
        long bsize;
 } bdiffparam_t;
 
+#include "vim.h"
 
-#define xdl_malloc(x) malloc(x)
-#define xdl_free(ptr) free(ptr)
-#define xdl_realloc(ptr,x) realloc(ptr,x)
+#define xdl_malloc(x) lalloc((x), TRUE)
+#define xdl_free(ptr) vim_free(ptr)
+#define xdl_realloc(ptr,x) vim_realloc((ptr),(x))
 
 void *xdl_mmfile_first(mmfile_t *mmf, long *size);
 long xdl_mmfile_size(mmfile_t *mmf);
index 3dc90ae513382e090d5a3e3c53aa76fe33519f4e..96d5277027881c3fa11cd0cdb9a008dd2664d663 100644 (file)
@@ -392,9 +392,9 @@ static int recs_match(xrecord_t *rec1, xrecord_t *rec2, long flags)
 }
 
 /*
- * If a line is indented more than this, get_indent() just returns this value.
+ * If a line is indented more than this, xget_indent() just returns this value.
  * This avoids having to do absurd amounts of work for data that are not
- * human-readable text, and also ensures that the output of get_indent fits within
+ * human-readable text, and also ensures that the output of xget_indent fits within
  * an int.
  */
 #define MAX_INDENT 200
@@ -404,7 +404,7 @@ static int recs_match(xrecord_t *rec1, xrecord_t *rec2, long flags)
  * columns. Return -1 if line is empty or contains only whitespace. Clamp the
  * output value at MAX_INDENT.
  */
-static int get_indent(xrecord_t *rec)
+static int xget_indent(xrecord_t *rec)
 {
        long i;
        int ret = 0;
@@ -492,13 +492,13 @@ static void measure_split(const xdfile_t *xdf, long split,
                m->indent = -1;
        } else {
                m->end_of_file = 0;
-               m->indent = get_indent(xdf->recs[split]);
+               m->indent = xget_indent(xdf->recs[split]);
        }
 
        m->pre_blank = 0;
        m->pre_indent = -1;
        for (i = split - 1; i >= 0; i--) {
-               m->pre_indent = get_indent(xdf->recs[i]);
+               m->pre_indent = xget_indent(xdf->recs[i]);
                if (m->pre_indent != -1)
                        break;
                m->pre_blank += 1;
@@ -511,7 +511,7 @@ static void measure_split(const xdfile_t *xdf, long split,
        m->post_blank = 0;
        m->post_indent = -1;
        for (i = split + 1; i < xdf->nrec; i++) {
-               m->post_indent = get_indent(xdf->recs[i]);
+               m->post_indent = xget_indent(xdf->recs[i]);
                if (m->post_indent != -1)
                        break;
                m->post_blank += 1;
index 1052d10a38667d0f2a68ec001bb015fbe883ca47..c1871296af781e3a8c97133989b0b60a7c9e34ba 100644 (file)
@@ -210,6 +210,10 @@ static struct entry *find_longest_common_sequence(struct hashmap *map)
        int longest = 0, i;
        struct entry *entry;
 
+       /* Added to silence Coverity. */
+       if (sequence == NULL)
+               return map->first;
+
        /*
         * If not -1, this entry in sequence must never be overridden.
         * Therefore, overriding entries before this has no effect, so