]> granicus.if.org Git - vim/commitdiff
patch 8.1.0753: printf format not checked for semsg() v8.1.0753
authorBram Moolenaar <Bram@vim.org>
Tue, 15 Jan 2019 19:19:40 +0000 (20:19 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 15 Jan 2019 19:19:40 +0000 (20:19 +0100)
Problem:    printf format not checked for semsg().
Solution:   Add GNUC attribute and fix reported problems. (Dominique Pelle,
            closes #3805)

16 files changed:
src/buffer.c
src/diff.c
src/eval.c
src/evalfunc.c
src/ex_docmd.c
src/gui_x11.c
src/if_cscope.c
src/netbeans.c
src/proto.h
src/proto/message.pro
src/quickfix.c
src/regexp_nfa.c
src/sign.c
src/spellfile.c
src/version.c
src/window.c

index fd29be704383f9689b65464d5352d116286b12c1..6bacb16384f36bdf133562b4cd29bc65122de1a9 100644 (file)
@@ -1407,7 +1407,7 @@ do_buffer(
            else
 #endif
            {
-               semsg(_("E89: No write since last change for buffer %ld (add ! to override)"),
+               semsg(_("E89: No write since last change for buffer %d (add ! to override)"),
                                                                 buf->b_fnum);
                return FAIL;
            }
@@ -2283,7 +2283,7 @@ buflist_getfile(
        if ((options & GETF_ALT) && n == 0)
            emsg(_(e_noalt));
        else
-           semsg(_("E92: Buffer %ld not found"), n);
+           semsg(_("E92: Buffer %d not found"), n);
        return FAIL;
     }
 
index 3acedc786d17828cb655cc72ba0d06d27c526760..ed63f51ee7b8ef17fff1395acc83c21f8292c89f 100644 (file)
@@ -173,7 +173,7 @@ diff_buf_add(buf_T *buf)
            return;
        }
 
-    semsg(_("E96: Cannot diff more than %ld buffers"), DB_COUNT);
+    semsg(_("E96: Cannot diff more than %d buffers"), DB_COUNT);
 }
 
 /*
index 00549365ecde390ab74402d182380a27066e0ae0..049d15cee2e593590b53e9660f98cc7200316606 100644 (file)
@@ -268,7 +268,7 @@ compare_func_name(const void *s1, const void *s2)
 
 /*
  * Sort the function table by function name.
- * The sorting of the table above is ASCII dependant.
+ * The sorting of the table above is ASCII dependent.
  * On machines using EBCDIC we have to sort it.
  */
     static void
index 8870fd4329641ddabeb944c70ecbfae474a00425..da4ffbf81e25a5b9a21e689b6d34200dd9e19a17 100644 (file)
@@ -8256,7 +8256,7 @@ f_matchadd(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
        return;
     if (id >= 1 && id <= 3)
     {
-       semsg(_("E798: ID is reserved for \":match\": %ld"), id);
+       semsg(_("E798: ID is reserved for \":match\": %d"), id);
        return;
     }
 
@@ -8314,7 +8314,7 @@ f_matchaddpos(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
     /* id == 3 is ok because matchaddpos() is supposed to substitute :3match */
     if (id == 1 || id == 2)
     {
-       semsg(_("E798: ID is reserved for \":match\": %ld"), id);
+       semsg(_("E798: ID is reserved for \":match\": %d"), id);
        return;
     }
 
index dddbf8304fcdf1b56a2671aa690b273491c5a803..7dc805ec1e7a0d206fadeee04b62ec9a6e4306a7 100644 (file)
@@ -1347,7 +1347,7 @@ do_cmdline(
            }
            else if (p != NULL)
            {
-               semsg(p);
+               emsg(p);
                vim_free(p);
            }
            vim_free(sourcing_name);
@@ -5788,8 +5788,8 @@ check_more(
                return FAIL;
            }
 #endif
-           semsg(NGETTEXT("E173: %ld more file to edit",
-                       "E173: %ld more files to edit", n), n);
+           semsg(NGETTEXT("E173: %d more file to edit",
+                       "E173: %d more files to edit", n), n);
            quitmore = 2;           /* next try to quit is allowed */
        }
        return FAIL;
@@ -6958,7 +6958,7 @@ do_ucmd(exarg_T *eap)
                }
            }
 
-           /* break if there no <item> is found */
+           /* break if no <item> is found */
            if (start == NULL || end == NULL)
                break;
 
@@ -8022,7 +8022,7 @@ handle_drop_internal(void)
 /*
  * Handle a file drop. The code is here because a drop is *nearly* like an
  * :args command, but not quite (we have a list of exact filenames, so we
- * don't want to (a) parse a command line, or (b) expand wildcards. So the
+ * don't want to (a) parse a command line, or (b) expand wildcards). So the
  * code is very similar to :args and hence needs access to a lot of the static
  * functions in this file.
  *
index 91f166fa854b604b6d05f894112ddebb71031458..42fb7ca86ec7d4a5238a7cfbb535c4d971716615 100644 (file)
@@ -2210,9 +2210,10 @@ check_fontset_sanity(XFontSet fs)
            semsg(_("E253: Fontset name: %s"), base_name);
            semsg(_("Font0: %s"), font_name[min_font_idx]);
            semsg(_("Font1: %s"), font_name[i]);
-           semsg(_("Font%ld width is not twice that of font0"), i);
-           semsg(_("Font0 width: %ld"), xfs[min_font_idx]->max_bounds.width);
-           semsg(_("Font1 width: %ld"), xfs[i]->max_bounds.width);
+           semsg(_("Font%d width is not twice that of font0"), i);
+           semsg(_("Font0 width: %d"),
+                                    (int)xfs[min_font_idx]->max_bounds.width);
+           semsg(_("Font%d width: %d"), i, (int)xfs[i]->max_bounds.width);
            return FAIL;
        }
     }
index e1408b2f3db26a9c299a76d0e6751728b7b657e1..4904424d15129d9f3e007a045ffad6b38ee01f27 100644 (file)
@@ -651,7 +651,7 @@ cs_cnt_connections(void)
 cs_reading_emsg(
     int idx)   /* connection index */
 {
-    semsg(_("E262: error reading cscope connection %ld"), idx);
+    semsg(_("E262: error reading cscope connection %d"), idx);
 }
 
 #define        CSREAD_BUFSIZE  2048
index eb61b31070abf9a178950f1393289beb962f73c2..65b2f70918e240ea7a0c050bf406cedaefe4a3a3 100644 (file)
@@ -1541,7 +1541,7 @@ nb_do_cmd(
                if (!buf->bufp->b_netbeans_file)
                {
                    nbdebug(("E658: NetBeans connection lost for buffer %ld\n", buf->bufp->b_fnum));
-                   semsg(_("E658: NetBeans connection lost for buffer %ld"),
+                   semsg(_("E658: NetBeans connection lost for buffer %d"),
                                                           buf->bufp->b_fnum);
                }
                else
index 653c089d822e991b8b9997bdfe1e1e944f849c7b..48c7b4d00a5073282790e88f3d4fb764d6ea4382 100644 (file)
@@ -108,19 +108,31 @@ int
 #  ifdef __BORLANDC__
 _RTLENTRYF
 #  endif
-smsg(const char *, ...);
+smsg(const char *, ...)
+#ifdef USE_PRINTF_FORMAT_ATTRIBUTE
+    __attribute__((format(printf, 1, 0)))
+#endif
+    ;
 
 int
 #  ifdef __BORLANDC__
 _RTLENTRYF
 #  endif
-smsg_attr(int, const char *, ...);
+smsg_attr(int, const char *, ...)
+#ifdef USE_PRINTF_FORMAT_ATTRIBUTE
+    __attribute__((format(printf, 2, 3)))
+#endif
+    ;
 
 int
 #  ifdef __BORLANDC__
 _RTLENTRYF
 #  endif
-smsg_attr_keep(int, const char *, ...);
+smsg_attr_keep(int, const char *, ...)
+#ifdef USE_PRINTF_FORMAT_ATTRIBUTE
+    __attribute__((format(printf, 2, 3)))
+#endif
+    ;
 
 int
 #  ifdef __BORLANDC__
index 9feeefb6a7a7bc16ba60ef5809a44100f6b7252d..588c3a7de628245c3b91263735eeccdc45578cff 100644 (file)
@@ -11,9 +11,18 @@ int emsg_not_now(void);
 void ignore_error_for_testing(char_u *error);
 void do_perror(char *msg);
 int emsg(char *s);
-int semsg(const char *s, ...);
+
+int semsg(const char *s, ...)
+#ifdef USE_PRINTF_FORMAT_ATTRIBUTE
+    __attribute__((format(printf, 1, 2)))
+#endif
+;
 void iemsg(char *s);
-void siemsg(const char *s, ...);
+void siemsg(const char *s, ...)
+#ifdef USE_PRINTF_FORMAT_ATTRIBUTE
+    __attribute__((format(printf, 1, 2)))
+#endif
+;
 void internal_error(char *where);
 void emsg_invreg(int name);
 char_u *msg_trunc_attr(char_u *s, int force, int attr);
index c533a28d342c92cabdea6f237a0e00eca4547de0..4e1e8e0614818e04ace56faa0b2366edd3dc8e47 100644 (file)
@@ -6263,7 +6263,7 @@ qf_add_entry_from_dict(
        if (!did_bufnr_emsg)
        {
            did_bufnr_emsg = TRUE;
-           semsg(_("E92: Buffer %ld not found"), bufnum);
+           semsg(_("E92: Buffer %d not found"), bufnum);
        }
        valid = FALSE;
        bufnum = 0;
index 15547bbdf9c1f453585091256e87681a99ef6ca2..f631f605f15afa9323253065ec113b448de76e63 100644 (file)
@@ -1307,7 +1307,7 @@ nfa_regatom(void)
                    rc_did_emsg = TRUE;
                    return FAIL;
                }
-               siemsg("INTERNAL: Unknown character class char: %ld", c);
+               siemsg("INTERNAL: Unknown character class char: %d", c);
                return FAIL;
            }
 #ifdef FEAT_MBYTE
index 734dd257e04f8a6ffd0e001a0730fb7821b96b8d..6f7ead96327c391aba4aecf1a97108c88cf23a95 100644 (file)
@@ -162,7 +162,7 @@ sign_group_get_next_signid(buf_T *buf, char_u *groupname)
        group = HI2SG(hi);
     }
 
-    // Search for the next usuable sign identifier
+    // Search for the next usable sign identifier
     while (!found)
     {
        if (group == NULL)
@@ -996,7 +996,7 @@ sign_jump(int sign_id, char_u *sign_group, buf_T *buf)
 
     if ((lnum = buf_findsign(buf, sign_id, sign_group)) <= 0)
     {
-       semsg(_("E157: Invalid sign ID: %ld"), sign_id);
+       semsg(_("E157: Invalid sign ID: %d"), sign_id);
        return -1;
     }
 
index 3d684098ead656b1c2b90d3cedc3f694b41bea35..bf580eb6553428e2fbdcd22cd61bb721aeae7f25 100644 (file)
@@ -6014,7 +6014,7 @@ mkspell(
     else if (vim_strchr(gettail(wfname), '_') != NULL)
        emsg(_("E751: Output file name must not have region name"));
     else if (incount > MAXREGIONS)
-       semsg(_("E754: Only up to %ld regions supported"), MAXREGIONS);
+       semsg(_("E754: Only up to %d regions supported"), MAXREGIONS);
     else
     {
        /* Check for overwriting before doing things that may take a lot of
@@ -6274,7 +6274,7 @@ spell_add_word(
                break;
            if (*spf == NUL)
            {
-               semsg(_("E765: 'spellfile' does not have %ld entries"), idx);
+               semsg(_("E765: 'spellfile' does not have %d entries"), idx);
                vim_free(fnamebuf);
                return;
            }
index 2930e758f32407a5730f4f309fc4d577c4737b9b..708f96f9cfecfd3510706216f48a30b035e302e5 100644 (file)
@@ -795,6 +795,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    753,
 /**/
     752,
 /**/
index 995debe2a3686788aa8c609ddb9cb43744238df7..f9b4999008742ca627ee596c0be1ac74cfdf11a4 100644 (file)
@@ -6782,7 +6782,7 @@ match_add(
        return -1;
     if (id < -1 || id == 0)
     {
-       semsg(_("E799: Invalid ID: %ld (must be greater than or equal to 1)"), id);
+       semsg(_("E799: Invalid ID: %d (must be greater than or equal to 1)"), id);
        return -1;
     }
     if (id != -1)
@@ -6792,7 +6792,7 @@ match_add(
        {
            if (cur->id == id)
            {
-               semsg(_("E801: ID already taken: %ld"), id);
+               semsg(_("E801: ID already taken: %d"), id);
                return -1;
            }
            cur = cur->next;
@@ -6969,7 +6969,7 @@ match_delete(win_T *wp, int id, int perr)
     if (id < 1)
     {
        if (perr == TRUE)
-           semsg(_("E802: Invalid ID: %ld (must be greater than or equal to 1)"),
+           semsg(_("E802: Invalid ID: %d (must be greater than or equal to 1)"),
                                                                          id);
        return -1;
     }
@@ -6981,7 +6981,7 @@ match_delete(win_T *wp, int id, int perr)
     if (cur == NULL)
     {
        if (perr == TRUE)
-           semsg(_("E803: ID not found: %ld"), id);
+           semsg(_("E803: ID not found: %d"), id);
        return -1;
     }
     if (cur == prev)