aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2022-10-12 14:53:40 +0100
committerGitHub <noreply@github.com>2022-10-12 14:53:40 +0100
commit0ef6aaa3a73d5089bf53e804364950c81784574c (patch)
treeb74efe8683f2a6a8257ed31725244d749d229274 /src
parent024f6880b5e0f7b6d968f4f709f8ca6e7ab567c7 (diff)
downloadrneovim-0ef6aaa3a73d5089bf53e804364950c81784574c.tar.gz
rneovim-0ef6aaa3a73d5089bf53e804364950c81784574c.tar.bz2
rneovim-0ef6aaa3a73d5089bf53e804364950c81784574c.zip
refactor: clint (#20600)
Diffstat (limited to 'src')
-rw-r--r--src/nvim/eval/decode.c40
-rw-r--r--src/nvim/eval/encode.c18
-rw-r--r--src/nvim/ex_cmds.c5
-rw-r--r--src/nvim/ex_eval.c6
-rw-r--r--src/nvim/file_search.c7
-rw-r--r--src/nvim/fileio.c24
-rw-r--r--src/nvim/garray.c2
-rw-r--r--src/nvim/main.c5
-rw-r--r--src/nvim/move.c3
-rw-r--r--src/nvim/ops.c2
-rw-r--r--src/nvim/option.c15
-rw-r--r--src/nvim/path.c4
-rw-r--r--src/nvim/tag.c3
-rw-r--r--src/nvim/window.c2
14 files changed, 59 insertions, 77 deletions
diff --git a/src/nvim/eval/decode.c b/src/nvim/eval/decode.c
index 94ef419bed..6b7eb2f8f8 100644
--- a/src/nvim/eval/decode.c
+++ b/src/nvim/eval/decode.c
@@ -271,11 +271,9 @@ typval_T decode_string(const char *const s, const size_t len, const TriState has
list_T *const list = tv_list_alloc(kListLenMayKnow);
tv_list_ref(list);
create_special_dict(&tv, kMPString,
- ((typval_T){
- .v_type = VAR_LIST,
- .v_lock = VAR_UNLOCKED,
- .vval = { .v_list = list },
- }));
+ (typval_T){ .v_type = VAR_LIST,
+ .v_lock = VAR_UNLOCKED,
+ .vval = { .v_list = list } });
const int elw_ret = encode_list_write((void *)list, s, len);
if (s_allocated) {
xfree((void *)s);
@@ -368,7 +366,7 @@ static inline int parse_json_string(const char *const buf, const size_t buf_len,
goto parse_json_string_fail;
}
} else {
- uint8_t p_byte = (uint8_t)*p;
+ uint8_t p_byte = (uint8_t)(*p);
// unescaped = %x20-21 / %x23-5B / %x5D-10FFFF
if (p_byte < 0x20) {
semsg(_("E474: ASCII control characters cannot be present "
@@ -469,7 +467,7 @@ static inline int parse_json_string(const char *const buf, const size_t buf_len,
['r'] = CAR,
['f'] = FF,
};
- *str_end++ = escapes[(int)*t];
+ *str_end++ = escapes[(int)(*t)];
break;
}
default:
@@ -838,12 +836,10 @@ json_decode_string_cycle_start:
.v_lock = VAR_UNLOCKED,
.vval = { .v_list = list },
};
- kv_push(container_stack, ((ContainerStackItem) {
- .stack_index = kv_size(stack),
- .s = p,
- .container = tv,
- .special_val = NULL,
- }));
+ kv_push(container_stack, ((ContainerStackItem) { .stack_index = kv_size(stack),
+ .s = p,
+ .container = tv,
+ .special_val = NULL }));
kv_push(stack, OBJ(tv, false, didcomma, didcolon));
break;
}
@@ -862,12 +858,10 @@ json_decode_string_cycle_start:
.vval = { .v_dict = dict },
};
}
- kv_push(container_stack, ((ContainerStackItem) {
- .stack_index = kv_size(stack),
- .s = p,
- .container = tv,
- .special_val = val_list,
- }));
+ kv_push(container_stack, ((ContainerStackItem) { .stack_index = kv_size(stack),
+ .s = p,
+ .container = tv,
+ .special_val = val_list }));
kv_push(stack, OBJ(tv, false, didcomma, didcolon));
break;
}
@@ -1089,11 +1083,9 @@ msgpack_to_vim_generic_map: {}
tv_list_append_number(list, mobj.via.ext.type);
list_T *const ext_val_list = tv_list_alloc(kListLenMayKnow);
tv_list_append_list(list, ext_val_list);
- create_special_dict(rettv, kMPExt, ((typval_T) {
- .v_type = VAR_LIST,
- .v_lock = VAR_UNLOCKED,
- .vval = { .v_list = list },
- }));
+ create_special_dict(rettv, kMPExt, ((typval_T) { .v_type = VAR_LIST,
+ .v_lock = VAR_UNLOCKED,
+ .vval = { .v_list = list } }));
if (encode_list_write((void *)ext_val_list, mobj.via.ext.ptr,
mobj.via.ext.size) == -1) {
return FAIL;
diff --git a/src/nvim/eval/encode.c b/src/nvim/eval/encode.c
index 27d35ea24f..82c9f04f8f 100644
--- a/src/nvim/eval/encode.c
+++ b/src/nvim/eval/encode.c
@@ -144,16 +144,16 @@ static int conv_error(const char *const msg, const MPConvStack *const mpstack,
case kMPConvPairs:
case kMPConvList: {
const int idx = (v.data.l.li == tv_list_first(v.data.l.list)
- ? 0
- : (v.data.l.li == NULL
- ? tv_list_len(v.data.l.list) - 1
- : (int)tv_list_idx_of_item(v.data.l.list,
- TV_LIST_ITEM_PREV(v.data.l.list,
- v.data.l.li))));
+ ? 0
+ : (v.data.l.li == NULL
+ ? tv_list_len(v.data.l.list) - 1
+ : (int)tv_list_idx_of_item(v.data.l.list,
+ TV_LIST_ITEM_PREV(v.data.l.list,
+ v.data.l.li))));
const listitem_T *const li = (v.data.l.li == NULL
- ? tv_list_last(v.data.l.list)
- : TV_LIST_ITEM_PREV(v.data.l.list,
- v.data.l.li));
+ ? tv_list_last(v.data.l.list)
+ : TV_LIST_ITEM_PREV(v.data.l.list,
+ v.data.l.li));
if (v.type == kMPConvList
|| li == NULL
|| (TV_LIST_ITEM_TV(li)->v_type != VAR_LIST
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index ea51cac163..781463b881 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -266,13 +266,12 @@ void ex_align(exarg_T *eap)
}
for (curwin->w_cursor.lnum = eap->line1;
- curwin->w_cursor.lnum <= eap->line2; ++curwin->w_cursor.lnum) {
+ curwin->w_cursor.lnum <= eap->line2; curwin->w_cursor.lnum++) {
if (eap->cmdidx == CMD_left) { // left align
new_indent = indent;
} else {
has_tab = false; // avoid uninit warnings
- len = linelen(eap->cmdidx == CMD_right ? &has_tab
- : NULL) - get_indent();
+ len = linelen(eap->cmdidx == CMD_right ? &has_tab : NULL) - get_indent();
if (len <= 0) { // skip blank lines
continue;
diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c
index c2648b9bfc..09bd88c947 100644
--- a/src/nvim/ex_eval.c
+++ b/src/nvim/ex_eval.c
@@ -539,9 +539,7 @@ static void discard_exception(except_T *excp, bool was_finished)
if (debug_break_level > 0 || *p_vfile == NUL) {
msg_scroll = true; // always scroll up, don't overwrite
}
- smsg(was_finished ? _("Exception finished: %s")
- : _("Exception discarded: %s"),
- excp->value);
+ smsg(was_finished ? _("Exception finished: %s") : _("Exception discarded: %s"), excp->value);
msg_puts("\n"); // don't overwrite this either
if (debug_break_level > 0 || *p_vfile == NUL) {
cmdline_row = msg_row;
@@ -1950,7 +1948,7 @@ void rewind_conditionals(cstack_T *cstack, int idx, int cond_type, int *cond_lev
{
while (cstack->cs_idx > idx) {
if (cstack->cs_flags[cstack->cs_idx] & cond_type) {
- --*cond_level;
+ (*cond_level)--;
}
if (cstack->cs_flags[cstack->cs_idx] & CSF_FOR) {
free_for_info(cstack->cs_forinfo[cstack->cs_idx]);
diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c
index d9adf84acc..c41916d40a 100644
--- a/src/nvim/file_search.c
+++ b/src/nvim/file_search.c
@@ -308,7 +308,7 @@ void *vim_findfile_init(char *path, char *filename, char *stopdirs, int level, i
goto error_return;
}
path += 2;
- } else
+ } else // NOLINT(readability/braces)
#endif
if (os_dirname((char_u *)ff_expand_buffer, MAXPATHL) == FAIL) {
goto error_return;
@@ -619,16 +619,15 @@ char_u *vim_findfile(void *search_ctx_arg)
#endif
ff_free_stack_element(stackp);
continue;
- }
#ifdef FF_VERBOSE
- else if (p_verbose >= 5) {
+ } else if (p_verbose >= 5) {
verbose_enter_scroll();
smsg("Searching: %s (%s)",
stackp->ffs_fix_path, stackp->ffs_wc_path);
msg_puts("\n"); // don't overwrite this either
verbose_leave_scroll();
- }
#endif
+ }
// check depth
if (stackp->ffs_level <= 0) {
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index 30898981de..7f844bc8f7 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -1048,9 +1048,8 @@ retry:
conv_error = curbuf->b_ml.ml_line_count
- linecnt + 1;
}
- }
- // Remember the first linenr with an illegal byte
- else if (illegal_byte == 0) {
+ } else if (illegal_byte == 0) {
+ // Remember the first linenr with an illegal byte
illegal_byte = curbuf->b_ml.ml_line_count
- linecnt + 1;
}
@@ -1066,7 +1065,7 @@ retry:
#ifdef HAVE_ICONV
|| iconv_fd != (iconv_t)-1
#endif
- )) {
+ )) { // NOLINT(whitespace/parens)
while (conv_restlen > 0) {
*(--ptr) = (char)bad_char_behavior;
conv_restlen--;
@@ -3039,9 +3038,11 @@ nobackup:
// false.
while ((fd = os_open(wfname,
O_WRONLY |
- (append ?
- (forceit ? (O_APPEND | O_CREAT) : O_APPEND)
- : (O_CREAT | O_TRUNC)),
+ (append
+ ? (forceit
+ ? (O_APPEND | O_CREAT)
+ : O_APPEND)
+ : (O_CREAT | O_TRUNC)),
perm < 0 ? 0666 : (perm & 0777))) < 0) {
// A forced write will try to create a new file if the old one
// is still readonly. This may also happen when the directory
@@ -3336,7 +3337,7 @@ restore_backup:
} else {
errmsg_allocated = true;
SET_ERRMSG(xmalloc(300));
- vim_snprintf(errmsg, 300,
+ vim_snprintf(errmsg, 300, // NOLINT(runtime/printf)
_("E513: write error, conversion failed in line %" PRIdLINENR
" (make 'fenc' empty to override)"),
write_info.bw_conv_error_lnum);
@@ -4258,7 +4259,7 @@ char *modname(const char *fname, const char *ext, bool prepend_dot)
} else {
fnamelen = strlen(fname);
retval = xmalloc(fnamelen + extlen + 3);
- strcpy(retval, fname);
+ strcpy(retval, fname); // NOLINT(runtime/printf)
}
// Search backwards until we hit a '/', '\' or ':'.
@@ -4276,12 +4277,11 @@ char *modname(const char *fname, const char *ext, bool prepend_dot)
ptr[BASENAMELEN] = '\0';
}
- char *s;
- s = ptr + strlen(ptr);
+ char *s = ptr + strlen(ptr);
// Append the extension.
// ext can start with '.' and cannot exceed 3 more characters.
- strcpy(s, ext);
+ strcpy(s, ext); // NOLINT(runtime/printf)
char *e;
// Prepend the dot if needed.
diff --git a/src/nvim/garray.c b/src/nvim/garray.c
index 6c63ce5a7c..eefbfed3ef 100644
--- a/src/nvim/garray.c
+++ b/src/nvim/garray.c
@@ -167,7 +167,7 @@ char *ga_concat_strings_sep(const garray_T *gap, const char *sep)
s = xstpcpy(s, strings[i]);
s = xstpcpy(s, sep);
}
- strcpy(s, strings[nelem - 1]);
+ strcpy(s, strings[nelem - 1]); // NOLINT(runtime/printf)
return ret;
}
diff --git a/src/nvim/main.c b/src/nvim/main.c
index 5687e0a6a9..d5fa992218 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -1274,9 +1274,8 @@ scripterror:
kFileReadOnly|kFileNonBlocking);
assert(stdin_dup != NULL);
scriptin[0] = stdin_dup;
- } else if ((scriptin[0] =
- file_open_new(&error, argv[0], kFileReadOnly|kFileNonBlocking,
- 0)) == NULL) {
+ } else if ((scriptin[0] = file_open_new(&error, argv[0],
+ kFileReadOnly|kFileNonBlocking, 0)) == NULL) {
vim_snprintf((char *)IObuff, IOSIZE,
_("Cannot open for reading: \"%s\": %s\n"),
argv[0], os_strerror(error));
diff --git a/src/nvim/move.c b/src/nvim/move.c
index 9b7755a828..b79edb50f9 100644
--- a/src/nvim/move.c
+++ b/src/nvim/move.c
@@ -813,8 +813,7 @@ void curs_columns(win_T *wp, int may_scroll)
if ((wp->w_wrow >= wp->w_height_inner
|| ((prev_skipcol > 0
|| wp->w_wrow + so >= wp->w_height_inner)
- && (plines =
- plines_win_nofill(wp, wp->w_cursor.lnum, false)) - 1
+ && (plines = plines_win_nofill(wp, wp->w_cursor.lnum, false)) - 1
>= wp->w_height_inner))
&& wp->w_height_inner != 0
&& wp->w_cursor.lnum == wp->w_topline
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index d3a47d77a2..3bb397fdd8 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -2239,7 +2239,7 @@ void op_insert(oparg_T *oap, long count1)
}
curwin->w_ve_flags = VE_ALL;
coladvance_force(oap->op_type == OP_APPEND
- ? oap->end_vcol + 1 : getviscol());
+ ? oap->end_vcol + 1 : getviscol());
if (oap->op_type == OP_APPEND) {
curwin->w_cursor.col--;
}
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 208112561a..3c3a69e063 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -207,7 +207,7 @@ void set_init_1(bool clean_arg)
p = "/tmp";
# endif
mustfree = false;
- } else
+ } else // NOLINT(readability/braces)
#endif
{
p = vim_getenv(names[n]);
@@ -2042,10 +2042,9 @@ static char *set_bool_option(const int opt_idx, char_u *const varp, const int va
}
redraw_titles();
modified_was_set = value;
- }
#ifdef BACKSLASH_IN_FILENAME
- else if ((int *)varp == &p_ssl) {
+ } else if ((int *)varp == &p_ssl) {
if (p_ssl) {
psepc = '/';
psepcN = '\\';
@@ -2060,9 +2059,8 @@ static char *set_bool_option(const int opt_idx, char_u *const varp, const int va
buflist_slash_adjust();
alist_slash_adjust();
scriptnames_slash_adjust();
- }
#endif
- else if ((int *)varp == &curwin->w_p_wrap) {
+ } else if ((int *)varp == &curwin->w_p_wrap) {
// If 'wrap' is set, set w_leftcol to zero.
if (curwin->w_p_wrap) {
curwin->w_leftcol = 0;
@@ -2681,7 +2679,7 @@ int findoption_len(const char *const arg, const size_t len)
// letter. There are 26 letters, plus the first "t_" option.
if (quick_tab[1] == 0) {
p = options[0].fullname;
- for (short int i = 1; (s = options[i].fullname) != NULL; i++) {
+ for (uint16_t i = 1; (s = options[i].fullname) != NULL; i++) {
if (s[0] != p[0]) {
if (s[0] == 't' && s[1] == '_') {
quick_tab[26] = i;
@@ -3598,8 +3596,7 @@ void unset_global_local_option(char *name, void *from)
}
p = &(options[opt_idx]);
- switch ((int)p->indir)
- {
+ switch ((int)p->indir) {
// global option with local value: use local value if it's been set
case PV_EP:
clear_string_option(&buf->b_p_ep);
@@ -4862,7 +4859,7 @@ static void option_value2string(vimoption_T *opp, int opt_flags)
snprintf((char *)NameBuff,
sizeof(NameBuff),
"%" PRId64,
- (int64_t)*(long *)varp);
+ (int64_t)(*(long *)varp));
}
} else { // P_STRING
varp = *(char_u **)(varp);
diff --git a/src/nvim/path.c b/src/nvim/path.c
index 9295905415..981937b79e 100644
--- a/src/nvim/path.c
+++ b/src/nvim/path.c
@@ -645,7 +645,7 @@ static size_t do_path_expand(garray_T *gap, const char *path, size_t wildoff, in
#ifndef MSWIN
|| (!p_fic && (flags & EW_ICASE) && mb_isalpha(utf_ptr2char((char *)path_end)))
#endif
- )) {
+ )) { // NOLINT(whitespace/parens)
e = p;
}
len = (size_t)(utfc_ptr2len((char *)path_end));
@@ -787,7 +787,7 @@ static int find_previous_pathsep(char_u *path, char_u **psep)
{
// skip the current separator
if (*psep > path && vim_ispathsep(**psep)) {
- --*psep;
+ (*psep)--;
}
// find the previous separator
diff --git a/src/nvim/tag.c b/src/nvim/tag.c
index a8d8eebb0d..4658aed235 100644
--- a/src/nvim/tag.c
+++ b/src/nvim/tag.c
@@ -220,8 +220,7 @@ bool do_tag(char *tag, int type, int count, int forceit, int verbose)
if (*tag != NUL
&& (type == DT_TAG || type == DT_SELECT || type == DT_JUMP
|| type == DT_LTAG
- || type == DT_CSCOPE
- )) {
+ || type == DT_CSCOPE)) {
if (g_do_tagpreview != 0) {
if (ptag_entry.tagname != NULL
&& strcmp(ptag_entry.tagname, tag) == 0) {
diff --git a/src/nvim/window.c b/src/nvim/window.c
index d99d22af12..c18f8ca6a3 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -2583,7 +2583,7 @@ static bool close_last_window_tabpage(win_T *win, bool free_buf, tabpage_T *prev
// save index for tabclosed event
char_u prev_idx[NUMBUFLEN];
- sprintf((char *)prev_idx, "%i", tabpage_index(prev_curtab));
+ snprintf((char *)prev_idx, NUMBUFLEN, "%i", tabpage_index(prev_curtab));
// Safety check: Autocommands may have closed the window when jumping
// to the other tab page.