]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.1251: checking returned value of ga_grow() is inconsistent v9.0.1251
authorYegappan Lakshmanan <yegappan@yahoo.com>
Fri, 27 Jan 2023 21:03:12 +0000 (21:03 +0000)
committerBram Moolenaar <Bram@vim.org>
Fri, 27 Jan 2023 21:03:12 +0000 (21:03 +0000)
Problem:    Checking returned value of ga_grow() is inconsistent.
Solution:   Check for FAIL instaed of "not OK". (Yegappan Lakshmanan,
            closes #11897)

12 files changed:
src/digraph.c
src/evalfunc.c
src/fold.c
src/getchar.c
src/map.c
src/os_win32.c
src/scriptfile.c
src/spellfile.c
src/syntax.c
src/tag.c
src/usercmd.c
src/version.c

index ac51d50a79cc1f60743889f1bf410d7049cda1f7..fb45c1524869bf6a79cdfe5e848a50ed5d064a51 100644 (file)
@@ -1682,7 +1682,7 @@ registerdigraph(int char1, int char2, int n)
     }
 
     // Add a new digraph to the table.
-    if (ga_grow(&user_digraphs, 1) != OK)
+    if (ga_grow(&user_digraphs, 1) == FAIL)
        return;
 
     dp = (digr_T *)user_digraphs.ga_data + user_digraphs.ga_len;
index 7b34e3925b42f33e29cecbb116f219a0003e8b89..08f88471e3452ccacb13a88bbd62e3d2818921e7 100644 (file)
@@ -3966,7 +3966,7 @@ execute_redir_str(char_u *value, int value_len)
        len = (int)STRLEN(value);       // Append the entire string
     else
        len = value_len;                // Append only "value_len" characters
-    if (ga_grow(&redir_execute_ga, len) != OK)
+    if (ga_grow(&redir_execute_ga, len) == FAIL)
        return;
 
     mch_memmove((char *)redir_execute_ga.ga_data
index 589727d989afb2a3f87accbf474cde0ca136c382..be20991c7aacfb54adfd88233ec06d76bf336b94 100644 (file)
@@ -645,7 +645,7 @@ foldCreate(linenr_T start, linenr_T end)
            i = (int)(fp - (fold_T *)gap->ga_data);
     }
 
-    if (ga_grow(gap, 1) != OK)
+    if (ga_grow(gap, 1) == FAIL)
        return;
 
     fp = (fold_T *)gap->ga_data + i;
@@ -2884,7 +2884,7 @@ foldInsert(garray_T *gap, int i)
 {
     fold_T     *fp;
 
-    if (ga_grow(gap, 1) != OK)
+    if (ga_grow(gap, 1) == FAIL)
        return FAIL;
     fp = (fold_T *)gap->ga_data + i;
     if (gap->ga_len > 0 && i < gap->ga_len)
index f4dce0222ac79795defee1bad772151450e38676..2d30d4fb1688e0ea953870421c90f684bc022388 100644 (file)
@@ -3890,7 +3890,7 @@ getcmdkeycmd(
     got_int = FALSE;
     while (c1 != NUL && !aborted)
     {
-       if (ga_grow(&line_ga, 32) != OK)
+       if (ga_grow(&line_ga, 32) == FAIL)
        {
            aborted = TRUE;
            break;
index 244636fdc8583d15db228c9a61dbe068bbc06e9f..9be67cd74bd123e80cdca201a3cab36563f643e1 100644 (file)
--- a/src/map.c
+++ b/src/map.c
@@ -2983,7 +2983,7 @@ langmap_set_entry(int from, int to)
            b = i;
     }
 
-    if (ga_grow(&langmap_mapga, 1) != OK)
+    if (ga_grow(&langmap_mapga, 1) == FAIL)
        return;  // out of memory
 
     // insert new entry at position "a"
index e80533b017e79689c3ebc1c5b6f27822df85251c..884ef0d578dfc884160eb072104485dde1f61935 100644 (file)
@@ -5725,7 +5725,7 @@ win32_build_env(dict_T *env, garray_T *gap, int is_terminal)
                    size_t      lkey = wcslen(wkey);
                    size_t      lval = wcslen(wval);
 
-                   if (ga_grow(gap, (int)(lkey + lval + 2)) != OK)
+                   if (ga_grow(gap, (int)(lkey + lval + 2)) == FAIL)
                        continue;
                    for (n = 0; n < lkey; n++)
                        *((WCHAR*)gap->ga_data + gap->ga_len++) = wkey[n];
index 630a11696a2ed9f1b9c090c00a9941215f582ac8..008c7b3d41e8e2fd847b9810aaf7a2933f19399f 100644 (file)
@@ -56,7 +56,7 @@ estack_push(etype_T type, char_u *name, long lnum)
 
     // If memory allocation fails then we'll pop more than we push, eventually
     // at the top level it will be OK again.
-    if (ga_grow(&exestack, 1) != OK)
+    if (ga_grow(&exestack, 1) == FAIL)
        return NULL;
 
     entry = ((estack_T *)exestack.ga_data) + exestack.ga_len;
index 1a7bd1f4c21a3581d9a0b060861de28f3857ff15..710e4388f65ce6678900d93b19947d3e03eb459b 100644 (file)
@@ -3428,7 +3428,7 @@ add_fromto(
     fromto_T   *ftp;
     char_u     word[MAXWLEN];
 
-    if (ga_grow(gap, 1) != OK)
+    if (ga_grow(gap, 1) == FAIL)
        return;
 
     ftp = ((fromto_T *)gap->ga_data) + gap->ga_len;
index 614f52e2f687f94372e2118279214e904f25168b..719bc9c797e619245ae53b7f100e334e2b863aa6 100644 (file)
@@ -1438,7 +1438,7 @@ load_current_state(synstate_T *from)
     validate_current_state();
     keepend_level = -1;
     if (from->sst_stacksize
-           && ga_grow(&current_state, from->sst_stacksize) != FAIL)
+           && ga_grow(&current_state, from->sst_stacksize) == OK)
     {
        if (from->sst_stacksize > SST_FIX_STATES)
            bp = SYN_STATE_P(&(from->sst_union.sst_ga));
@@ -4946,7 +4946,7 @@ syn_cmd_match(
        set_nextcmd(eap, rest);
        if (!ends_excmd2(eap->cmd, rest) || eap->skip)
            rest = NULL;
-       else if (ga_grow(&curwin->w_s->b_syn_patterns, 1) != FAIL
+       else if (ga_grow(&curwin->w_s->b_syn_patterns, 1) == OK
                && (syn_id = syn_check_group(arg,
                                           (int)(group_name_end - arg))) != 0)
        {
@@ -5186,7 +5186,7 @@ syn_cmd_region(
        set_nextcmd(eap, rest);
        if (!ends_excmd(*rest) || eap->skip)
            rest = NULL;
-       else if (ga_grow(&(curwin->w_s->b_syn_patterns), pat_count) != FAIL
+       else if (ga_grow(&(curwin->w_s->b_syn_patterns), pat_count) == OK
                && (syn_id = syn_check_group(arg,
                                           (int)(group_name_end - arg))) != 0)
        {
index 66d6100d8f273cc7c18055a412c1701d36c906db..93768bc51999f681c8fec67e1664c4fcafa823ee 100644 (file)
--- a/src/tag.c
+++ b/src/tag.c
@@ -2739,7 +2739,7 @@ findtags_add_match(
        if (HASHITEM_EMPTY(hi))
        {
            if (hash_add_item(&st->ht_match[mtt], hi, mfp, *hash) == FAIL
-                   || ga_grow(&st->ga_match[mtt], 1) != OK)
+                   || ga_grow(&st->ga_match[mtt], 1) == FAIL)
            {
                // Out of memory! Just forget about the rest.
                st->stop_searching = TRUE;
index 9dcc20e7f44ab97312657d55d37efa63bf0ae7a7..44fa578f695a8f31bdb721b0f24192e929995b73 100644 (file)
@@ -1058,7 +1058,7 @@ uc_add_command(
     // Extend the array unless we're replacing an existing command
     if (cmp != 0)
     {
-       if (ga_grow(gap, 1) != OK)
+       if (ga_grow(gap, 1) == FAIL)
            goto fail;
        if ((p = vim_strnsave(name, name_len)) == NULL)
            goto fail;
index 0c31039c8926402fdc87bdc3b20b7b43e9635cef..64da4b30098df449317a994b7c2c4ca1dba07a62 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1251,
 /**/
     1250,
 /**/