aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2016-03-09 09:52:07 -0500
committerJustin M. Keyes <justinkz@gmail.com>2019-01-02 21:06:37 +0100
commita70fde1b45859bbe557261493bfff40aa90d469a (patch)
tree50589bf680a676fe7e0ba7b3d8bd527971d1ca22 /src/nvim/eval.c
parent5fba8159213e7821d16cdbea379cb49ac8a6ee74 (diff)
downloadrneovim-a70fde1b45859bbe557261493bfff40aa90d469a.tar.gz
rneovim-a70fde1b45859bbe557261493bfff40aa90d469a.tar.bz2
rneovim-a70fde1b45859bbe557261493bfff40aa90d469a.zip
build: enable -Wshadow
Note about shada.c: - shada_read_next_item_start was intentionally shadowing `unpacked` and `i` because many of the macros (e.g. ADDITIONAL_KEY) implicitly depended on those variable names. - Macros were changed to parameterize `unpacked` (but not `i`). Macros like CLEAR_GA_AND_ERROR_OUT do control-flow (goto), so any other approach is messy.
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r--src/nvim/eval.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index f1cce716e0..460e454048 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -2380,7 +2380,7 @@ static void set_var_lval(lval_T *lp, char_u *endp, typval_T *rettv,
int ll_n1 = lp->ll_n1;
// Check whether any of the list items is locked
- for (listitem_T *ri = tv_list_first(rettv->vval.v_list);
+ for (ri = tv_list_first(rettv->vval.v_list);
ri != NULL && ll_li != NULL; ) {
if (tv_check_lock(TV_LIST_ITEM_TV(ll_li)->v_lock,
(const char *)lp->ll_name,
@@ -2476,9 +2476,9 @@ notify:
assert(lp->ll_newkey != NULL);
tv_dict_watcher_notify(dict, (char *)lp->ll_newkey, lp->ll_tv, NULL);
} else {
- dictitem_T *di = lp->ll_di;
- assert(di->di_key != NULL);
- tv_dict_watcher_notify(dict, (char *)di->di_key, lp->ll_tv, &oldtv);
+ dictitem_T *di_ = lp->ll_di;
+ assert(di_->di_key != NULL);
+ tv_dict_watcher_notify(dict, (char *)di_->di_key, lp->ll_tv, &oldtv);
tv_clear(&oldtv);
}
}
@@ -5234,8 +5234,6 @@ bool garbage_collect(bool testing)
/// @return true, if something was freed.
static int free_unref_items(int copyID)
{
- dict_T *dd, *dd_next;
- list_T *ll, *ll_next;
bool did_free = false;
// Let all "free" functions know that we are here. This means no
@@ -5273,14 +5271,16 @@ static int free_unref_items(int copyID)
}
// PASS 2: free the items themselves.
- for (dd = gc_first_dict; dd != NULL; dd = dd_next) {
+ dict_T *dd_next;
+ for (dict_T *dd = gc_first_dict; dd != NULL; dd = dd_next) {
dd_next = dd->dv_used_next;
if ((dd->dv_copyID & COPYID_MASK) != (copyID & COPYID_MASK)) {
tv_dict_free_dict(dd);
}
}
- for (ll = gc_first_list; ll != NULL; ll = ll_next) {
+ list_T *ll_next;
+ for (list_T *ll = gc_first_list; ll != NULL; ll = ll_next) {
ll_next = ll->lv_used_next;
if ((ll->lv_copyID & COPYID_MASK) != (copyID & COPYID_MASK)
&& !tv_list_has_watchers(ll)) {
@@ -11508,23 +11508,23 @@ static void dict_list(typval_T *const tv, typval_T *const rettv,
tv_list_alloc_ret(rettv, tv_dict_len(tv->vval.v_dict));
TV_DICT_ITER(tv->vval.v_dict, di, {
- typval_T tv = { .v_lock = VAR_UNLOCKED };
+ typval_T tv_item = { .v_lock = VAR_UNLOCKED };
switch (what) {
case kDictListKeys: {
- tv.v_type = VAR_STRING;
- tv.vval.v_string = vim_strsave(di->di_key);
+ tv_item.v_type = VAR_STRING;
+ tv_item.vval.v_string = vim_strsave(di->di_key);
break;
}
case kDictListValues: {
- tv_copy(&di->di_tv, &tv);
+ tv_copy(&di->di_tv, &tv_item);
break;
}
case kDictListItems: {
// items()
list_T *const sub_l = tv_list_alloc(2);
- tv.v_type = VAR_LIST;
- tv.vval.v_list = sub_l;
+ tv_item.v_type = VAR_LIST;
+ tv_item.vval.v_list = sub_l;
tv_list_ref(sub_l);
tv_list_append_owned_tv(sub_l, (typval_T) {
@@ -11539,7 +11539,7 @@ static void dict_list(typval_T *const tv, typval_T *const rettv,
}
}
- tv_list_append_owned_tv(rettv->vval.v_list, tv);
+ tv_list_append_owned_tv(rettv->vval.v_list, tv_item);
});
}
@@ -14785,12 +14785,12 @@ static void f_setmatches(typval_T *argvars, typval_T *rettv, FunPtr fptr)
list_T *const l = argvars[0].vval.v_list;
// To some extent make sure that we are dealing with a list from
// "getmatches()".
- int i = 0;
+ int li_idx = 0;
TV_LIST_ITER_CONST(l, li, {
if (TV_LIST_ITEM_TV(li)->v_type != VAR_DICT
|| (d = TV_LIST_ITEM_TV(li)->vval.v_dict) == NULL) {
emsgf(_("E474: List item %d is either not a dictionary "
- "or an empty one"), i);
+ "or an empty one"), li_idx);
return;
}
if (!(tv_dict_find(d, S_LEN("group")) != NULL
@@ -14798,10 +14798,11 @@ static void f_setmatches(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|| tv_dict_find(d, S_LEN("pos1")) != NULL)
&& tv_dict_find(d, S_LEN("priority")) != NULL
&& tv_dict_find(d, S_LEN("id")) != NULL)) {
- emsgf(_("E474: List item %d is missing one of the required keys"), i);
+ emsgf(_("E474: List item %d is missing one of the required keys"),
+ li_idx);
return;
}
- i++;
+ li_idx++;
});
clear_matches(curwin);