Skip to content

Commit

Permalink
patch 8.2.4241: some type casts are redundant
Browse files Browse the repository at this point in the history
Problem:    Some type casts are redundant.
Solution:   Remove the type casts. (closes #9643)
  • Loading branch information
dundargoc authored and brammool committed Jan 28, 2022
1 parent fb80862 commit 420fabc
Show file tree
Hide file tree
Showing 32 changed files with 92 additions and 93 deletions.
2 changes: 1 addition & 1 deletion src/blob.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ blob2string(blob_T *blob, char_u **tofree, char_u *numbuf)
{
if (i > 0 && (i & 3) == 0)
ga_concat(&ga, (char_u *)".");
vim_snprintf((char *)numbuf, NUMBUFLEN, "%02X", (int)blob_get(blob, i));
vim_snprintf((char *)numbuf, NUMBUFLEN, "%02X", blob_get(blob, i));
ga_concat(&ga, numbuf);
}
ga_append(&ga, NUL); // append a NUL at the end
Expand Down
4 changes: 2 additions & 2 deletions src/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1624,7 +1624,7 @@ do_bufdel(
// also be deleted, etc.
if (bnr == curbuf->b_fnum)
do_current = bnr;
else if (do_buffer_ext(command, DOBUF_FIRST, FORWARD, (int)bnr,
else if (do_buffer_ext(command, DOBUF_FIRST, FORWARD, bnr,
DOBUF_NOPOPUP | (forceit ? DOBUF_FORCEIT : 0)) == OK)
++deleted;

Expand Down Expand Up @@ -3754,7 +3754,7 @@ fileinfo(
}
else
{
p = (char *)msg_trunc_attr(buffer, FALSE, 0);
p = msg_trunc_attr(buffer, FALSE, 0);
if (restart_edit != 0 || (msg_scrolled && !need_wait_return))
// Need to repeat the message after redrawing when:
// - When restart_edit is set (otherwise there will be a delay
Expand Down
2 changes: 1 addition & 1 deletion src/channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ channel_connect(
ch_log(channel,
"Waiting for connection (waiting %d msec)...", waitnow);

ret = select((int)sd + 1, &rfds, &wfds, NULL, &tv);
ret = select(sd + 1, &rfds, &wfds, NULL, &tv);
if (ret < 0)
{
SOCK_ERRNO;
Expand Down
4 changes: 2 additions & 2 deletions src/clientserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ server_to_input_buf(char_u *str)
// The last but one parameter of replace_termcodes() is TRUE so that the
// <lt> sequence is recognised - needed for a real backslash.
p_cpo = (char_u *)"Bk";
str = replace_termcodes((char_u *)str, &ptr, REPTERM_DO_LT, NULL);
str = replace_termcodes(str, &ptr, REPTERM_DO_LT, NULL);
p_cpo = cpo_save;

if (*ptr != NUL) // trailing CTRL-V results in nothing
Expand All @@ -55,7 +55,7 @@ server_to_input_buf(char_u *str)
// buffer.
typebuf_was_filled = TRUE;
}
vim_free((char_u *)ptr);
vim_free(ptr);
}

/*
Expand Down
2 changes: 1 addition & 1 deletion src/clipboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -1488,7 +1488,7 @@ clip_x11_convert_selection_cb(
// create NUL terminated string which XmbTextListToTextProperty wants
mch_memmove(string_nt, string, (size_t)*length);
string_nt[*length] = NUL;
conv_result = XmbTextListToTextProperty(X_DISPLAY, (char **)&string_nt,
conv_result = XmbTextListToTextProperty(X_DISPLAY, &string_nt,
1, XCompoundTextStyle, &text_prop);
if (conv_result != Success)
{
Expand Down
8 changes: 4 additions & 4 deletions src/drawline.c
Original file line number Diff line number Diff line change
Expand Up @@ -1357,7 +1357,7 @@ win_line(
#endif
)
{
screen_line(screen_row, wp->w_wincol, col, -(int)wp->w_width,
screen_line(screen_row, wp->w_wincol, col, -wp->w_width,
screen_line_flags);
// Pretend we have finished updating the window. Except when
// 'cursorcolumn' is set.
Expand Down Expand Up @@ -2846,7 +2846,7 @@ win_line(
#endif

screen_line(screen_row, wp->w_wincol, col,
(int)wp->w_width, screen_line_flags);
wp->w_width, screen_line_flags);
row++;

// Update w_cline_height and w_cline_folded if the cursor line was
Expand Down Expand Up @@ -3147,11 +3147,11 @@ win_line(
{
#ifdef FEAT_CONCEAL
screen_line(screen_row, wp->w_wincol, col - boguscols,
(int)wp->w_width, screen_line_flags);
wp->w_width, screen_line_flags);
boguscols = 0;
#else
screen_line(screen_row, wp->w_wincol, col,
(int)wp->w_width, screen_line_flags);
wp->w_width, screen_line_flags);
#endif
++row;
++screen_row;
Expand Down
10 changes: 4 additions & 6 deletions src/drawscreen.c
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ win_redr_status(win_T *wp, int ignore_pum UNUSED)
this_ru_col + wp->w_wincol, fillchar, fillchar, attr);

if (get_keymap_str(wp, (char_u *)"<%s>", NameBuff, MAXPATHL)
&& (int)(this_ru_col - len) > (int)(STRLEN(NameBuff) + 1))
&& (this_ru_col - len) > (int)(STRLEN(NameBuff) + 1))
screen_puts(NameBuff, row, (int)(this_ru_col - STRLEN(NameBuff)
- 1 + wp->w_wincol), attr);

Expand Down Expand Up @@ -797,7 +797,7 @@ win_redr_ruler(win_T *wp, int always, int ignore_pum)
i = redraw_cmdline;
screen_fill(row, row + 1,
this_ru_col + off + (int)STRLEN(buffer),
(int)(off + width),
(off + width),
fillchar, fillchar, attr);
// don't redraw the cmdline because of showing the ruler
redraw_cmdline = i;
Expand Down Expand Up @@ -1038,8 +1038,7 @@ redraw_win_toolbar(win_T *wp)
}
wp->w_winbar_items[item_idx].wb_menu = NULL; // end marker

screen_line(wp->w_winrow, wp->w_wincol, (int)wp->w_width,
(int)wp->w_width, 0);
screen_line(wp->w_winrow, wp->w_wincol, wp->w_width, wp->w_width, 0);
}
#endif

Expand Down Expand Up @@ -1372,8 +1371,7 @@ fold_line(
}
#endif

screen_line(row + W_WINROW(wp), wp->w_wincol, (int)wp->w_width,
(int)wp->w_width, 0);
screen_line(row + W_WINROW(wp), wp->w_wincol, wp->w_width, wp->w_width, 0);

// Update w_cline_height and w_cline_folded if the cursor line was
// updated (saves a call to plines() later).
Expand Down
6 changes: 3 additions & 3 deletions src/edit.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ edit(

if (
#ifdef FEAT_VARTABS
(int)curwin->w_wcol < mincol - tabstop_at(
curwin->w_wcol < mincol - tabstop_at(
get_nolist_virtcol(), curbuf->b_p_ts,
curbuf->b_p_vts_array)
#else
Expand Down Expand Up @@ -2134,7 +2134,7 @@ insertchar(
return;

// Check whether this character should end a comment.
if (did_ai && (int)c == end_comment_pending)
if (did_ai && c == end_comment_pending)
{
char_u *line;
char_u lead_end[COM_MAX_LEN]; // end-comment string
Expand Down Expand Up @@ -2907,7 +2907,7 @@ stuff_inserted(
// may want to stuff the command character, to start Insert mode
if (c != NUL)
stuffcharReadbuff(c);
if ((esc_ptr = (char_u *)vim_strrchr(ptr, ESC)) != NULL)
if ((esc_ptr = vim_strrchr(ptr, ESC)) != NULL)
*esc_ptr = NUL; // remove the ESC

// when the last char is either "0" or "^" it will be quoted if no ESC
Expand Down
8 changes: 4 additions & 4 deletions src/evalfunc.c
Original file line number Diff line number Diff line change
Expand Up @@ -7158,7 +7158,7 @@ find_some_match(typval_T *argvars, typval_T *rettv, matchtype_T type)
break;
}

match = vim_regexec_nl(&regmatch, str, (colnr_T)startcol);
match = vim_regexec_nl(&regmatch, str, startcol);

if (match && --nth <= 0)
break;
Expand Down Expand Up @@ -7944,7 +7944,7 @@ range_list_materialize(list_T *list)
list->lv_u.mat.lv_idx_item = NULL;
for (i = start; stride > 0 ? i <= end : i >= end; i += stride)
{
if (list_append_number(list, (varnumber_T)i) == FAIL)
if (list_append_number(list, i) == FAIL)
break;
if (list->lv_lock & VAR_ITEMS_LOCKED)
list->lv_u.mat.lv_last->li_tv.v_lock = VAR_LOCKED;
Expand Down Expand Up @@ -9804,7 +9804,7 @@ f_synID(typval_T *argvars UNUSED, typval_T *rettv)

if (!transerr && lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count
&& col >= 0 && col < (long)STRLEN(ml_get(lnum)))
id = syn_get_id(curwin, lnum, (colnr_T)col, trans, NULL, FALSE);
id = syn_get_id(curwin, lnum, col, trans, NULL, FALSE);
#endif

rettv->vval.v_number = id;
Expand Down Expand Up @@ -10024,7 +10024,7 @@ f_synstack(typval_T *argvars UNUSED, typval_T *rettv)
&& col >= 0 && col <= (long)STRLEN(ml_get(lnum))
&& rettv_list_alloc(rettv) != FAIL)
{
(void)syn_get_id(curwin, lnum, (colnr_T)col, FALSE, NULL, TRUE);
(void)syn_get_id(curwin, lnum, col, FALSE, NULL, TRUE);
for (i = 0; ; ++i)
{
id = syn_get_stack_item(i);
Expand Down
2 changes: 1 addition & 1 deletion src/ex_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -1185,7 +1185,7 @@ do_filter(

if (do_out)
{
if (u_save((linenr_T)(line2), (linenr_T)(line2 + 1)) == FAIL)
if (u_save(line2, (linenr_T)(line2 + 1)) == FAIL)
{
vim_free(cmd_buf);
goto error;
Expand Down
6 changes: 3 additions & 3 deletions src/ex_docmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -6800,15 +6800,15 @@ ex_resize(exarg_T *eap)
n += wp->w_width;
else if (n == 0 && eap->arg[0] == NUL) // default is very wide
n = 9999;
win_setwidth_win((int)n, wp);
win_setwidth_win(n, wp);
}
else
{
if (*eap->arg == '-' || *eap->arg == '+')
n += wp->w_height;
else if (n == 0 && eap->arg[0] == NUL) // default is very high
n = 9999;
win_setheight_win((int)n, wp);
win_setheight_win(n, wp);
}
}

Expand Down Expand Up @@ -7531,7 +7531,7 @@ ex_sleep(exarg_T *eap)
{
n = W_WINROW(curwin) + curwin->w_wrow - msg_scrolled;
if (n >= 0)
windgoto((int)n, curwin->w_wincol + curwin->w_wcol);
windgoto(n, curwin->w_wincol + curwin->w_wcol);
}

len = eap->line2;
Expand Down
2 changes: 1 addition & 1 deletion src/ex_eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -2283,7 +2283,7 @@ leave_cleanup(cleanup_T *csp)
{
if (pending & CSTP_THROW)
// Cancel the pending exception (includes report).
discard_exception((except_T *)csp->exception, FALSE);
discard_exception(csp->exception, FALSE);
else
report_discard_pending(pending, NULL);

Expand Down
2 changes: 1 addition & 1 deletion src/fold.c
Original file line number Diff line number Diff line change
Expand Up @@ -2637,7 +2637,7 @@ foldUpdateIEMSRecurse(
// to stop just above startlnum.
fp->fd_len = startlnum - fp->fd_top;
foldMarkAdjustRecurse(&fp->fd_nested,
(linenr_T)fp->fd_len, (linenr_T)MAXLNUM,
fp->fd_len, (linenr_T)MAXLNUM,
(linenr_T)MAXLNUM, 0L);
fold_changed = TRUE;
}
Expand Down
2 changes: 1 addition & 1 deletion src/if_cscope.c
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ cs_create_connection(int i)
goto err_closing;
#endif
}
expand_env((char_u *)p_csprg, (char_u *)prog, MAXPATHL);
expand_env(p_csprg, (char_u *)prog, MAXPATHL);

// alloc space to hold the cscope command
len = (int)(strlen(prog) + strlen(csinfo[i].fname) + 32);
Expand Down
2 changes: 1 addition & 1 deletion src/json.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ json_encode_item(garray_T *gap, typval_T *val, int copyID, int options)
if (i > 0)
ga_concat(gap, (char_u *)",");
vim_snprintf((char *)numbuf, NUMBUFLEN, "%d",
(int)blob_get(b, i));
blob_get(b, i));
ga_concat(gap, numbuf);
}
ga_append(gap, ']');
Expand Down
4 changes: 2 additions & 2 deletions src/match.c
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ f_getmatches(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
{
char_u buf[MB_MAXBYTES + 1];

buf[(*mb_char2bytes)((int)cur->conceal_char, buf)] = NUL;
buf[(*mb_char2bytes)(cur->conceal_char, buf)] = NUL;
dict_add_string(dict, "conceal", (char_u *)&buf);
}
# endif
Expand Down Expand Up @@ -1309,7 +1309,7 @@ f_matcharg(typval_T *argvars UNUSED, typval_T *rettv)
id = (int)tv_get_number(&argvars[0]);
if (id >= 1 && id <= 3)
{
if ((m = (matchitem_T *)get_match(curwin, id)) != NULL)
if ((m = get_match(curwin, id)) != NULL)
{
list_append_string(rettv->vval.v_list,
syn_id2name(m->hlg_id), -1);
Expand Down
6 changes: 3 additions & 3 deletions src/memline.c
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ ml_set_crypt_key(
mf_put(mfp, hp, FALSE, FALSE); // release previous block

// get the block (pointer or data)
if ((hp = mf_get(mfp, (blocknr_T)bnum, page_count)) == NULL)
if ((hp = mf_get(mfp, bnum, page_count)) == NULL)
{
if (bnum == 1)
break;
Expand Down Expand Up @@ -1511,7 +1511,7 @@ ml_recover(int checkext)
/*
* get block
*/
if ((hp = mf_get(mfp, (blocknr_T)bnum, page_count)) == NULL)
if ((hp = mf_get(mfp, bnum, page_count)) == NULL)
{
if (bnum == 1)
{
Expand Down Expand Up @@ -3672,7 +3672,7 @@ ml_delete_int(buf_T *buf, linenr_T lnum, int flags)

#ifdef FEAT_NETBEANS_INTG
if (netbeans_active())
netbeans_removed(buf, lnum, 0, (long)line_size);
netbeans_removed(buf, lnum, 0, line_size);
#endif
#ifdef FEAT_PROP_POPUP
// If there are text properties, make a copy, so that we can update
Expand Down
6 changes: 3 additions & 3 deletions src/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ msg_attr_keep(
#ifdef FEAT_JOB_CHANNEL
if (emsg_to_channel_log)
// Write message in the channel log.
ch_log(NULL, "ERROR: %s", (char *)s);
ch_log(NULL, "ERROR: %s", s);
#endif

// Truncate the message if needed.
Expand Down Expand Up @@ -905,7 +905,7 @@ emsg_invreg(int name)
void
emsg_namelen(char *msg, char_u *name, int len)
{
char_u *copy = vim_strnsave((char_u *)name, len);
char_u *copy = vim_strnsave(name, len);

semsg(msg, copy == NULL ? "NULL" : (char *)copy);
vim_free(copy);
Expand Down Expand Up @@ -3701,7 +3701,7 @@ give_warning2(char_u *message, char_u *a1, int hl)
{
// Very early in initialisation and already something wrong, just give
// the raw message so the user at least gets a hint.
give_warning((char_u *)message, hl);
give_warning(message, hl);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/misc1.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ plines_win_nofill(

lines = plines_win_nofold(wp, lnum);
if (winheight > 0 && lines > wp->w_height)
return (int)wp->w_height;
return wp->w_height;
return lines;
}

Expand Down
2 changes: 1 addition & 1 deletion src/normal.c
Original file line number Diff line number Diff line change
Expand Up @@ -5211,7 +5211,7 @@ nv_replace(cmdarg_T *cap)
colnr_T start = (colnr_T)(curwin->w_cursor.col - cap->count1);

netbeans_removed(curbuf, curwin->w_cursor.lnum, start,
(long)cap->count1);
cap->count1);
netbeans_inserted(curbuf, curwin->w_cursor.lnum, start,
&ptr[start], (int)cap->count1);
}
Expand Down

0 comments on commit 420fabc

Please sign in to comment.