aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2019-01-18 00:20:38 +0100
committerGitHub <noreply@github.com>2019-01-18 00:20:38 +0100
commit8f9fc1f692292efe63b9e71bb6f6340bccf2b37f (patch)
treecaafab85917d2ce0de1289d67704648ee2345938
parent8093cbd8e8ca06ce5c9d8814fc6d94cb2304133a (diff)
parentaa39fc56f68e2087a2327bcd03cc5f3d2dc9a696 (diff)
downloadrneovim-8f9fc1f692292efe63b9e71bb6f6340bccf2b37f.tar.gz
rneovim-8f9fc1f692292efe63b9e71bb6f6340bccf2b37f.tar.bz2
rneovim-8f9fc1f692292efe63b9e71bb6f6340bccf2b37f.zip
Merge #9508 from justinmk/pvs-warnings
-rw-r--r--src/nvim/diff.c2
-rw-r--r--src/nvim/eval.c12
-rw-r--r--src/nvim/ex_cmds.c2
-rw-r--r--src/nvim/ex_docmd.c48
-rw-r--r--src/nvim/ex_getln.c13
-rw-r--r--src/nvim/globals.h10
-rw-r--r--src/nvim/normal.c14
-rw-r--r--src/nvim/path.c2
8 files changed, 54 insertions, 49 deletions
diff --git a/src/nvim/diff.c b/src/nvim/diff.c
index 866161e5cf..ee4a48ff5d 100644
--- a/src/nvim/diff.c
+++ b/src/nvim/diff.c
@@ -1541,7 +1541,7 @@ static void diff_read(int idx_orig, int idx_new, diffout_T *dout)
diffstyle = DIFF_ED;
} else if ((STRNCMP(line, "@@ ", 3) == 0)) {
diffstyle = DIFF_UNIFIED;
- } else if ((STRNCMP(line, "--- ", 4) == 0)
+ } else if ((STRNCMP(line, "--- ", 4) == 0) // -V501
&& (vim_fgets(linebuf, LBUFLEN, fd) == 0) // -V501
&& (STRNCMP(line, "+++ ", 4) == 0)
&& (vim_fgets(linebuf, LBUFLEN, fd) == 0) // -V501
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 4cf8a01ddb..85b838e443 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -19902,13 +19902,15 @@ void ex_function(exarg_T *eap)
if (FUNCLINE(fp, j) == NULL)
continue;
msg_putchar('\n');
- msg_outnum((long)(j + 1));
- if (j < 9)
+ msg_outnum((long)j + 1);
+ if (j < 9) {
msg_putchar(' ');
- if (j < 99)
+ }
+ if (j < 99) {
msg_putchar(' ');
- msg_prt_line(FUNCLINE(fp, j), FALSE);
- ui_flush(); /* show a line at a time */
+ }
+ msg_prt_line(FUNCLINE(fp, j), false);
+ ui_flush(); // show a line at a time
os_breakcheck();
}
if (!got_int) {
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index 85844c37bd..c574ac10e9 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -4895,7 +4895,7 @@ int find_help_tags(const char_u *arg, int *num_matches, char_u ***matches,
}
}
- *matches = (char_u **)"";
+ *matches = NULL;
*num_matches = 0;
int flags = TAG_HELP | TAG_REGEXP | TAG_NAMES | TAG_VERBOSE;
if (keep_lang) {
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index f5c16d883a..ae618bfc61 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -9191,33 +9191,38 @@ static int ses_winsizes(FILE *fd, int restore_size, win_T *tab_firstwin)
if (restore_size && (ssop_flags & SSOP_WINSIZE)) {
for (wp = tab_firstwin; wp != NULL; wp = wp->w_next) {
- if (!ses_do_win(wp))
+ if (!ses_do_win(wp)) {
continue;
- ++n;
+ }
+ n++;
- /* restore height when not full height */
+ // restore height when not full height
if (wp->w_height + wp->w_status_height < topframe->fr_height
&& (fprintf(fd,
"exe '%dresize ' . ((&lines * %" PRId64
" + %" PRId64 ") / %" PRId64 ")",
n, (int64_t)wp->w_grid.Rows,
- (int64_t)(Rows / 2), (int64_t)Rows) < 0
- || put_eol(fd) == FAIL))
+ (int64_t)Rows / 2, (int64_t)Rows) < 0
+ || put_eol(fd) == FAIL)) {
return FAIL;
+ }
- /* restore width when not full width */
+ // restore width when not full width
if (wp->w_width < Columns
- && (fprintf(fd, "exe 'vert %dresize ' . ((&columns * %" PRId64
- " + %" PRId64 ") / %" PRId64 ")",
- n, (int64_t)wp->w_width, (int64_t)(Columns / 2),
+ && (fprintf(fd,
+ "exe 'vert %dresize ' . ((&columns * %" PRId64
+ " + %" PRId64 ") / %" PRId64 ")",
+ n, (int64_t)wp->w_width, (int64_t)Columns / 2,
(int64_t)Columns) < 0
- || put_eol(fd) == FAIL))
+ || put_eol(fd) == FAIL)) {
return FAIL;
+ }
}
} else {
- /* Just equalise window sizes */
- if (put_line(fd, "wincmd =") == FAIL)
+ // Just equalise window sizes
+ if (put_line(fd, "wincmd =") == FAIL) {
return FAIL;
+ }
}
return OK;
}
@@ -9365,10 +9370,11 @@ put_view(
* arguments may have been deleted, check if the index is valid. */
if (wp->w_arg_idx != current_arg_idx && wp->w_arg_idx < WARGCOUNT(wp)
&& flagp == &ssop_flags) {
- if (fprintf(fd, "%" PRId64 "argu", (int64_t)(wp->w_arg_idx + 1)) < 0
- || put_eol(fd) == FAIL)
+ if (fprintf(fd, "%" PRId64 "argu", (int64_t)wp->w_arg_idx + 1) < 0
+ || put_eol(fd) == FAIL) {
return FAIL;
- did_next = TRUE;
+ }
+ did_next = true;
}
/* Edit the file. Skip this when ":next" already did it. */
@@ -9478,21 +9484,23 @@ put_view(
return FAIL;
} else {
if (!wp->w_p_wrap && wp->w_leftcol > 0 && wp->w_width > 0) {
- if (fprintf(fd, "let s:c = %" PRId64 " - ((%" PRId64
- " * winwidth(0) + %" PRId64 ") / %" PRId64 ")",
- (int64_t)(wp->w_virtcol + 1),
+ if (fprintf(fd,
+ "let s:c = %" PRId64 " - ((%" PRId64
+ " * winwidth(0) + %" PRId64 ") / %" PRId64 ")",
+ (int64_t)wp->w_virtcol + 1,
(int64_t)(wp->w_virtcol - wp->w_leftcol),
(int64_t)(wp->w_width / 2),
(int64_t)wp->w_width) < 0
|| put_eol(fd) == FAIL
|| put_line(fd, "if s:c > 0") == FAIL
|| fprintf(fd, " exe 'normal! ' . s:c . '|zs' . %" PRId64 " . '|'",
- (int64_t)(wp->w_virtcol + 1)) < 0
+ (int64_t)wp->w_virtcol + 1) < 0
|| put_eol(fd) == FAIL
|| put_line(fd, "else") == FAIL
|| put_view_curpos(fd, wp, " ") == FAIL
- || put_line(fd, "endif") == FAIL)
+ || put_line(fd, "endif") == FAIL) {
return FAIL;
+ }
} else if (put_view_curpos(fd, wp, "") == FAIL) {
return FAIL;
}
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 8efb027575..786769dc7d 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -3393,14 +3393,11 @@ void cmdline_paste_str(char_u *s, int literally)
}
}
-/*
- * Delete characters on the command line, from "from" to the current
- * position.
- */
+/// Delete characters on the command line, from "from" to the current position.
static void cmdline_del(int from)
{
memmove(ccline.cmdbuff + from, ccline.cmdbuff + ccline.cmdpos,
- (size_t)(ccline.cmdlen - ccline.cmdpos + 1));
+ (size_t)ccline.cmdlen - ccline.cmdpos + 1);
ccline.cmdlen -= ccline.cmdpos - from;
ccline.cmdpos = from;
}
@@ -3661,8 +3658,8 @@ nextwild (
xp->xp_pattern = ccline.cmdbuff + i;
}
memmove(&ccline.cmdbuff[ccline.cmdpos + difflen],
- &ccline.cmdbuff[ccline.cmdpos],
- (size_t)(ccline.cmdlen - ccline.cmdpos + 1));
+ &ccline.cmdbuff[ccline.cmdpos],
+ (size_t)ccline.cmdlen - ccline.cmdpos + 1);
memmove(&ccline.cmdbuff[i], p2, STRLEN(p2));
ccline.cmdlen += difflen;
ccline.cmdpos += difflen;
@@ -4705,7 +4702,7 @@ ExpandFromContext (
return ret;
}
- *file = (char_u **)"";
+ *file = NULL;
*num_file = 0;
if (xp->xp_context == EXPAND_HELP) {
/* With an empty argument we would get all the help tags, which is
diff --git a/src/nvim/globals.h b/src/nvim/globals.h
index 2550fb8163..cc39e2c112 100644
--- a/src/nvim/globals.h
+++ b/src/nvim/globals.h
@@ -1072,16 +1072,14 @@ EXTERN char_u e_cmdmap_key[] INIT(=N_(
EXTERN char top_bot_msg[] INIT(= N_("search hit TOP, continuing at BOTTOM"));
EXTERN char bot_top_msg[] INIT(= N_("search hit BOTTOM, continuing at TOP"));
-/* For undo we need to know the lowest time possible. */
+// For undo we need to know the lowest time possible.
EXTERN time_t starttime;
EXTERN FILE *time_fd INIT(= NULL); /* where to write startup timing */
-/*
- * Some compilers warn for not using a return value, but in some situations we
- * can't do anything useful with the value. Assign to this variable to avoid
- * the warning.
- */
+// Some compilers warn for not using a return value, but in some situations we
+// can't do anything useful with the value. Assign to this variable to avoid
+// the warning.
EXTERN int vim_ignored;
// Start a msgpack-rpc channel over stdin/stdout.
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index 0e3946740a..0dc5f3175d 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -3284,11 +3284,11 @@ void clear_showcmd(void)
p_sbr = empty_option;
getvcols(curwin, &curwin->w_cursor, &VIsual, &leftcol, &rightcol);
p_sbr = saved_sbr;
- sprintf((char *)showcmd_buf, "%" PRId64 "x%" PRId64,
- (int64_t)lines, (int64_t)(rightcol - leftcol + 1));
- } else if (VIsual_mode == 'V' || VIsual.lnum != curwin->w_cursor.lnum)
- sprintf((char *)showcmd_buf, "%" PRId64, (int64_t)lines);
- else {
+ snprintf((char *)showcmd_buf, SHOWCMD_BUFLEN, "%" PRId64 "x%" PRId64,
+ (int64_t)lines, (int64_t)rightcol - leftcol + 1);
+ } else if (VIsual_mode == 'V' || VIsual.lnum != curwin->w_cursor.lnum) {
+ snprintf((char *)showcmd_buf, SHOWCMD_BUFLEN, "%" PRId64, (int64_t)lines);
+ } else {
char_u *s, *e;
int l;
int bytes = 0;
@@ -4930,10 +4930,10 @@ get_visual_text (
} else {
if (lt(curwin->w_cursor, VIsual)) {
*pp = ml_get_pos(&curwin->w_cursor);
- *lenp = (size_t)(VIsual.col - curwin->w_cursor.col + 1);
+ *lenp = (size_t)VIsual.col - (size_t)curwin->w_cursor.col + 1;
} else {
*pp = ml_get_pos(&VIsual);
- *lenp = (size_t)(curwin->w_cursor.col - VIsual.col + 1);
+ *lenp = (size_t)curwin->w_cursor.col - (size_t)VIsual.col + 1;
}
if (has_mbyte)
/* Correct the length to include the whole last character. */
diff --git a/src/nvim/path.c b/src/nvim/path.c
index de697642c7..03de914e4f 100644
--- a/src/nvim/path.c
+++ b/src/nvim/path.c
@@ -1267,7 +1267,7 @@ int gen_expand_wildcards(int num_pat, char_u **pat, int *num_file,
}
*num_file = ga.ga_len;
- *file = (ga.ga_data != NULL) ? (char_u **)ga.ga_data : (char_u **)"";
+ *file = (ga.ga_data != NULL) ? (char_u **)ga.ga_data : NULL;
recursive = false;