]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0686: style: strcmp usage is inconsistent v9.2.0686
authorDoug Kearns <dougkearns@gmail.com>
Sun, 21 Jun 2026 13:31:40 +0000 (13:31 +0000)
committerChristian Brabandt <cb@256bit.org>
Sun, 21 Jun 2026 13:31:40 +0000 (13:31 +0000)
Problem:  style: strcmp usage is inconsistent.
Solution: Always explicitly test the return value, matching the dominant
          style.

closes: #19101

Signed-off-by: Doug Kearns <dougkearns@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/channel.c
src/cindent.c
src/gui_w32.c
src/hardcopy.c
src/map.c
src/message.c
src/misc1.c
src/search.c
src/tag.c
src/version.c

index cfbfcb2bec95cedc114e041643c79a92af52f455..d7fa3bd2c729ebf184ecce18940724cf9858fd73 100644 (file)
@@ -1308,7 +1308,7 @@ channel_parse_socketserver_address(
     if (*address == NUL)
        goto fail;
 
-    if (!STRNCMP(address, "unix:", 5))
+    if (STRNCMP(address, "unix:", 5) == 0)
     {
        *unix_path = vim_strsave(address + 5);
        return OK;
@@ -1361,7 +1361,7 @@ channel_open_func(typval_T *argvars)
        return NULL;
     }
 
-    if (!STRNCMP(address, "unix:", 5))
+    if (STRNCMP(address, "unix:", 5) == 0)
     {
        is_unix = TRUE;
        address += 5;
@@ -1458,7 +1458,7 @@ channel_listen_func(typval_T *argvars)
        return NULL;
     }
 
-    if (!STRNCMP(arg, "unix:", 5))
+    if (STRNCMP(arg, "unix:", 5) == 0)
     {
        is_unix = TRUE;
        arg += 5;
index fa8059509ea2bc0d0a57ef7da7be9f2f1339f2d7..6bea836e2eec9e4a6a57f0cd2ef6abdf1a52cedf 100644 (file)
@@ -748,7 +748,7 @@ cin_is_compound_init(char_u *s)
     {
        if (*p == '=')
            p = r = cin_skipcomment(p + 1);
-       else if (!STRNCMP(p, "return", 6) && !vim_isIDc(p[6])
+       else if (STRNCMP(p, "return", 6) == 0 && !vim_isIDc(p[6])
                && (p == s || (p > s && !vim_isIDc(p[-1]))))
            p = r = cin_skipcomment(p + 6);
        else
@@ -1424,19 +1424,19 @@ cin_is_if_for_while_before_offset(char_u *line, int *poffset)
        --offset;
 
     offset -= 1;
-    if (!STRNCMP(line + offset, "if", 2))
+    if (STRNCMP(line + offset, "if", 2) == 0)
        goto probablyFound;
 
     if (offset >= 1)
     {
        offset -= 1;
-       if (!STRNCMP(line + offset, "for", 3))
+       if (STRNCMP(line + offset, "for", 3) == 0)
            goto probablyFound;
 
        if (offset >= 2)
        {
            offset -= 2;
-           if (!STRNCMP(line + offset, "while", 5))
+           if (STRNCMP(line + offset, "while", 5) == 0)
                goto probablyFound;
        }
     }
index d84190091cb067613b6d4d116c0b22ab1ef3695d..077ca9c1f7882bd0e5c0f844e1827071e503c036 100644 (file)
@@ -9113,11 +9113,11 @@ gui_mch_register_sign(char_u *signfile)
     {
        int do_load = 1;
 
-       if (!STRICMP(ext, ".bmp"))
+       if (STRICMP(ext, ".bmp") == 0)
            sign.uType =  IMAGE_BITMAP;
-       else if (!STRICMP(ext, ".ico"))
+       else if (STRICMP(ext, ".ico") == 0)
            sign.uType =  IMAGE_ICON;
-       else if (!STRICMP(ext, ".cur") || !STRICMP(ext, ".ani"))
+       else if (STRICMP(ext, ".cur") == 0 || STRICMP(ext, ".ani") == 0)
            sign.uType =  IMAGE_CURSOR;
        else
            do_load = 0;
@@ -9127,7 +9127,7 @@ gui_mch_register_sign(char_u *signfile)
                    gui.char_width * 2, gui.char_height,
                    LR_LOADFROMFILE | LR_CREATEDIBSECTION);
 # ifdef FEAT_XPM_W32
-       if (!STRICMP(ext, ".xpm"))
+       if (STRICMP(ext, ".xpm") == 0)
        {
            sign.uType = IMAGE_XPM;
            LoadXpmImage((char *)signfile, (HBITMAP *)&sign.hImage,
index 2eb63ea5889388bb5ef8a7edeff41f04ef1599e5..10c3beb8f1444893cd8417bc75dfeee4ab833d0b 100644 (file)
@@ -1959,7 +1959,7 @@ prt_open_resource(struct prt_ps_resource_S *resource)
 prt_check_resource(struct prt_ps_resource_S *resource, char_u *version)
 {
     // Version number m.n should match, the revision number does not matter
-    if (STRNCMP(resource->version, version, STRLEN(version)))
+    if (STRNCMP(resource->version, version, STRLEN(version)) != 0)
     {
        semsg(_(e_str_resource_file_has_wrong_version),
                resource->name);
index 5970b3f5a520380a10752c1867bf6d06234fda1e..b19f747d0cd75b0202780368d0da6ca819e97fb5 100644 (file)
--- a/src/map.c
+++ b/src/map.c
@@ -1554,7 +1554,7 @@ ExpandMappings(
 
        while (ptr2 < ptr3)
        {
-           if (STRCMP(*ptr1, *ptr2))
+           if (STRCMP(*ptr1, *ptr2) != 0)
                *++ptr1 = *ptr2++;
            else
            {
@@ -1694,7 +1694,7 @@ check_abbr(
            // find entries with right mode and keys
            match =    (mp->m_mode & State)
                    && qlen == len
-                   && !STRNCMP(q, ptr, (size_t)len);
+                   && STRNCMP(q, ptr, (size_t)len) == 0;
            if (q != mp->m_keys)
                vim_free(q);
            if (match)
index b0d09f6da6a4e55e92772d1fa28244c6bd33bb24..de56ddcb932a037b09dce16000c0d41a212b14a9 100644 (file)
@@ -174,7 +174,7 @@ msg_attr_keep(
            || (*s != '<'
                && last_msg_hist != NULL
                && last_msg_hist->msg != NULL
-               && STRCMP(s, last_msg_hist->msg)))
+               && STRCMP(s, last_msg_hist->msg) != 0))
        add_msg_hist((char_u *)s, -1, attr);
 
 #ifdef FEAT_EVAL
index 88e872d766d489325a490c18faa4fe2118021772..c09ae8127548751d11a2ff4f5bcac5aa5eadc869 100644 (file)
@@ -316,7 +316,7 @@ get_last_leader_offset(char_u *line, char_u **flags)
                for (off = (len2 > i ? i : len2); off > 0 && off + len1 > len2;)
                {
                    --off;
-                   if (!STRNCMP(string + off, com_leader, len2 - off))
+                   if (STRNCMP(string + off, com_leader, len2 - off) == 0)
                    {
                        if (i - off < lower_check_bound)
                            lower_check_bound = i - off;
index 12977dc8fafba616879d193e56cb48bff8855f81..e60f2d7b4329d1a646ae4a29bccecdea065c576b 100644 (file)
@@ -3816,9 +3816,9 @@ search_line:
                    // compare the first "len" chars from "ptr"
                    startp = skipwhite(p);
                    if (p_ic)
-                       matched = !MB_STRNICMP(startp, ptr, len);
+                       matched = MB_STRNICMP(startp, ptr, len) == 0;
                    else
-                       matched = !STRNCMP(startp, ptr, len);
+                       matched = STRNCMP(startp, ptr, len) == 0;
                    if (matched && define_matched && whole
                                                  && vim_iswordc(startp[len]))
                        matched = FALSE;
index 24d33bc11d0af3d349e8da09cc8ed419194edcce..0e9d9344bf78295287e1385770bdbf113c200cd9 100644 (file)
--- a/src/tag.c
+++ b/src/tag.c
@@ -1535,23 +1535,23 @@ find_tagfunc_tags(
                continue;
 
            len += (int)STRLEN(tv->vval.v_string) + 1;   // Space for "\tVALUE"
-           if (!STRCMP(dict_key, "name"))
+           if (STRCMP(dict_key, "name") == 0)
            {
                res_name = tv->vval.v_string;
                continue;
            }
-           if (!STRCMP(dict_key, "filename"))
+           if (STRCMP(dict_key, "filename") == 0)
            {
                res_fname = tv->vval.v_string;
                continue;
            }
-           if (!STRCMP(dict_key, "cmd"))
+           if (STRCMP(dict_key, "cmd") == 0)
            {
                res_cmd = tv->vval.v_string;
                continue;
            }
            has_extra = 1;
-           if (!STRCMP(dict_key, "kind"))
+           if (STRCMP(dict_key, "kind") == 0)
            {
                res_kind = tv->vval.v_string;
                continue;
@@ -1617,13 +1617,13 @@ find_tagfunc_tags(
                    if (tv->v_type != VAR_STRING || tv->vval.v_string == NULL)
                        continue;
 
-                   if (!STRCMP(dict_key, "name"))
+                   if (STRCMP(dict_key, "name") == 0)
                        continue;
-                   if (!STRCMP(dict_key, "filename"))
+                   if (STRCMP(dict_key, "filename") == 0)
                        continue;
-                   if (!STRCMP(dict_key, "cmd"))
+                   if (STRCMP(dict_key, "cmd") == 0)
                        continue;
-                   if (!STRCMP(dict_key, "kind"))
+                   if (STRCMP(dict_key, "kind") == 0)
                        continue;
 
                    *p++ = TAB;
index 3f925d14753b3d9d5e18cacdc852be95bbff28a3..c640b1c60ca0d5b0a92859f46aa0936e14dc3c12 100644 (file)
@@ -759,6 +759,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    686,
 /**/
     685,
 /**/