diff options
author | dundargoc <33953936+dundargoc@users.noreply.github.com> | 2021-09-14 13:07:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-14 04:07:08 -0700 |
commit | b8cce77702777bb876b2cef7e28662cf4539265e (patch) | |
tree | 70424a5319204875e76dbfddb72c931635bd959d /src | |
parent | 6ed43f8f1caad702f9590d174c5ec142f3d85b18 (diff) | |
download | rneovim-b8cce77702777bb876b2cef7e28662cf4539265e.tar.gz rneovim-b8cce77702777bb876b2cef7e28662cf4539265e.tar.bz2 rneovim-b8cce77702777bb876b2cef7e28662cf4539265e.zip |
fix: "redundant cast to the same type" #15662
Apply "redundant cast to the same type" fix from clangd.
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/edit.c | 8 | ||||
-rw-r--r-- | src/nvim/ex_cmds.c | 6 | ||||
-rw-r--r-- | src/nvim/ex_docmd.c | 12 | ||||
-rw-r--r-- | src/nvim/fileio.c | 6 | ||||
-rw-r--r-- | src/nvim/fold.c | 18 | ||||
-rw-r--r-- | src/nvim/ops.c | 26 | ||||
-rw-r--r-- | src/nvim/screen.c | 20 | ||||
-rw-r--r-- | src/nvim/syntax.c | 10 | ||||
-rw-r--r-- | src/nvim/tui/tui.c | 6 |
9 files changed, 56 insertions, 56 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 5410343365..a19adca942 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -4084,7 +4084,7 @@ int ins_compl_add_tv(typval_T *const tv, const Direction dir, bool fast) flags |= CP_EQUAL; } } else { - word = (const char *)tv_get_string_chk(tv); + word = tv_get_string_chk(tv); memset(cptext, 0, sizeof(cptext)); } if (word == NULL || (!empty && *word == NUL)) { @@ -8345,7 +8345,7 @@ static bool ins_bs(int c, int mode, int *inserted_space_p) getvcol(curwin, &curwin->w_cursor, NULL, NULL, &want_vcol); inc_cursor(); if (p_sta && in_indent) { - ts = (int)get_sw_value(curbuf); + ts = get_sw_value(curbuf); want_vcol = (want_vcol / ts) * ts; } else { want_vcol = tabstop_start(want_vcol, @@ -8538,7 +8538,7 @@ static void ins_mousescroll(int dir) if (dir == MSCR_DOWN || dir == MSCR_UP) { if (mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL)) { scroll_redraw(dir, - (long)(curwin->w_botline - curwin->w_topline)); + (curwin->w_botline - curwin->w_topline)); } else { scroll_redraw(dir, 3L); } @@ -8852,7 +8852,7 @@ static bool ins_tab(void) AppendToRedobuff("\t"); if (p_sta && ind) { // insert tab in indent, use 'shiftwidth' - temp = (int)get_sw_value(curbuf); + temp = get_sw_value(curbuf); temp -= get_nolist_virtcol() % temp; } else if (tabstop_count(curbuf->b_p_vsts_array) > 0 || curbuf->b_p_sts != 0) { diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 8096b1bc0c..5485355885 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -1353,7 +1353,7 @@ static void do_filter(linenr_T line1, linenr_T line2, exarg_T *eap, char_u *cmd, ui_cursor_goto(Rows - 1, 0); if (do_out) { - if (u_save((linenr_T)(line2), (linenr_T)(line2 + 1)) == FAIL) { + if (u_save((line2), (linenr_T)(line2 + 1)) == FAIL) { xfree(cmd_buf); goto error; } @@ -3068,7 +3068,7 @@ void ex_change(exarg_T *eap) // make sure the cursor is not beyond the end of the file now check_cursor_lnum(); - deleted_lines_mark(eap->line1, (long)(eap->line2 - lnum)); + deleted_lines_mark(eap->line1, (eap->line2 - lnum)); // ":append" on the line above the deleted lines. eap->line2 = eap->line1; @@ -4085,7 +4085,7 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle + copy_len + sublen + 1); // copy the text up to the part that matched - memmove(new_end, sub_firstline + copycol, (size_t)copy_len); + memmove(new_end, sub_firstline + copycol, copy_len); new_end += copy_len; // Finally, at this point we can know where the match actually will diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index a9852a78e6..4280a6a2c6 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -2644,7 +2644,7 @@ static char_u *find_command(exarg_T *eap, int *full) const int c1 = eap->cmd[0]; const int c2 = len == 1 ? NUL : eap->cmd[1]; - if (command_count != (int)CMD_SIZE) { + if (command_count != CMD_SIZE) { iemsg((char *)_("E943: Command table needs to be updated, run 'make'")); getout(1); } @@ -2659,7 +2659,7 @@ static char_u *find_command(exarg_T *eap, int *full) eap->cmdidx = CMD_bang; } - for (; (int)eap->cmdidx < (int)CMD_SIZE; + for (; (int)eap->cmdidx < CMD_SIZE; eap->cmdidx = (cmdidx_T)((int)eap->cmdidx + 1)) { if (STRNCMP(cmdnames[(int)eap->cmdidx].cmd_name, (char *)eap->cmd, (size_t)len) == 0) { @@ -2869,7 +2869,7 @@ int cmd_exists(const char *const name) for (int i = 0; i < (int)ARRAY_SIZE(cmdmods); i++) { int j; for (j = 0; name[j] != NUL; j++) { - if (name[j] != (char)cmdmods[i].name[j]) { + if (name[j] != cmdmods[i].name[j]) { break; } } @@ -2989,7 +2989,7 @@ const char * set_one_cmd_context(expand_T *xp, const char *buff) xp->xp_context = EXPAND_UNSUCCESSFUL; return NULL; } - for (ea.cmdidx = (cmdidx_T)0; (int)ea.cmdidx < (int)CMD_SIZE; + for (ea.cmdidx = (cmdidx_T)0; (int)ea.cmdidx < CMD_SIZE; ea.cmdidx = (cmdidx_T)((int)ea.cmdidx + 1)) { if (STRNCMP(cmdnames[(int)ea.cmdidx].cmd_name, cmd, len) == 0) { break; @@ -5143,7 +5143,7 @@ static int check_more(int message, bool forceit) */ char_u *get_command_name(expand_T *xp, int idx) { - if (idx >= (int)CMD_SIZE) { + if (idx >= CMD_SIZE) { return get_user_command_name(idx); } return cmdnames[idx].cmd_name; @@ -6239,7 +6239,7 @@ static void do_ucmd(exarg_T *eap) static char_u *get_user_command_name(int idx) { - return get_user_commands(NULL, idx - (int)CMD_SIZE); + return get_user_commands(NULL, idx - CMD_SIZE); } /* * Function given to ExpandGeneric() to obtain the list of user address type names. diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index a23ade4ec9..870c6ca2b1 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -1221,7 +1221,7 @@ retry: // move the linerest to before the converted characters line_start = ptr - linerest; memmove(line_start, buffer, (size_t)linerest); - size = (long)((char_u *)top - ptr); + size = ((char_u *)top - ptr); } # endif @@ -1397,7 +1397,7 @@ retry: // move the linerest to before the converted characters line_start = dest - linerest; memmove(line_start, buffer, (size_t)linerest); - size = (long)((ptr + real_size) - dest); + size = ((ptr + real_size) - dest); ptr = dest; } else if (!curbuf->b_p_bin) { bool incomplete_tail = false; @@ -1652,7 +1652,7 @@ rewind_retry: } } } - linerest = (long)(ptr - line_start); + linerest = (ptr - line_start); os_breakcheck(); } diff --git a/src/nvim/fold.c b/src/nvim/fold.c index 567cf9c8c3..bfc72e6af8 100644 --- a/src/nvim/fold.c +++ b/src/nvim/fold.c @@ -309,7 +309,7 @@ foldinfo_T fold_info(win_T *win, linenr_T lnum) linenr_T last; if (hasFoldingWin(win, lnum, NULL, &last, false, &info)) { - info.fi_lines = (long)(last - lnum + 1); + info.fi_lines = (last - lnum + 1); } else { info.fi_lines = 0; } @@ -2374,14 +2374,14 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *const gap, const int level, // nested folds (with relative line numbers) down. foldMarkAdjustRecurse(flp->wp, &fp->fd_nested, (linenr_T)0, (linenr_T)MAXLNUM, - (long)(fp->fd_top - firstlnum), 0L); + (fp->fd_top - firstlnum), 0L); } else { // Will move fold down, move nested folds relatively up. foldMarkAdjustRecurse(flp->wp, &fp->fd_nested, (linenr_T)0, - (long)(firstlnum - fp->fd_top - 1), + (firstlnum - fp->fd_top - 1), (linenr_T)MAXLNUM, - (long)(fp->fd_top - firstlnum)); + (fp->fd_top - firstlnum)); } fp->fd_len += fp->fd_top - firstlnum; fp->fd_top = firstlnum; @@ -2444,7 +2444,7 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *const gap, const int level, * to stop just above startlnum. */ fp->fd_len = startlnum - fp->fd_top; foldMarkAdjustRecurse(flp->wp, &fp->fd_nested, - (linenr_T)fp->fd_len, (linenr_T)MAXLNUM, + fp->fd_len, (linenr_T)MAXLNUM, (linenr_T)MAXLNUM, 0L); fold_changed = true; } @@ -2622,8 +2622,8 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *const gap, const int level, if (fp2->fd_top < flp->lnum) { // Make fold that includes lnum start at lnum. foldMarkAdjustRecurse(flp->wp, &fp2->fd_nested, - (linenr_T)0, (long)(flp->lnum - fp2->fd_top - 1), - (linenr_T)MAXLNUM, (long)(fp2->fd_top-flp->lnum)); + (linenr_T)0, (flp->lnum - fp2->fd_top - 1), + (linenr_T)MAXLNUM, (fp2->fd_top-flp->lnum)); fp2->fd_len -= flp->lnum - fp2->fd_top; fp2->fd_top = flp->lnum; fold_changed = true; @@ -2767,8 +2767,8 @@ static void foldRemove(win_T *const wp, garray_T *gap, linenr_T top, linenr_T bo if (fp->fd_top + fp->fd_len - 1 > bot) { // 5: Make fold that includes bot start below bot. foldMarkAdjustRecurse(wp, &fp->fd_nested, - (linenr_T)0, (long)(bot - fp->fd_top), - (linenr_T)MAXLNUM, (long)(fp->fd_top - bot - 1)); + (linenr_T)0, (bot - fp->fd_top), + (linenr_T)MAXLNUM, (fp->fd_top - bot - 1)); fp->fd_len -= bot - fp->fd_top + 1; fp->fd_top = bot + 1; break; diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 56a03620e3..a0dee7ace8 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -387,7 +387,7 @@ static void shift_block(oparg_T *oap, int amount) } for (; ascii_iswhite(*bd.textstart); ) { // TODO: is passing bd.textstart for start of the line OK? - incr = lbr_chartabsize_adv(bd.textstart, &bd.textstart, (colnr_T)(bd.start_vcol)); + incr = lbr_chartabsize_adv(bd.textstart, &bd.textstart, (bd.start_vcol)); total += incr; bd.start_vcol += incr; } @@ -506,7 +506,7 @@ static void shift_block(oparg_T *oap, int amount) } // replace the line ml_replace(curwin->w_cursor.lnum, newp, false); - changed_bytes(curwin->w_cursor.lnum, (colnr_T)bd.textcol); + changed_bytes(curwin->w_cursor.lnum, bd.textcol); extmark_splice_cols(curbuf, (int)curwin->w_cursor.lnum-1, startcol, oldlen, newlen, kExtmarkUndo); @@ -1253,7 +1253,7 @@ static void stuffescaped(const char *arg, int literally) arg++; } if (arg > start) { - stuffReadbuffLen(start, (long)(arg - start)); + stuffReadbuffLen(start, (arg - start)); } // stuff a single special character @@ -3227,7 +3227,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags) oldlen = STRLEN(oldp); for (ptr = oldp; vcol < col && *ptr; ) { // Count a tab for what it's worth (if list mode not on) - incr = lbr_chartabsize_adv(oldp, &ptr, (colnr_T)vcol); + incr = lbr_chartabsize_adv(oldp, &ptr, vcol); vcol += incr; } bd.textcol = (colnr_T)(ptr - oldp); @@ -4026,8 +4026,8 @@ int do_join(size_t count, int insert_space, int save_undo, int use_formatoptions const int spaces_removed = (int)((curr - curr_start) - spaces[t]); linenr_T lnum = curwin->w_cursor.lnum + t; colnr_T mincol = (colnr_T)0; - long lnum_amount = (linenr_T)-t; - long col_amount = (long)(cend - newp - spaces_removed); + long lnum_amount = -t; + long col_amount = (cend - newp - spaces_removed); mark_col_adjust(lnum, mincol, lnum_amount, col_amount, spaces_removed); @@ -4635,7 +4635,7 @@ static void block_prep(oparg_T *oap, struct block_def *bdp, linenr_T lnum, bool prev_pstart = line; while (bdp->start_vcol < oap->start_vcol && *pstart) { // Count a tab for what it's worth (if list mode not on) - incr = lbr_chartabsize(line, pstart, (colnr_T)bdp->start_vcol); + incr = lbr_chartabsize(line, pstart, bdp->start_vcol); bdp->start_vcol += incr; if (ascii_iswhite(*pstart)) { bdp->pre_whitesp += incr; @@ -4686,7 +4686,7 @@ static void block_prep(oparg_T *oap, struct block_def *bdp, linenr_T lnum, bool while (bdp->end_vcol <= oap->end_vcol && *pend != NUL) { // Count a tab for what it's worth (if list mode not on) prev_pend = pend; - incr = lbr_chartabsize_adv(line, &pend, (colnr_T)bdp->end_vcol); + incr = lbr_chartabsize_adv(line, &pend, bdp->end_vcol); bdp->end_vcol += incr; } if (bdp->end_vcol <= oap->end_vcol @@ -5908,18 +5908,18 @@ void cursor_pos_info(dict_T *dict) if (dict != NULL) { // Don't shorten this message, the user asked for it. - tv_dict_add_nr(dict, S_LEN("words"), (varnumber_T)word_count); - tv_dict_add_nr(dict, S_LEN("chars"), (varnumber_T)char_count); + tv_dict_add_nr(dict, S_LEN("words"), word_count); + tv_dict_add_nr(dict, S_LEN("chars"), char_count); tv_dict_add_nr(dict, S_LEN("bytes"), (varnumber_T)(byte_count + bom_count)); STATIC_ASSERT(sizeof("visual") == sizeof("cursor"), "key_len argument in tv_dict_add_nr is wrong"); tv_dict_add_nr(dict, l_VIsual_active ? "visual_bytes" : "cursor_bytes", - sizeof("visual_bytes") - 1, (varnumber_T)byte_count_cursor); + sizeof("visual_bytes") - 1, byte_count_cursor); tv_dict_add_nr(dict, l_VIsual_active ? "visual_chars" : "cursor_chars", - sizeof("visual_chars") - 1, (varnumber_T)char_count_cursor); + sizeof("visual_chars") - 1, char_count_cursor); tv_dict_add_nr(dict, l_VIsual_active ? "visual_words" : "cursor_words", - sizeof("visual_words") - 1, (varnumber_T)word_count_cursor); + sizeof("visual_words") - 1, word_count_cursor); } } diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 7ec0a9585b..3257eac9a9 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -385,7 +385,7 @@ int update_screen(int type) // 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); } } if (msg_use_msgsep()) { @@ -2627,7 +2627,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc shl->endcol = MAXCOL; shl->attr_cur = 0; shl->is_addpos = false; - v = (long)(ptr - line); + v = (ptr - line); if (cur != NULL) { cur->pos.cur = 0; } @@ -3061,7 +3061,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc * Do this for 'search_hl' and the match list (ordered by * priority). */ - v = (long)(ptr - line); + v = (ptr - line); cur = wp->w_match_head; shl_flag = false; while (cur != NULL || !shl_flag) { @@ -3405,7 +3405,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc /* Get syntax attribute, unless still at the start of the line * (double-wide char that doesn't fit). */ - v = (long)(ptr - line); + v = (ptr - line); if (has_syntax && v > 0) { /* Get the syntax attribute for the character. If there * is an error, disable syntax highlighting. */ @@ -3453,7 +3453,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc * Only do this when there is no syntax highlighting, the * @Spell cluster is not used or the current syntax item * contains the @Spell cluster. */ - v = (long)(ptr - line); + v = (ptr - line); if (has_spell && v >= word_end && v > cur_checked_col) { spell_attr = 0; if (!attr_pri) { @@ -3944,7 +3944,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc // At end of the text line or just after the last character. if (c == NUL && eol_hl_off == 0) { - long prevcol = (long)(ptr - line) - 1; + long prevcol = (ptr - line) - 1; // we're not really at that column when skipping some text if ((long)(wp->w_p_wrap ? wp->w_skipcol : wp->w_leftcol) > prevcol) { @@ -6597,7 +6597,7 @@ void screenclear(void) // blank out the default grid for (i = 0; i < default_grid.Rows; i++) { grid_clear_line(&default_grid, default_grid.line_offset[i], - (int)default_grid.Columns, true); + default_grid.Columns, true); default_grid.line_wraps[i] = false; } @@ -6770,7 +6770,7 @@ void grid_ins_lines(ScreenGrid *grid, int row, int line_count, int end, int col, } grid->line_offset[j + line_count] = temp; grid->line_wraps[j + line_count] = false; - grid_clear_line(grid, temp, (int)grid->Columns, false); + grid_clear_line(grid, temp, grid->Columns, false); } } @@ -6822,7 +6822,7 @@ void grid_del_lines(ScreenGrid *grid, int row, int line_count, int end, int col, } grid->line_offset[j - line_count] = temp; grid->line_wraps[j - line_count] = false; - grid_clear_line(grid, temp, (int)grid->Columns, false); + grid_clear_line(grid, temp, grid->Columns, false); } } @@ -6919,7 +6919,7 @@ int showmode(void) } if (edit_submode_extra != NULL) { MSG_PUTS_ATTR(" ", attr); // Add a space in between. - if ((int)edit_submode_highl < (int)HLF_COUNT) { + if ((int)edit_submode_highl < HLF_COUNT) { sub_attr = win_hl_attr(curwin, edit_submode_highl); } else { sub_attr = attr; diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 49e451062c..64206b4269 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -7007,7 +7007,7 @@ void do_highlight(const char *line, const bool forceit, const bool init) } if (ascii_isdigit(*arg)) { - color = atoi((char *)arg); + color = atoi(arg); } else if (STRICMP(arg, "fg") == 0) { if (cterm_normal_fg_color) { color = cterm_normal_fg_color - 1; @@ -7867,20 +7867,20 @@ void highlight_changed(void) need_highlight_changed = false; /// Translate builtin highlight groups into attributes for quick lookup. - for (int hlf = 0; hlf < (int)HLF_COUNT; hlf++) { + for (int hlf = 0; hlf < HLF_COUNT; hlf++) { id = syn_check_group((char_u *)hlf_names[hlf], STRLEN(hlf_names[hlf])); if (id == 0) { abort(); } int final_id = syn_get_final_id(id); - if (hlf == (int)HLF_SNC) { + if (hlf == HLF_SNC) { id_SNC = final_id; - } else if (hlf == (int)HLF_S) { + } else if (hlf == HLF_S) { id_S = final_id; } highlight_attr[hlf] = hl_get_ui_attr(hlf, final_id, - hlf == (int)HLF_INACTIVE); + hlf == HLF_INACTIVE); if (highlight_attr[hlf] != highlight_attr_last[hlf]) { if (hlf == HLF_MSG) { diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index db14334c1c..fb5e12c20e 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1458,8 +1458,8 @@ static void tui_guess_size(UI *ui) did_user_set_dimensions = true; assert(Columns >= INT_MIN && Columns <= INT_MAX); assert(Rows >= INT_MIN && Rows <= INT_MAX); - width = (int)Columns; - height = (int)Rows; + width = Columns; + height = Rows; goto end; } @@ -1934,7 +1934,7 @@ static void augment_terminfo(TUIData *data, const char *term, long vte_version, // terminfo describes strikethrough modes as rmxx/smxx with respect // to the ECMA-48 strikeout/crossed-out attributes. - data->unibi_ext.enter_strikethrough_mode = (int)unibi_find_ext_str(ut, "smxx"); + data->unibi_ext.enter_strikethrough_mode = unibi_find_ext_str(ut, "smxx"); // Dickey ncurses terminfo does not include the setrgbf and setrgbb // capabilities, proposed by RĂ¼diger Sonderfeld on 2013-10-15. Adding |