summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-04-08 13:07:22 +0200
committerBram Moolenaar <Bram@vim.org>2018-04-08 13:07:22 +0200
commitea39176baab52b646d1e2676e662def718ddd365 (patch)
treeb7efd5049894e2dd699222f9614ffcf01e892480 /src
parent4ac2e8d8e60dcc7dbff662e177b86ccfbda7cd9e (diff)
downloadvim-git-ea39176baab52b646d1e2676e662def718ddd365.tar.gz
patch 8.0.1677: no compiler warning for wrong format in vim_snprintf()v8.0.1677
Problem: No compiler warning for wrong format in vim_snprintf(). Solution: Add printf attribute for gcc. Fix reported problems.
Diffstat (limited to 'src')
-rw-r--r--src/eval.c2
-rw-r--r--src/fileio.c4
-rw-r--r--src/json.c2
-rw-r--r--src/mbyte.c4
-rw-r--r--src/ops.c37
-rw-r--r--src/proto.h20
-rw-r--r--src/spellfile.c2
-rw-r--r--src/undo.c2
-rw-r--r--src/version.c2
-rw-r--r--src/vim.h7
10 files changed, 51 insertions, 31 deletions
diff --git a/src/eval.c b/src/eval.c
index c965d64f2..cfeba2eda 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -7105,7 +7105,7 @@ get_tv_string_buf_chk(typval_T *varp, char_u *buf)
{
case VAR_NUMBER:
vim_snprintf((char *)buf, NUMBUFLEN, "%lld",
- (varnumber_T)varp->vval.v_number);
+ (long long)varp->vval.v_number);
return buf;
case VAR_FUNC:
case VAR_PARTIAL:
diff --git a/src/fileio.c b/src/fileio.c
index e2fa3e22b..4f35cb965 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -5315,7 +5315,7 @@ msg_add_lines(
*p++ = ' ';
if (shortmess(SHM_LINES))
vim_snprintf((char *)p, IOSIZE - (p - IObuff),
- "%ldL, %lldC", lnum, (varnumber_T)nchars);
+ "%ldL, %lldC", lnum, (long long)nchars);
else
{
if (lnum == 1)
@@ -5327,7 +5327,7 @@ msg_add_lines(
STRCPY(p, _("1 character"));
else
vim_snprintf((char *)p, IOSIZE - (p - IObuff),
- _("%lld characters"), (varnumber_T)nchars);
+ _("%lld characters"), (long long)nchars);
}
}
diff --git a/src/json.c b/src/json.c
index e1f40bf65..cc756488d 100644
--- a/src/json.c
+++ b/src/json.c
@@ -217,7 +217,7 @@ json_encode_item(garray_T *gap, typval_T *val, int copyID, int options)
case VAR_NUMBER:
vim_snprintf((char *)numbuf, NUMBUFLEN, "%lld",
- val->vval.v_number);
+ (long long)val->vval.v_number);
ga_concat(gap, numbuf);
break;
diff --git a/src/mbyte.c b/src/mbyte.c
index cb2d2d93e..6d21f113e 100644
--- a/src/mbyte.c
+++ b/src/mbyte.c
@@ -5040,11 +5040,11 @@ im_preedit_window_open()
#else
gtk_widget_modify_font(preedit_label, gui.norm_font);
- vim_snprintf(buf, sizeof(buf), "#%06X", gui.norm_pixel);
+ vim_snprintf(buf, sizeof(buf), "#%06X", (unsigned)gui.norm_pixel);
gdk_color_parse(buf, &color);
gtk_widget_modify_fg(preedit_label, GTK_STATE_NORMAL, &color);
- vim_snprintf(buf, sizeof(buf), "#%06X", gui.back_pixel);
+ vim_snprintf(buf, sizeof(buf), "#%06X", (unsigned)gui.back_pixel);
gdk_color_parse(buf, &color);
gtk_widget_modify_bg(preedit_window, GTK_STATE_NORMAL, &color);
#endif
diff --git a/src/ops.c b/src/ops.c
index cb019cfd0..8b895d863 100644
--- a/src/ops.c
+++ b/src/ops.c
@@ -5976,13 +5976,17 @@ do_addsub(
buf2[i] = '\0';
}
else if (pre == 0)
- vim_snprintf((char *)buf2, NUMBUFLEN, "%llu", n);
+ vim_snprintf((char *)buf2, NUMBUFLEN, "%llu",
+ (long long unsigned)n);
else if (pre == '0')
- vim_snprintf((char *)buf2, NUMBUFLEN, "%llo", n);
+ vim_snprintf((char *)buf2, NUMBUFLEN, "%llo",
+ (long long unsigned)n);
else if (pre && hexupper)
- vim_snprintf((char *)buf2, NUMBUFLEN, "%llX", n);
+ vim_snprintf((char *)buf2, NUMBUFLEN, "%llX",
+ (long long unsigned)n);
else
- vim_snprintf((char *)buf2, NUMBUFLEN, "%llx", n);
+ vim_snprintf((char *)buf2, NUMBUFLEN, "%llx",
+ (long long unsigned)n);
length -= (int)STRLEN(buf2);
/*
@@ -7501,16 +7505,21 @@ cursor_pos_info(dict_T *dict)
_("Selected %s%ld of %ld Lines; %lld of %lld Words; %lld of %lld Bytes"),
buf1, line_count_selected,
(long)curbuf->b_ml.ml_line_count,
- word_count_cursor, word_count,
- byte_count_cursor, byte_count);
+ (long long)word_count_cursor,
+ (long long)word_count,
+ (long long)byte_count_cursor,
+ (long long)byte_count);
else
vim_snprintf((char *)IObuff, IOSIZE,
_("Selected %s%ld of %ld Lines; %lld of %lld Words; %lld of %lld Chars; %lld of %lld Bytes"),
buf1, line_count_selected,
(long)curbuf->b_ml.ml_line_count,
- word_count_cursor, word_count,
- char_count_cursor, char_count,
- byte_count_cursor, byte_count);
+ (long long)word_count_cursor,
+ (long long)word_count,
+ (long long)char_count_cursor,
+ (long long)char_count,
+ (long long)byte_count_cursor,
+ (long long)byte_count);
}
else
{
@@ -7528,17 +7537,17 @@ cursor_pos_info(dict_T *dict)
(char *)buf1, (char *)buf2,
(long)curwin->w_cursor.lnum,
(long)curbuf->b_ml.ml_line_count,
- word_count_cursor, word_count,
- byte_count_cursor, byte_count);
+ (long long)word_count_cursor, (long long)word_count,
+ (long long)byte_count_cursor, (long long)byte_count);
else
vim_snprintf((char *)IObuff, IOSIZE,
_("Col %s of %s; Line %ld of %ld; Word %lld of %lld; Char %lld of %lld; Byte %lld of %lld"),
(char *)buf1, (char *)buf2,
(long)curwin->w_cursor.lnum,
(long)curbuf->b_ml.ml_line_count,
- word_count_cursor, word_count,
- char_count_cursor, char_count,
- byte_count_cursor, byte_count);
+ (long long)word_count_cursor, (long long)word_count,
+ (long long)char_count_cursor, (long long)char_count,
+ (long long)byte_count_cursor, (long long)byte_count);
}
}
diff --git a/src/proto.h b/src/proto.h
index 5513746dd..231c53f3b 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -119,13 +119,21 @@ int
# ifdef __BORLANDC__
_RTLENTRYF
# endif
-vim_snprintf_add(char *, size_t, char *, ...);
+vim_snprintf_add(char *, size_t, char *, ...)
+#ifdef __GNUC__
+ __attribute__((format(printf, 3, 4)))
+#endif
+ ;
int
# ifdef __BORLANDC__
_RTLENTRYF
# endif
-vim_snprintf(char *, size_t, char *, ...);
+vim_snprintf(char *, size_t, char *, ...)
+#ifdef __GNUC__
+ __attribute__((format(printf, 3, 4)))
+#endif
+ ;
int vim_vsnprintf(char *str, size_t str_m, char *fmt, va_list ap);
int vim_vsnprintf_typval(char *str, size_t str_m, char *fmt, va_list ap, typval_T *tvs);
@@ -212,6 +220,14 @@ void qsort(void *base, size_t elm_count, size_t elm_size, int (*cmp)(const void
# endif
# ifdef FEAT_JOB_CHANNEL
# include "channel.pro"
+
+/* Not generated automatically, to add extra attribute. */
+void ch_log(channel_T *ch, const char *fmt, ...)
+#ifdef __GNUC__
+ __attribute__((format(printf, 2, 3)))
+#endif
+ ;
+
# endif
# if defined(FEAT_GUI) || defined(FEAT_JOB_CHANNEL)
diff --git a/src/spellfile.c b/src/spellfile.c
index e9eacbecb..496e07f8f 100644
--- a/src/spellfile.c
+++ b/src/spellfile.c
@@ -3649,7 +3649,7 @@ spell_read_dic(spellinfo_T *spin, char_u *fname, afffile_T *affile)
{
spin->si_msg_count = 0;
vim_snprintf((char *)message, sizeof(message),
- _("line %6d, word %6d - %s"),
+ _("line %6d, word %6ld - %s"),
lnum, spin->si_foldwcount + spin->si_keepwcount, w);
msg_start();
msg_puts_long_attr(message, 0);
diff --git a/src/undo.c b/src/undo.c
index 09bcc91be..6e3381f8c 100644
--- a/src/undo.c
+++ b/src/undo.c
@@ -3029,7 +3029,7 @@ ex_undolist(exarg_T *eap UNUSED)
{
if (ga_grow(&ga, 1) == FAIL)
break;
- vim_snprintf((char *)IObuff, IOSIZE, "%6ld %7ld ",
+ vim_snprintf((char *)IObuff, IOSIZE, "%6ld %7d ",
uhp->uh_seq, changes);
u_add_time(IObuff + STRLEN(IObuff), IOSIZE - STRLEN(IObuff),
uhp->uh_time);
diff --git a/src/version.c b/src/version.c
index 4ee3c2576..1b2a1fa0f 100644
--- a/src/version.c
+++ b/src/version.c
@@ -763,6 +763,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1677,
+/**/
1676,
/**/
1675,
diff --git a/src/vim.h b/src/vim.h
index 78dede0cd..626c0ad12 100644
--- a/src/vim.h
+++ b/src/vim.h
@@ -2549,11 +2549,4 @@ typedef enum {
#define TERM_START_FORCEIT 2
#define TERM_START_SYSTEM 4
-/* Not generated automatically, to add extra attribute. */
-void ch_log(channel_T *ch, const char *fmt, ...)
-#ifdef __GNUC__
-__attribute__((format(printf, 2, 3)))
-#endif
-;
-
#endif /* VIM__H */