Merge #9508 from justinmk/pvs-warnings

This commit is contained in:
Justin M. Keyes
2019-01-18 00:20:38 +01:00
committed by GitHub
8 changed files with 54 additions and 49 deletions

View File

@@ -1541,7 +1541,7 @@ static void diff_read(int idx_orig, int idx_new, diffout_T *dout)
diffstyle = DIFF_ED; diffstyle = DIFF_ED;
} else if ((STRNCMP(line, "@@ ", 3) == 0)) { } else if ((STRNCMP(line, "@@ ", 3) == 0)) {
diffstyle = DIFF_UNIFIED; diffstyle = DIFF_UNIFIED;
} else if ((STRNCMP(line, "--- ", 4) == 0) } else if ((STRNCMP(line, "--- ", 4) == 0) // -V501
&& (vim_fgets(linebuf, LBUFLEN, fd) == 0) // -V501 && (vim_fgets(linebuf, LBUFLEN, fd) == 0) // -V501
&& (STRNCMP(line, "+++ ", 4) == 0) && (STRNCMP(line, "+++ ", 4) == 0)
&& (vim_fgets(linebuf, LBUFLEN, fd) == 0) // -V501 && (vim_fgets(linebuf, LBUFLEN, fd) == 0) // -V501

View File

@@ -19902,13 +19902,15 @@ void ex_function(exarg_T *eap)
if (FUNCLINE(fp, j) == NULL) if (FUNCLINE(fp, j) == NULL)
continue; continue;
msg_putchar('\n'); msg_putchar('\n');
msg_outnum((long)(j + 1)); msg_outnum((long)j + 1);
if (j < 9) if (j < 9) {
msg_putchar(' '); msg_putchar(' ');
if (j < 99) }
if (j < 99) {
msg_putchar(' '); 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(); os_breakcheck();
} }
if (!got_int) { if (!got_int) {

View File

@@ -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; *num_matches = 0;
int flags = TAG_HELP | TAG_REGEXP | TAG_NAMES | TAG_VERBOSE; int flags = TAG_HELP | TAG_REGEXP | TAG_NAMES | TAG_VERBOSE;
if (keep_lang) { if (keep_lang) {

View File

@@ -9191,34 +9191,39 @@ static int ses_winsizes(FILE *fd, int restore_size, win_T *tab_firstwin)
if (restore_size && (ssop_flags & SSOP_WINSIZE)) { if (restore_size && (ssop_flags & SSOP_WINSIZE)) {
for (wp = tab_firstwin; wp != NULL; wp = wp->w_next) { for (wp = tab_firstwin; wp != NULL; wp = wp->w_next) {
if (!ses_do_win(wp)) if (!ses_do_win(wp)) {
continue; 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 if (wp->w_height + wp->w_status_height < topframe->fr_height
&& (fprintf(fd, && (fprintf(fd,
"exe '%dresize ' . ((&lines * %" PRId64 "exe '%dresize ' . ((&lines * %" PRId64
" + %" PRId64 ") / %" PRId64 ")", " + %" PRId64 ") / %" PRId64 ")",
n, (int64_t)wp->w_grid.Rows, n, (int64_t)wp->w_grid.Rows,
(int64_t)(Rows / 2), (int64_t)Rows) < 0 (int64_t)Rows / 2, (int64_t)Rows) < 0
|| put_eol(fd) == FAIL)) || put_eol(fd) == FAIL)) {
return FAIL;
/* 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),
(int64_t)Columns) < 0
|| put_eol(fd) == FAIL))
return FAIL; return FAIL;
} }
} else {
/* Just equalise window sizes */ // restore width when not full width
if (put_line(fd, "wincmd =") == FAIL) if (wp->w_width < Columns
&& (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)) {
return FAIL; return FAIL;
} }
}
} else {
// Just equalise window sizes
if (put_line(fd, "wincmd =") == FAIL) {
return FAIL;
}
}
return OK; return OK;
} }
@@ -9365,10 +9370,11 @@ put_view(
* arguments may have been deleted, check if the index is valid. */ * 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) if (wp->w_arg_idx != current_arg_idx && wp->w_arg_idx < WARGCOUNT(wp)
&& flagp == &ssop_flags) { && flagp == &ssop_flags) {
if (fprintf(fd, "%" PRId64 "argu", (int64_t)(wp->w_arg_idx + 1)) < 0 if (fprintf(fd, "%" PRId64 "argu", (int64_t)wp->w_arg_idx + 1) < 0
|| put_eol(fd) == FAIL) || put_eol(fd) == FAIL) {
return FAIL; return FAIL;
did_next = TRUE; }
did_next = true;
} }
/* Edit the file. Skip this when ":next" already did it. */ /* Edit the file. Skip this when ":next" already did it. */
@@ -9478,21 +9484,23 @@ put_view(
return FAIL; return FAIL;
} else { } else {
if (!wp->w_p_wrap && wp->w_leftcol > 0 && wp->w_width > 0) { if (!wp->w_p_wrap && wp->w_leftcol > 0 && wp->w_width > 0) {
if (fprintf(fd, "let s:c = %" PRId64 " - ((%" PRId64 if (fprintf(fd,
"let s:c = %" PRId64 " - ((%" PRId64
" * winwidth(0) + %" PRId64 ") / %" PRId64 ")", " * winwidth(0) + %" PRId64 ") / %" PRId64 ")",
(int64_t)(wp->w_virtcol + 1), (int64_t)wp->w_virtcol + 1,
(int64_t)(wp->w_virtcol - wp->w_leftcol), (int64_t)(wp->w_virtcol - wp->w_leftcol),
(int64_t)(wp->w_width / 2), (int64_t)(wp->w_width / 2),
(int64_t)wp->w_width) < 0 (int64_t)wp->w_width) < 0
|| put_eol(fd) == FAIL || put_eol(fd) == FAIL
|| put_line(fd, "if s:c > 0") == FAIL || put_line(fd, "if s:c > 0") == FAIL
|| fprintf(fd, " exe 'normal! ' . s:c . '|zs' . %" PRId64 " . '|'", || 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_eol(fd) == FAIL
|| put_line(fd, "else") == FAIL || put_line(fd, "else") == FAIL
|| put_view_curpos(fd, wp, " ") == FAIL || put_view_curpos(fd, wp, " ") == FAIL
|| put_line(fd, "endif") == FAIL) || put_line(fd, "endif") == FAIL) {
return FAIL; return FAIL;
}
} else if (put_view_curpos(fd, wp, "") == FAIL) { } else if (put_view_curpos(fd, wp, "") == FAIL) {
return FAIL; return FAIL;
} }

View File

@@ -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) static void cmdline_del(int from)
{ {
memmove(ccline.cmdbuff + from, ccline.cmdbuff + ccline.cmdpos, 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.cmdlen -= ccline.cmdpos - from;
ccline.cmdpos = from; ccline.cmdpos = from;
} }
@@ -3662,7 +3659,7 @@ nextwild (
} }
memmove(&ccline.cmdbuff[ccline.cmdpos + difflen], memmove(&ccline.cmdbuff[ccline.cmdpos + difflen],
&ccline.cmdbuff[ccline.cmdpos], &ccline.cmdbuff[ccline.cmdpos],
(size_t)(ccline.cmdlen - ccline.cmdpos + 1)); (size_t)ccline.cmdlen - ccline.cmdpos + 1);
memmove(&ccline.cmdbuff[i], p2, STRLEN(p2)); memmove(&ccline.cmdbuff[i], p2, STRLEN(p2));
ccline.cmdlen += difflen; ccline.cmdlen += difflen;
ccline.cmdpos += difflen; ccline.cmdpos += difflen;
@@ -4705,7 +4702,7 @@ ExpandFromContext (
return ret; return ret;
} }
*file = (char_u **)""; *file = NULL;
*num_file = 0; *num_file = 0;
if (xp->xp_context == EXPAND_HELP) { if (xp->xp_context == EXPAND_HELP) {
/* With an empty argument we would get all the help tags, which is /* With an empty argument we would get all the help tags, which is

View File

@@ -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 top_bot_msg[] INIT(= N_("search hit TOP, continuing at BOTTOM"));
EXTERN char bot_top_msg[] INIT(= N_("search hit BOTTOM, continuing at TOP")); 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 time_t starttime;
EXTERN FILE *time_fd INIT(= NULL); /* where to write startup timing */ 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
* 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
* can't do anything useful with the value. Assign to this variable to avoid // the warning.
* the warning.
*/
EXTERN int vim_ignored; EXTERN int vim_ignored;
// Start a msgpack-rpc channel over stdin/stdout. // Start a msgpack-rpc channel over stdin/stdout.

View File

@@ -3284,11 +3284,11 @@ void clear_showcmd(void)
p_sbr = empty_option; p_sbr = empty_option;
getvcols(curwin, &curwin->w_cursor, &VIsual, &leftcol, &rightcol); getvcols(curwin, &curwin->w_cursor, &VIsual, &leftcol, &rightcol);
p_sbr = saved_sbr; p_sbr = saved_sbr;
sprintf((char *)showcmd_buf, "%" PRId64 "x%" PRId64, snprintf((char *)showcmd_buf, SHOWCMD_BUFLEN, "%" PRId64 "x%" PRId64,
(int64_t)lines, (int64_t)(rightcol - leftcol + 1)); (int64_t)lines, (int64_t)rightcol - leftcol + 1);
} else if (VIsual_mode == 'V' || VIsual.lnum != curwin->w_cursor.lnum) } else if (VIsual_mode == 'V' || VIsual.lnum != curwin->w_cursor.lnum) {
sprintf((char *)showcmd_buf, "%" PRId64, (int64_t)lines); snprintf((char *)showcmd_buf, SHOWCMD_BUFLEN, "%" PRId64, (int64_t)lines);
else { } else {
char_u *s, *e; char_u *s, *e;
int l; int l;
int bytes = 0; int bytes = 0;
@@ -4930,10 +4930,10 @@ get_visual_text (
} else { } else {
if (lt(curwin->w_cursor, VIsual)) { if (lt(curwin->w_cursor, VIsual)) {
*pp = ml_get_pos(&curwin->w_cursor); *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 { } else {
*pp = ml_get_pos(&VIsual); *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) if (has_mbyte)
/* Correct the length to include the whole last character. */ /* Correct the length to include the whole last character. */

View File

@@ -1267,7 +1267,7 @@ int gen_expand_wildcards(int num_pat, char_u **pat, int *num_file,
} }
*num_file = ga.ga_len; *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; recursive = false;