patch 7.4.822

Problem:    More problems reported by coverity.
Solution:   Avoid the warnings. (Christian Brabandt)
This commit is contained in:
Bram Moolenaar
2015-08-11 19:14:00 +02:00
parent bd8539aac3
commit cde8854730
18 changed files with 46 additions and 45 deletions

View File

@@ -6736,7 +6736,7 @@ list_join_inner(gap, l, sep, echo_style, copyID, join_gap)
len = (int)STRLEN(s); len = (int)STRLEN(s);
sumlen += len; sumlen += len;
ga_grow(join_gap, 1); (void)ga_grow(join_gap, 1);
p = ((join_T *)join_gap->ga_data) + (join_gap->ga_len++); p = ((join_T *)join_gap->ga_data) + (join_gap->ga_len++);
if (tofree != NULL || s != numbuf) if (tofree != NULL || s != numbuf)
{ {
@@ -19590,7 +19590,7 @@ error:
goto error; goto error;
} }
ga_grow(&ga, cplen); (void)ga_grow(&ga, cplen);
mch_memmove((char *)ga.ga_data + ga.ga_len, cpstr, (size_t)cplen); mch_memmove((char *)ga.ga_data + ga.ga_len, cpstr, (size_t)cplen);
ga.ga_len += cplen; ga.ga_len += cplen;
@@ -19610,7 +19610,7 @@ error:
} }
/* add a terminating NUL */ /* add a terminating NUL */
ga_grow(&ga, 1); (void)ga_grow(&ga, 1);
ga_append(&ga, NUL); ga_append(&ga, NUL);
rettv->vval.v_string = ga.ga_data; rettv->vval.v_string = ga.ga_data;

View File

@@ -6856,7 +6856,8 @@ helptags_one(dir, ext, tagfname, add_help_tags)
/* /*
* Sort the tags. * Sort the tags.
*/ */
sort_strings((char_u **)ga.ga_data, ga.ga_len); if (ga.ga_data != NULL)
sort_strings((char_u **)ga.ga_data, ga.ga_len);
/* /*
* Check for duplicates. * Check for duplicates.

View File

@@ -3051,7 +3051,7 @@ fopen_noinh_readbin(filename)
{ {
int fdflags = fcntl(fd_tmp, F_GETFD); int fdflags = fcntl(fd_tmp, F_GETFD);
if (fdflags >= 0 && (fdflags & FD_CLOEXEC) == 0) if (fdflags >= 0 && (fdflags & FD_CLOEXEC) == 0)
fcntl(fd_tmp, F_SETFD, fdflags | FD_CLOEXEC); (void)fcntl(fd_tmp, F_SETFD, fdflags | FD_CLOEXEC);
} }
# endif # endif
@@ -3841,7 +3841,7 @@ script_line_start()
{ {
/* Grow the array before starting the timer, so that the time spent /* Grow the array before starting the timer, so that the time spent
* here isn't counted. */ * here isn't counted. */
ga_grow(&si->sn_prl_ga, (int)(sourcing_lnum - si->sn_prl_ga.ga_len)); (void)ga_grow(&si->sn_prl_ga, (int)(sourcing_lnum - si->sn_prl_ga.ga_len));
si->sn_prl_idx = sourcing_lnum - 1; si->sn_prl_idx = sourcing_lnum - 1;
while (si->sn_prl_ga.ga_len <= si->sn_prl_idx while (si->sn_prl_ga.ga_len <= si->sn_prl_idx
&& si->sn_prl_ga.ga_len < si->sn_prl_ga.ga_maxlen) && si->sn_prl_ga.ga_len < si->sn_prl_ga.ga_maxlen)

View File

@@ -2312,7 +2312,7 @@ getexmodeline(promptc, cookie, indent)
add_indent: add_indent:
while (get_indent_str(p, 8, FALSE) < indent) while (get_indent_str(p, 8, FALSE) < indent)
{ {
ga_grow(&line_ga, 2); /* one more for the NUL */ (void)ga_grow(&line_ga, 2); /* one more for the NUL */
p = (char_u *)line_ga.ga_data; p = (char_u *)line_ga.ga_data;
s = skipwhite(p); s = skipwhite(p);
mch_memmove(s + 1, s, line_ga.ga_len - (s - p) + 1); mch_memmove(s + 1, s, line_ga.ga_len - (s - p) + 1);

View File

@@ -2446,7 +2446,7 @@ foldUpdateIEMSRecurse(gap, level, startlnum, flp, getlevel, bot, topflags)
if (getlevel == foldlevelMarker && flp->start <= flp->lvl - level if (getlevel == foldlevelMarker && flp->start <= flp->lvl - level
&& flp->lvl > 0) && flp->lvl > 0)
{ {
foldFind(gap, startlnum - 1, &fp); (void)foldFind(gap, startlnum - 1, &fp);
if (fp >= ((fold_T *)gap->ga_data) + gap->ga_len if (fp >= ((fold_T *)gap->ga_data) + gap->ga_len
|| fp->fd_top >= startlnum) || fp->fd_top >= startlnum)
fp = NULL; fp = NULL;
@@ -2508,7 +2508,7 @@ foldUpdateIEMSRecurse(gap, level, startlnum, flp, getlevel, bot, topflags)
} }
if (lvl < level + i) if (lvl < level + i)
{ {
foldFind(&fp->fd_nested, flp->lnum - fp->fd_top, &fp2); (void)foldFind(&fp->fd_nested, flp->lnum - fp->fd_top, &fp2);
if (fp2 != NULL) if (fp2 != NULL)
bot = fp2->fd_top + fp2->fd_len - 1 + fp->fd_top; bot = fp2->fd_top + fp2->fd_len - 1 + fp->fd_top;
} }

View File

@@ -1575,7 +1575,7 @@ gui_set_shellsize(mustset, fit_to_display, direction)
base_height = gui_get_base_height(); base_height = gui_get_base_height();
if (fit_to_display) if (fit_to_display)
/* Remember the original window position. */ /* Remember the original window position. */
gui_mch_get_winpos(&x, &y); (void)gui_mch_get_winpos(&x, &y);
#ifdef USE_SUN_WORKSHOP #ifdef USE_SUN_WORKSHOP
if (!mustset && usingSunWorkShop if (!mustset && usingSunWorkShop
@@ -5366,7 +5366,7 @@ gui_do_findrepl(flags, find_text, repl_text, down)
{ {
/* Search for the next match. */ /* Search for the next match. */
i = msg_scroll; i = msg_scroll;
do_search(NULL, down ? '/' : '?', ga.ga_data, 1L, (void)do_search(NULL, down ? '/' : '?', ga.ga_data, 1L,
SEARCH_MSG + SEARCH_MARK, NULL); SEARCH_MSG + SEARCH_MARK, NULL);
msg_scroll = i; /* don't let an error message set msg_scroll */ msg_scroll = i; /* don't let an error message set msg_scroll */
} }

View File

@@ -282,7 +282,7 @@ _WndProc(
result = MyWindowProc(hwnd, uMsg, wParam, lParam); result = MyWindowProc(hwnd, uMsg, wParam, lParam);
if (result == HTCLIENT) if (result == HTCLIENT)
{ {
gui_mch_get_winpos(&x, &y); (void)gui_mch_get_winpos(&x, &y);
xPos -= x; xPos -= x;
if (xPos < 48) /*<VN> TODO should use system metric?*/ if (xPos < 48) /*<VN> TODO should use system metric?*/

View File

@@ -17,7 +17,7 @@
* scrollbars, etc. * scrollbars, etc.
* *
* Note: Clipboard stuff, for cutting and pasting text to other windows, is in * Note: Clipboard stuff, for cutting and pasting text to other windows, is in
* os_win32.c. (It can also be done from the terminal version). * winclip.c. (It can also be done from the terminal version).
* *
* TODO: Some of the function signatures ought to be updated for Win64; * TODO: Some of the function signatures ought to be updated for Win64;
* e.g., replace LONG with LONG_PTR, etc. * e.g., replace LONG with LONG_PTR, etc.
@@ -76,7 +76,7 @@ gui_mch_set_rendering_options(char_u *s)
char_u name[128]; char_u name[128];
char_u value[128]; char_u value[128];
copy_option_part(&p, item, sizeof(item), ","); copy_option_part(&p, item, sizeof(item), ",");
if (p == NULL) if (p == NULL)
break; break;
q = &item[0]; q = &item[0];
@@ -1227,7 +1227,7 @@ _WndProc(
return result; return result;
} }
#endif #endif
gui_mch_get_winpos(&x, &y); (void)gui_mch_get_winpos(&x, &y);
xPos -= x; xPos -= x;
if (xPos < 48) /* <VN> TODO should use system metric? */ if (xPos < 48) /* <VN> TODO should use system metric? */

View File

@@ -1076,8 +1076,8 @@ err_closing:
/* /*
* PRIVATE: cs_find * PRIVATE: cs_find
* *
* query cscope using command line interface. parse the output and use tselect * Query cscope using command line interface. Parse the output and use tselect
* to allow choices. like Nvi, creates a pipe to send to/from query/cscope. * to allow choices. Like Nvi, creates a pipe to send to/from query/cscope.
* *
* returns TRUE if we jump to a tag or abort, FALSE if not. * returns TRUE if we jump to a tag or abort, FALSE if not.
*/ */
@@ -1214,7 +1214,10 @@ cs_find_common(opt, pat, forceit, verbose, use_ll, cmdline)
nummatches = (int *)alloc(sizeof(int)*csinfo_size); nummatches = (int *)alloc(sizeof(int)*csinfo_size);
if (nummatches == NULL) if (nummatches == NULL)
{
vim_free(cmd);
return FALSE; return FALSE;
}
/* Send query to all open connections, then count the total number /* Send query to all open connections, then count the total number
* of matches so we can alloc all in one swell foop. */ * of matches so we can alloc all in one swell foop. */
@@ -1289,7 +1292,7 @@ cs_find_common(opt, pat, forceit, verbose, use_ll, cmdline)
# ifdef FEAT_WINDOWS # ifdef FEAT_WINDOWS
if (postponed_split != 0) if (postponed_split != 0)
{ {
win_split(postponed_split > 0 ? postponed_split : 0, (void)win_split(postponed_split > 0 ? postponed_split : 0,
postponed_split_flags); postponed_split_flags);
RESET_BINDING(curwin); RESET_BINDING(curwin);
postponed_split = 0; postponed_split = 0;
@@ -2085,6 +2088,8 @@ cs_print_tags_priv(matches, cntxts, num_matches)
strcpy(tbuf, matches[0]); strcpy(tbuf, matches[0]);
ptag = strtok(tbuf, "\t"); ptag = strtok(tbuf, "\t");
if (ptag == NULL)
return;
newsize = (int)(strlen(cstag_msg) + strlen(ptag)); newsize = (int)(strlen(cstag_msg) + strlen(ptag));
buf = (char *)alloc(newsize); buf = (char *)alloc(newsize);

View File

@@ -1265,12 +1265,12 @@ serverEventProc(dpy, eventPtr)
/* Initialize the result property. */ /* Initialize the result property. */
ga_init2(&reply, 1, 100); ga_init2(&reply, 1, 100);
#ifdef FEAT_MBYTE #ifdef FEAT_MBYTE
ga_grow(&reply, 50 + STRLEN(p_enc)); (void)ga_grow(&reply, 50 + STRLEN(p_enc));
sprintf(reply.ga_data, "%cr%c-E %s%c-s %s%c-r ", sprintf(reply.ga_data, "%cr%c-E %s%c-s %s%c-r ",
0, 0, p_enc, 0, serial, 0); 0, 0, p_enc, 0, serial, 0);
reply.ga_len = 14 + STRLEN(p_enc) + STRLEN(serial); reply.ga_len = 14 + STRLEN(p_enc) + STRLEN(serial);
#else #else
ga_grow(&reply, 50); (void)ga_grow(&reply, 50);
sprintf(reply.ga_data, "%cr%c-s %s%c-r ", sprintf(reply.ga_data, "%cr%c-s %s%c-r ",
0, 0, serial, 0); 0, 0, serial, 0);
reply.ga_len = 10 + STRLEN(serial); reply.ga_len = 10 + STRLEN(serial);
@@ -1351,15 +1351,10 @@ serverEventProc(dpy, eventPtr)
continue; continue;
pcPtr->code = code; pcPtr->code = code;
if (res != NULL) res = serverConvert(enc, res, &tofree);
{ if (tofree == NULL)
res = serverConvert(enc, res, &tofree); res = vim_strsave(res);
if (tofree == NULL) pcPtr->result = res;
res = vim_strsave(res);
pcPtr->result = res;
}
else
pcPtr->result = vim_strsave((char_u *)"");
break; break;
} }
} }

View File

@@ -1512,7 +1512,7 @@ scrolldown_clamp()
--curwin->w_topline; --curwin->w_topline;
#endif #endif
#ifdef FEAT_FOLDING #ifdef FEAT_FOLDING
hasFolding(curwin->w_topline, &curwin->w_topline, NULL); (void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL);
#endif #endif
--curwin->w_botline; /* approximate w_botline */ --curwin->w_botline; /* approximate w_botline */
curwin->w_valid &= ~(VALID_WROW|VALID_CROW|VALID_BOTLINE); curwin->w_valid &= ~(VALID_WROW|VALID_CROW|VALID_BOTLINE);

View File

@@ -2865,10 +2865,8 @@ do_mouse(oap, c, dir, count, fixindent)
end_visual.col = leftcol; end_visual.col = leftcol;
else else
end_visual.col = rightcol; end_visual.col = rightcol;
if (curwin->w_cursor.lnum < if (curwin->w_cursor.lnum >=
(start_visual.lnum + end_visual.lnum) / 2) (start_visual.lnum + end_visual.lnum) / 2)
end_visual.lnum = end_visual.lnum;
else
end_visual.lnum = start_visual.lnum; end_visual.lnum = start_visual.lnum;
/* move VIsual to the right column */ /* move VIsual to the right column */
@@ -3807,8 +3805,8 @@ clear_showcmd()
} }
# ifdef FEAT_FOLDING # ifdef FEAT_FOLDING
/* Include closed folds as a whole. */ /* Include closed folds as a whole. */
hasFolding(top, &top, NULL); (void)hasFolding(top, &top, NULL);
hasFolding(bot, NULL, &bot); (void)hasFolding(bot, NULL, &bot);
# endif # endif
lines = bot - top + 1; lines = bot - top + 1;
@@ -5954,7 +5952,7 @@ nv_scroll(cap)
lnum = curwin->w_topline; lnum = curwin->w_topline;
while (n-- > 0 && lnum < curwin->w_botline - 1) while (n-- > 0 && lnum < curwin->w_botline - 1)
{ {
hasFolding(lnum, NULL, &lnum); (void)hasFolding(lnum, NULL, &lnum);
++lnum; ++lnum;
} }
n = lnum - curwin->w_topline; n = lnum - curwin->w_topline;
@@ -6254,7 +6252,7 @@ nv_gotofile(cap)
{ {
/* do autowrite if necessary */ /* do autowrite if necessary */
if (curbufIsChanged() && curbuf->b_nwindows <= 1 && !P_HID(curbuf)) if (curbufIsChanged() && curbuf->b_nwindows <= 1 && !P_HID(curbuf))
autowrite(curbuf, FALSE); (void)autowrite(curbuf, FALSE);
setpcmark(); setpcmark();
(void)do_ecmd(0, ptr, NULL, NULL, ECMD_LAST, (void)do_ecmd(0, ptr, NULL, NULL, ECMD_LAST,
P_HID(curbuf) ? ECMD_HIDE : 0, curwin); P_HID(curbuf) ? ECMD_HIDE : 0, curwin);

View File

@@ -7001,7 +7001,7 @@ do_xterm_trace()
/* Rely on the same mouse code for the duration of this */ /* Rely on the same mouse code for the duration of this */
mouse_code = find_termcode(mouse_name); mouse_code = find_termcode(mouse_name);
prev_row = mouse_row; prev_row = mouse_row;
prev_row = mouse_col; prev_col = mouse_col;
xterm_trace = 2; xterm_trace = 2;
/* Find the offset of the chars, there might be a scrollbar on the /* Find the offset of the chars, there might be a scrollbar on the

View File

@@ -3824,14 +3824,14 @@ bt_regexec_both(line, col, tm)
/* Use an item size of 1 byte, since we push different things /* Use an item size of 1 byte, since we push different things
* onto the regstack. */ * onto the regstack. */
ga_init2(&regstack, 1, REGSTACK_INITIAL); ga_init2(&regstack, 1, REGSTACK_INITIAL);
ga_grow(&regstack, REGSTACK_INITIAL); (void)ga_grow(&regstack, REGSTACK_INITIAL);
regstack.ga_growsize = REGSTACK_INITIAL * 8; regstack.ga_growsize = REGSTACK_INITIAL * 8;
} }
if (backpos.ga_data == NULL) if (backpos.ga_data == NULL)
{ {
ga_init2(&backpos, sizeof(backpos_T), BACKPOS_INITIAL); ga_init2(&backpos, sizeof(backpos_T), BACKPOS_INITIAL);
ga_grow(&backpos, BACKPOS_INITIAL); (void)ga_grow(&backpos, BACKPOS_INITIAL);
backpos.ga_growsize = BACKPOS_INITIAL * 8; backpos.ga_growsize = BACKPOS_INITIAL * 8;
} }

View File

@@ -6670,7 +6670,7 @@ syntime_report()
spp = &(SYN_ITEMS(curwin->w_s)[idx]); spp = &(SYN_ITEMS(curwin->w_s)[idx]);
if (spp->sp_time.count > 0) if (spp->sp_time.count > 0)
{ {
ga_grow(&ga, 1); (void)ga_grow(&ga, 1);
p = ((time_entry_T *)ga.ga_data) + ga.ga_len; p = ((time_entry_T *)ga.ga_data) + ga.ga_len;
p->total = spp->sp_time.total; p->total = spp->sp_time.total;
profile_add(&total_total, &spp->sp_time.total); profile_add(&total_total, &spp->sp_time.total);

View File

@@ -2903,7 +2903,7 @@ retnomove:
break; break;
first = FALSE; first = FALSE;
#ifdef FEAT_FOLDING #ifdef FEAT_FOLDING
hasFolding(curwin->w_topline, &curwin->w_topline, NULL); (void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL);
#endif #endif
#ifdef FEAT_DIFF #ifdef FEAT_DIFF
if (curwin->w_topfill < diff_check(curwin, curwin->w_topline)) if (curwin->w_topfill < diff_check(curwin, curwin->w_topline))

View File

@@ -741,6 +741,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
822,
/**/ /**/
821, 821,
/**/ /**/

View File

@@ -141,7 +141,7 @@ do_window(nchar, Prenum, xchar)
#ifdef FEAT_GUI #ifdef FEAT_GUI
need_mouse_correct = TRUE; need_mouse_correct = TRUE;
#endif #endif
win_split((int)Prenum, 0); (void)win_split((int)Prenum, 0);
break; break;
#ifdef FEAT_VERTSPLIT #ifdef FEAT_VERTSPLIT
@@ -159,7 +159,7 @@ do_window(nchar, Prenum, xchar)
# ifdef FEAT_GUI # ifdef FEAT_GUI
need_mouse_correct = TRUE; need_mouse_correct = TRUE;
# endif # endif
win_split((int)Prenum, WSP_VERT); (void)win_split((int)Prenum, WSP_VERT);
break; break;
#endif #endif
@@ -2586,7 +2586,7 @@ win_close_othertab(win, free_buf, tp)
return; return;
/* When closing the last window in a tab page remove the tab page. */ /* When closing the last window in a tab page remove the tab page. */
if (tp == NULL ? firstwin == lastwin : tp->tp_firstwin == tp->tp_lastwin) if (tp->tp_firstwin == tp->tp_lastwin)
{ {
if (tp == first_tabpage) if (tp == first_tabpage)
first_tabpage = tp->tp_next; first_tabpage = tp->tp_next;