Merge pull request #15941 from dundargoc/refactor/remove-redundant-casts

refactor: remove redundant casts
This commit is contained in:
Björn Linse 2021-10-07 18:39:27 +02:00 committed by GitHub
commit 684299ed4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 27 additions and 27 deletions

View File

@ -418,7 +418,7 @@ void nvim_buf_set_lines(uint64_t channel_id, Buffer buffer, Integer start, Integ
try_start();
aco_save_T aco;
aucmd_prepbuf(&aco, (buf_T *)buf);
aucmd_prepbuf(&aco, buf);
if (!MODIFIABLE(buf)) {
api_set_error(err, kErrorTypeException, "Buffer is not 'modifiable'");
@ -656,7 +656,7 @@ void nvim_buf_set_text(uint64_t channel_id, Buffer buffer, Integer start_row, In
try_start();
aco_save_T aco;
aucmd_prepbuf(&aco, (buf_T *)buf);
aucmd_prepbuf(&aco, buf);
if (!MODIFIABLE(buf)) {
api_set_error(err, kErrorTypeException, "Buffer is not 'modifiable'");
@ -1340,7 +1340,7 @@ ArrayOf(Integer) nvim_buf_get_extmark_by_id(Buffer buffer, Integer ns_id,
if (extmark.row < 0) {
return rv;
}
return extmark_to_array(extmark, false, (bool)details);
return extmark_to_array(extmark, false, details);
}
/// Gets extmarks in "traversal order" from a |charwise| region defined by
@ -1982,7 +1982,7 @@ Object nvim_buf_call(Buffer buffer, LuaRef fun, Error *err)
}
try_start();
aco_save_T aco;
aucmd_prepbuf(&aco, (buf_T *)buf);
aucmd_prepbuf(&aco, buf);
Array args = ARRAY_DICT_INIT;
Object res = nlua_call_ref(fun, NULL, args, true, err);

View File

@ -625,7 +625,7 @@ void ins_char_bytes(char_u *buf, size_t charlen)
// Copy bytes before the cursor.
if (col > 0) {
memmove(newp, oldp, (size_t)col);
memmove(newp, oldp, col);
}
// Copy bytes after the changed character(s).

View File

@ -87,7 +87,7 @@ bool channel_close(uint64_t id, ChannelPart part, const char **error)
break;
case kChannelStreamProc:
proc = (Process *)&chan->stream.proc;
proc = &chan->stream.proc;
if (part == kChannelPartStdin || close_main) {
stream_may_close(&proc->in);
}
@ -335,7 +335,7 @@ Channel *channel_job_start(char **argv, CallbackReader on_stdout, CallbackReader
chan->stream.uv = libuv_process_init(&main_loop, chan);
}
Process *proc = (Process *)&chan->stream.proc;
Process *proc = &chan->stream.proc;
proc->argv = argv;
proc->cb = channel_process_exit_cb;
proc->events = chan->events;

View File

@ -3741,7 +3741,7 @@ static void f_getmatches(typval_T *argvars, typval_T *rettv, FunPtr fptr)
if (cur->conceal_char) {
char buf[MB_MAXBYTES + 1];
buf[utf_char2bytes((int)cur->conceal_char, (char_u *)buf)] = NUL;
buf[utf_char2bytes(cur->conceal_char, (char_u *)buf)] = NUL;
tv_dict_add_str(dict, S_LEN("conceal"), buf);
}
@ -5230,7 +5230,7 @@ static void f_jobpid(typval_T *argvars, typval_T *rettv, FunPtr fptr)
return;
}
Process *proc = (Process *)&data->stream.proc;
Process *proc = &data->stream.proc;
rettv->vval.v_number = proc->pid;
}
@ -5528,7 +5528,7 @@ static void f_jobstop(typval_T *argvars, typval_T *rettv, FunPtr fptr)
// Ignore return code, but show error later.
(void)channel_close(data->id, kChannelPartRpc, &error);
}
process_stop((Process *)&data->stream.proc);
process_stop(&data->stream.proc);
rettv->vval.v_number = 1;
if (error) {
EMSG(error);
@ -6135,7 +6135,7 @@ static void find_some_match(typval_T *const argvars, typval_T *const rettv,
}
}
match = vim_regexec_nl(&regmatch, str, (colnr_T)startcol);
match = vim_regexec_nl(&regmatch, str, startcol);
if (match && --nth <= 0) {
break;
@ -6346,7 +6346,7 @@ static void f_matcharg(typval_T *argvars, typval_T *rettv, FunPtr fptr)
: 0));
if (id >= 1 && id <= 3) {
matchitem_T *const m = (matchitem_T *)get_match(curwin, id);
matchitem_T *const m = get_match(curwin, id);
if (m != NULL) {
tv_list_append_string(rettv->vval.v_list,
@ -6993,7 +6993,7 @@ static void f_range(typval_T *argvars, typval_T *rettv, FunPtr fptr)
} else {
tv_list_alloc_ret(rettv, (end - start) / stride);
for (i = start; stride > 0 ? i <= end : i >= end; i += stride) {
tv_list_append_number(rettv->vval.v_list, (varnumber_T)i);
tv_list_append_number(rettv->vval.v_list, i);
}
}
}

View File

@ -2861,7 +2861,7 @@ bool tv_equal(typval_T *const tv1, typval_T *const tv2, const bool ic, const boo
char buf2[NUMBUFLEN];
const char *s1 = tv_get_string_buf(tv1, buf1);
const char *s2 = tv_get_string_buf(tv2, buf2);
return mb_strcmp_ic((bool)ic, s1, s2) == 0;
return mb_strcmp_ic(ic, s1, s2) == 0;
}
case VAR_BOOL:
return tv1->vval.v_bool == tv2->vval.v_bool;

View File

@ -723,7 +723,7 @@ void extmark_move_region(buf_T *buf, int start_row, colnr_T start_col, bcount_t
uint64_t src2ns(Integer *src_id)
{
if (*src_id == 0) {
*src_id = (Integer)nvim_create_namespace((String)STRING_INIT);
*src_id = nvim_create_namespace((String)STRING_INIT);
}
if (*src_id < 0) {
return UINT64_MAX;

View File

@ -1294,7 +1294,7 @@ static int cs_kill(exarg_T *eap)
}
}
} else {
cs_kill_execute((size_t)i, stok);
cs_kill_execute(i, stok);
}
}
@ -1559,8 +1559,8 @@ static void cs_fill_results(char *tagstr, size_t totmatches, int *nummatches_a,
assert(totmatches > 0);
buf = xmalloc(CSREAD_BUFSIZE);
matches = xmalloc(sizeof(char *) * (size_t)totmatches);
cntxts = xmalloc(sizeof(char *) * (size_t)totmatches);
matches = xmalloc(sizeof(char *) * totmatches);
cntxts = xmalloc(sizeof(char *) * totmatches);
for (size_t i = 0; i < csinfo_size; i++) {
if (nummatches_a[i] < 1) {

View File

@ -837,8 +837,8 @@ bool marktree_splice(MarkTree *b, int start_line, int start_col, int old_extent_
int old_extent_col, int new_extent_line, int new_extent_col)
{
mtpos_t start = { start_line, start_col };
mtpos_t old_extent = { (int)old_extent_line, old_extent_col };
mtpos_t new_extent = { (int)new_extent_line, new_extent_col };
mtpos_t old_extent = { old_extent_line, old_extent_col };
mtpos_t new_extent = { new_extent_line, new_extent_col };
bool may_delete = (old_extent.row != 0 || old_extent.col != 0);
bool same_line = old_extent.row == 0 && new_extent.row == 0;

View File

@ -857,7 +857,7 @@ static void show_menus_recursive(vimmenu_T *menu, int modes, int depth)
MSG_PUTS(" ");
}
if (menu->priority) {
msg_outnum((long)menu->priority);
msg_outnum(menu->priority);
MSG_PUTS(" ");
}
// Same highlighting as for directories!?

View File

@ -2363,7 +2363,7 @@ void msg_reset_scroll(void)
// non-displayed part of msg_grid is considered invalid.
for (int i = 0; i < MIN(msg_scrollsize(), msg_grid.Rows); i++) {
grid_clear_line(&msg_grid, msg_grid.line_offset[i],
(int)msg_grid.Columns, false);
msg_grid.Columns, false);
}
}
} else {

View File

@ -3899,7 +3899,7 @@ static char *set_bool_option(const int opt_idx, char_u *const varp, const int va
// when 'buflisted' changes, trigger autocommands
apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE,
NULL, NULL, true, curbuf);
} else if ((int *)varp == (int *)&curbuf->b_p_swf) {
} else if ((int *)varp == &curbuf->b_p_swf) {
// when 'swf' is set, create swapfile, when reset remove swapfile
if (curbuf->b_p_swf && p_uc) {
ml_open_file(curbuf); // create the swap file

View File

@ -2401,7 +2401,7 @@ static inline void shada_initialize_registers(WriteMergerState *const wms, int m
.data = {
.reg = {
.contents = (char **)reg.y_array,
.contents_size = (size_t)reg.y_size,
.contents_size = reg.y_size,
.type = reg.y_type,
.width = (size_t)(reg.y_type == kMTBlockWise ? reg.y_width : 0),
.additional_data = reg.additional_data,

View File

@ -2924,8 +2924,8 @@ void spell_suggest(int count)
// Get the list of suggestions. Limit to 'lines' - 2 or the number in
// 'spellsuggest', whatever is smaller.
if (sps_limit > (int)Rows - 2) {
limit = (int)Rows - 2;
if (sps_limit > Rows - 2) {
limit = Rows - 2;
} else {
limit = sps_limit;
}

View File

@ -1241,7 +1241,7 @@ static bool send_mouse_event(Terminal *term, int c)
mouse_action(term, button, row, col - offset, drag, 0);
size_t len = vterm_output_read(term->vt, term->textbuf,
sizeof(term->textbuf));
terminal_send(term, term->textbuf, (size_t)len);
terminal_send(term, term->textbuf, len);
return false;
}