diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-01-04 23:45:21 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-04 23:45:21 +0100 |
commit | 38b4ca26b555e5bdca4d672917a85f1bd60297c2 (patch) | |
tree | 5f12bdc1175aa05709e183d8a2f7a6b1b5793997 /src/nvim/diff.c | |
parent | 292b1790c8fd0c4ccf4dbff23d2cc5ed307dad08 (diff) | |
parent | 58538d121016d559e7988fa3d0ed21e07f60a2f6 (diff) | |
download | rneovim-38b4ca26b555e5bdca4d672917a85f1bd60297c2.tar.gz rneovim-38b4ca26b555e5bdca4d672917a85f1bd60297c2.tar.bz2 rneovim-38b4ca26b555e5bdca4d672917a85f1bd60297c2.zip |
Merge #9454 from justinmk/pvs-warnings
Diffstat (limited to 'src/nvim/diff.c')
-rw-r--r-- | src/nvim/diff.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 2e0b198c13..e0cd285667 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -695,7 +695,7 @@ static int diff_write_buffer(buf_T *buf, diffin_T *din) for (lnum = 1; lnum <= buf->b_ml.ml_line_count; lnum++) { len += (long)STRLEN(ml_get_buf(buf, lnum, false)) + 1; } - ptr = xmalloc(len); + ptr = try_malloc(len); if (ptr == NULL) { // Allocating memory failed. This can happen, because we try to read // the whole buffer text into memory. Set the failed flag, the diff @@ -1088,9 +1088,6 @@ static int diff_file(diffio_T *dio) const size_t len = (strlen(tmp_orig) + strlen(tmp_new) + strlen(tmp_diff) + STRLEN(p_srr) + 27); char *const cmd = xmalloc(len); - if (cmd == NULL) { - return FAIL; - } // We don't want $DIFF_OPTIONS to get in the way. if (os_getenv("DIFF_OPTIONS")) { @@ -1547,7 +1544,7 @@ static void diff_read(int idx_orig, int idx_new, diffout_T *dout) } else if ((STRNCMP(line, "--- ", 4) == 0) && (vim_fgets(linebuf, LBUFLEN, fd) == 0) && (STRNCMP(line, "+++ ", 4) == 0) - && (vim_fgets(linebuf, LBUFLEN, fd) == 0) + && (vim_fgets(linebuf, LBUFLEN, fd) == 0) // -V501 && (STRNCMP(line, "@@ ", 3) == 0)) { diffstyle = DIFF_UNIFIED; } else { @@ -1565,7 +1562,8 @@ static void diff_read(int idx_orig, int idx_new, diffout_T *dout) &lnum_new, &count_new) == FAIL) { continue; } - } else if (diffstyle == DIFF_UNIFIED) { + } else { + assert(diffstyle == DIFF_UNIFIED); if (STRNCMP(line, "@@ ", 3) != 0) { continue; // not the start of a diff block } @@ -1573,9 +1571,6 @@ static void diff_read(int idx_orig, int idx_new, diffout_T *dout) &lnum_new, &count_new) == FAIL) { continue; } - } else { - EMSG(_("E959: Invalid diff format.")); - break; } // Go over blocks before the change, for which orig and new are equal. |