mirror of
https://github.com/neovim/neovim.git
synced 2025-09-27 21:48:35 +00:00
Call to list_append_number cannot fail.
Clean up the use of list_append_number and remove error checks.
This commit is contained in:

committed by
Thiago de Arruda

parent
1a5505c46b
commit
6797a3e788
44
src/eval.c
44
src/eval.c
@@ -471,7 +471,7 @@ static int dict_equal(dict_T *d1, dict_T *d2, int ic, int recursive);
|
|||||||
static int tv_equal(typval_T *tv1, typval_T *tv2, int ic, int recursive);
|
static int tv_equal(typval_T *tv1, typval_T *tv2, int ic, int recursive);
|
||||||
static long list_find_nr(list_T *l, long idx, int *errorp);
|
static long list_find_nr(list_T *l, long idx, int *errorp);
|
||||||
static long list_idx_of_item(list_T *l, listitem_T *item);
|
static long list_idx_of_item(list_T *l, listitem_T *item);
|
||||||
static int list_append_number(list_T *l, varnumber_T n);
|
static void list_append_number(list_T *l, varnumber_T n);
|
||||||
static int list_extend(list_T *l1, list_T *l2, listitem_T *bef);
|
static int list_extend(list_T *l1, list_T *l2, listitem_T *bef);
|
||||||
static int list_concat(list_T *l1, list_T *l2, typval_T *tv);
|
static int list_concat(list_T *l1, list_T *l2, typval_T *tv);
|
||||||
static list_T *list_copy(list_T *orig, int deep, int copyID);
|
static list_T *list_copy(list_T *orig, int deep, int copyID);
|
||||||
@@ -2672,10 +2672,7 @@ static void set_var_lval(lval_T *lp, char_u *endp, typval_T *rettv, int copy, ch
|
|||||||
break;
|
break;
|
||||||
if (lp->ll_li->li_next == NULL) {
|
if (lp->ll_li->li_next == NULL) {
|
||||||
/* Need to add an empty item. */
|
/* Need to add an empty item. */
|
||||||
if (list_append_number(lp->ll_list, 0) == FAIL) {
|
list_append_number(lp->ll_list, 0);
|
||||||
ri = NULL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
lp->ll_li = lp->ll_li->li_next;
|
lp->ll_li = lp->ll_li->li_next;
|
||||||
++lp->ll_n1;
|
++lp->ll_n1;
|
||||||
@@ -5569,20 +5566,14 @@ void list_append_string(list_T *l, char_u *str, int len)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Append "n" to list "l".
|
* Append "n" to list "l".
|
||||||
* Returns FAIL when out of memory.
|
|
||||||
*/
|
*/
|
||||||
static int list_append_number(list_T *l, varnumber_T n)
|
static void list_append_number(list_T *l, varnumber_T n)
|
||||||
{
|
{
|
||||||
listitem_T *li;
|
listitem_T *li = listitem_alloc();
|
||||||
|
|
||||||
li = listitem_alloc();
|
|
||||||
if (li == NULL)
|
|
||||||
return FAIL;
|
|
||||||
li->li_tv.v_type = VAR_NUMBER;
|
li->li_tv.v_type = VAR_NUMBER;
|
||||||
li->li_tv.v_lock = 0;
|
li->li_tv.v_lock = 0;
|
||||||
li->li_tv.vval.v_number = n;
|
li->li_tv.vval.v_number = n;
|
||||||
list_append(l, li);
|
list_append(l, li);
|
||||||
return OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -12059,10 +12050,9 @@ static void f_range(typval_T *argvars, typval_T *rettv)
|
|||||||
EMSG(_("E727: Start past end"));
|
EMSG(_("E727: Start past end"));
|
||||||
else {
|
else {
|
||||||
if (rettv_list_alloc(rettv) == OK)
|
if (rettv_list_alloc(rettv) == OK)
|
||||||
for (i = start; stride > 0 ? i <= end : i >= end; i += stride)
|
for (i = start; stride > 0 ? i <= end : i >= end; i += stride) {
|
||||||
if (list_append_number(rettv->vval.v_list,
|
list_append_number(rettv->vval.v_list, (varnumber_T)i);
|
||||||
(varnumber_T)i) == FAIL)
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -14658,8 +14648,6 @@ static void f_synstack(typval_T *argvars, typval_T *rettv)
|
|||||||
{
|
{
|
||||||
long lnum;
|
long lnum;
|
||||||
long col;
|
long col;
|
||||||
int i;
|
|
||||||
int id;
|
|
||||||
|
|
||||||
rettv->v_type = VAR_LIST;
|
rettv->v_type = VAR_LIST;
|
||||||
rettv->vval.v_list = NULL;
|
rettv->vval.v_list = NULL;
|
||||||
@@ -14671,12 +14659,11 @@ static void f_synstack(typval_T *argvars, typval_T *rettv)
|
|||||||
&& col >= 0 && col <= (long)STRLEN(ml_get(lnum))
|
&& col >= 0 && col <= (long)STRLEN(ml_get(lnum))
|
||||||
&& rettv_list_alloc(rettv) != FAIL) {
|
&& rettv_list_alloc(rettv) != FAIL) {
|
||||||
(void)syn_get_id(curwin, lnum, (colnr_T)col, FALSE, NULL, TRUE);
|
(void)syn_get_id(curwin, lnum, (colnr_T)col, FALSE, NULL, TRUE);
|
||||||
for (i = 0;; ++i) {
|
|
||||||
id = syn_get_stack_item(i);
|
int id;
|
||||||
if (id < 0)
|
int i = 0;
|
||||||
break;
|
while ((id = syn_get_stack_item(i++)) >= 0) {
|
||||||
if (list_append_number(rettv->vval.v_list, id) == FAIL)
|
list_append_number(rettv->vval.v_list, id);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -14781,10 +14768,9 @@ static void f_tabpagebuflist(typval_T *argvars, typval_T *rettv)
|
|||||||
wp = (tp == curtab) ? firstwin : tp->tp_firstwin;
|
wp = (tp == curtab) ? firstwin : tp->tp_firstwin;
|
||||||
}
|
}
|
||||||
if (wp != NULL && rettv_list_alloc(rettv) != FAIL) {
|
if (wp != NULL && rettv_list_alloc(rettv) != FAIL) {
|
||||||
for (; wp != NULL; wp = wp->w_next)
|
for (; wp != NULL; wp = wp->w_next) {
|
||||||
if (list_append_number(rettv->vval.v_list,
|
list_append_number(rettv->vval.v_list, wp->w_buffer->b_fnum);
|
||||||
wp->w_buffer->b_fnum) == FAIL)
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user