mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 8.0.1677: no compiler warning for wrong format in vim_snprintf()
Problem: No compiler warning for wrong format in vim_snprintf(). Solution: Add printf attribute for gcc. Fix reported problems.
This commit is contained in:
@@ -7105,7 +7105,7 @@ get_tv_string_buf_chk(typval_T *varp, char_u *buf)
|
|||||||
{
|
{
|
||||||
case VAR_NUMBER:
|
case VAR_NUMBER:
|
||||||
vim_snprintf((char *)buf, NUMBUFLEN, "%lld",
|
vim_snprintf((char *)buf, NUMBUFLEN, "%lld",
|
||||||
(varnumber_T)varp->vval.v_number);
|
(long long)varp->vval.v_number);
|
||||||
return buf;
|
return buf;
|
||||||
case VAR_FUNC:
|
case VAR_FUNC:
|
||||||
case VAR_PARTIAL:
|
case VAR_PARTIAL:
|
||||||
|
@@ -5315,7 +5315,7 @@ msg_add_lines(
|
|||||||
*p++ = ' ';
|
*p++ = ' ';
|
||||||
if (shortmess(SHM_LINES))
|
if (shortmess(SHM_LINES))
|
||||||
vim_snprintf((char *)p, IOSIZE - (p - IObuff),
|
vim_snprintf((char *)p, IOSIZE - (p - IObuff),
|
||||||
"%ldL, %lldC", lnum, (varnumber_T)nchars);
|
"%ldL, %lldC", lnum, (long long)nchars);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (lnum == 1)
|
if (lnum == 1)
|
||||||
@@ -5327,7 +5327,7 @@ msg_add_lines(
|
|||||||
STRCPY(p, _("1 character"));
|
STRCPY(p, _("1 character"));
|
||||||
else
|
else
|
||||||
vim_snprintf((char *)p, IOSIZE - (p - IObuff),
|
vim_snprintf((char *)p, IOSIZE - (p - IObuff),
|
||||||
_("%lld characters"), (varnumber_T)nchars);
|
_("%lld characters"), (long long)nchars);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -217,7 +217,7 @@ json_encode_item(garray_T *gap, typval_T *val, int copyID, int options)
|
|||||||
|
|
||||||
case VAR_NUMBER:
|
case VAR_NUMBER:
|
||||||
vim_snprintf((char *)numbuf, NUMBUFLEN, "%lld",
|
vim_snprintf((char *)numbuf, NUMBUFLEN, "%lld",
|
||||||
val->vval.v_number);
|
(long long)val->vval.v_number);
|
||||||
ga_concat(gap, numbuf);
|
ga_concat(gap, numbuf);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@@ -5040,11 +5040,11 @@ im_preedit_window_open()
|
|||||||
#else
|
#else
|
||||||
gtk_widget_modify_font(preedit_label, gui.norm_font);
|
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);
|
gdk_color_parse(buf, &color);
|
||||||
gtk_widget_modify_fg(preedit_label, GTK_STATE_NORMAL, &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);
|
gdk_color_parse(buf, &color);
|
||||||
gtk_widget_modify_bg(preedit_window, GTK_STATE_NORMAL, &color);
|
gtk_widget_modify_bg(preedit_window, GTK_STATE_NORMAL, &color);
|
||||||
#endif
|
#endif
|
||||||
|
37
src/ops.c
37
src/ops.c
@@ -5976,13 +5976,17 @@ do_addsub(
|
|||||||
buf2[i] = '\0';
|
buf2[i] = '\0';
|
||||||
}
|
}
|
||||||
else if (pre == 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')
|
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)
|
else if (pre && hexupper)
|
||||||
vim_snprintf((char *)buf2, NUMBUFLEN, "%llX", n);
|
vim_snprintf((char *)buf2, NUMBUFLEN, "%llX",
|
||||||
|
(long long unsigned)n);
|
||||||
else
|
else
|
||||||
vim_snprintf((char *)buf2, NUMBUFLEN, "%llx", n);
|
vim_snprintf((char *)buf2, NUMBUFLEN, "%llx",
|
||||||
|
(long long unsigned)n);
|
||||||
length -= (int)STRLEN(buf2);
|
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"),
|
_("Selected %s%ld of %ld Lines; %lld of %lld Words; %lld of %lld Bytes"),
|
||||||
buf1, line_count_selected,
|
buf1, line_count_selected,
|
||||||
(long)curbuf->b_ml.ml_line_count,
|
(long)curbuf->b_ml.ml_line_count,
|
||||||
word_count_cursor, word_count,
|
(long long)word_count_cursor,
|
||||||
byte_count_cursor, byte_count);
|
(long long)word_count,
|
||||||
|
(long long)byte_count_cursor,
|
||||||
|
(long long)byte_count);
|
||||||
else
|
else
|
||||||
vim_snprintf((char *)IObuff, IOSIZE,
|
vim_snprintf((char *)IObuff, IOSIZE,
|
||||||
_("Selected %s%ld of %ld Lines; %lld of %lld Words; %lld of %lld Chars; %lld of %lld Bytes"),
|
_("Selected %s%ld of %ld Lines; %lld of %lld Words; %lld of %lld Chars; %lld of %lld Bytes"),
|
||||||
buf1, line_count_selected,
|
buf1, line_count_selected,
|
||||||
(long)curbuf->b_ml.ml_line_count,
|
(long)curbuf->b_ml.ml_line_count,
|
||||||
word_count_cursor, word_count,
|
(long long)word_count_cursor,
|
||||||
char_count_cursor, char_count,
|
(long long)word_count,
|
||||||
byte_count_cursor, byte_count);
|
(long long)char_count_cursor,
|
||||||
|
(long long)char_count,
|
||||||
|
(long long)byte_count_cursor,
|
||||||
|
(long long)byte_count);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -7528,17 +7537,17 @@ cursor_pos_info(dict_T *dict)
|
|||||||
(char *)buf1, (char *)buf2,
|
(char *)buf1, (char *)buf2,
|
||||||
(long)curwin->w_cursor.lnum,
|
(long)curwin->w_cursor.lnum,
|
||||||
(long)curbuf->b_ml.ml_line_count,
|
(long)curbuf->b_ml.ml_line_count,
|
||||||
word_count_cursor, word_count,
|
(long long)word_count_cursor, (long long)word_count,
|
||||||
byte_count_cursor, byte_count);
|
(long long)byte_count_cursor, (long long)byte_count);
|
||||||
else
|
else
|
||||||
vim_snprintf((char *)IObuff, IOSIZE,
|
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"),
|
_("Col %s of %s; Line %ld of %ld; Word %lld of %lld; Char %lld of %lld; Byte %lld of %lld"),
|
||||||
(char *)buf1, (char *)buf2,
|
(char *)buf1, (char *)buf2,
|
||||||
(long)curwin->w_cursor.lnum,
|
(long)curwin->w_cursor.lnum,
|
||||||
(long)curbuf->b_ml.ml_line_count,
|
(long)curbuf->b_ml.ml_line_count,
|
||||||
word_count_cursor, word_count,
|
(long long)word_count_cursor, (long long)word_count,
|
||||||
char_count_cursor, char_count,
|
(long long)char_count_cursor, (long long)char_count,
|
||||||
byte_count_cursor, byte_count);
|
(long long)byte_count_cursor, (long long)byte_count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
20
src/proto.h
20
src/proto.h
@@ -119,13 +119,21 @@ int
|
|||||||
# ifdef __BORLANDC__
|
# ifdef __BORLANDC__
|
||||||
_RTLENTRYF
|
_RTLENTRYF
|
||||||
# endif
|
# endif
|
||||||
vim_snprintf_add(char *, size_t, char *, ...);
|
vim_snprintf_add(char *, size_t, char *, ...)
|
||||||
|
#ifdef __GNUC__
|
||||||
|
__attribute__((format(printf, 3, 4)))
|
||||||
|
#endif
|
||||||
|
;
|
||||||
|
|
||||||
int
|
int
|
||||||
# ifdef __BORLANDC__
|
# ifdef __BORLANDC__
|
||||||
_RTLENTRYF
|
_RTLENTRYF
|
||||||
# endif
|
# 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(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);
|
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
|
# endif
|
||||||
# ifdef FEAT_JOB_CHANNEL
|
# ifdef FEAT_JOB_CHANNEL
|
||||||
# include "channel.pro"
|
# 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
|
# endif
|
||||||
|
|
||||||
# if defined(FEAT_GUI) || defined(FEAT_JOB_CHANNEL)
|
# if defined(FEAT_GUI) || defined(FEAT_JOB_CHANNEL)
|
||||||
|
@@ -3649,7 +3649,7 @@ spell_read_dic(spellinfo_T *spin, char_u *fname, afffile_T *affile)
|
|||||||
{
|
{
|
||||||
spin->si_msg_count = 0;
|
spin->si_msg_count = 0;
|
||||||
vim_snprintf((char *)message, sizeof(message),
|
vim_snprintf((char *)message, sizeof(message),
|
||||||
_("line %6d, word %6d - %s"),
|
_("line %6d, word %6ld - %s"),
|
||||||
lnum, spin->si_foldwcount + spin->si_keepwcount, w);
|
lnum, spin->si_foldwcount + spin->si_keepwcount, w);
|
||||||
msg_start();
|
msg_start();
|
||||||
msg_puts_long_attr(message, 0);
|
msg_puts_long_attr(message, 0);
|
||||||
|
@@ -3029,7 +3029,7 @@ ex_undolist(exarg_T *eap UNUSED)
|
|||||||
{
|
{
|
||||||
if (ga_grow(&ga, 1) == FAIL)
|
if (ga_grow(&ga, 1) == FAIL)
|
||||||
break;
|
break;
|
||||||
vim_snprintf((char *)IObuff, IOSIZE, "%6ld %7ld ",
|
vim_snprintf((char *)IObuff, IOSIZE, "%6ld %7d ",
|
||||||
uhp->uh_seq, changes);
|
uhp->uh_seq, changes);
|
||||||
u_add_time(IObuff + STRLEN(IObuff), IOSIZE - STRLEN(IObuff),
|
u_add_time(IObuff + STRLEN(IObuff), IOSIZE - STRLEN(IObuff),
|
||||||
uhp->uh_time);
|
uhp->uh_time);
|
||||||
|
@@ -762,6 +762,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1677,
|
||||||
/**/
|
/**/
|
||||||
1676,
|
1676,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -2549,11 +2549,4 @@ typedef enum {
|
|||||||
#define TERM_START_FORCEIT 2
|
#define TERM_START_FORCEIT 2
|
||||||
#define TERM_START_SYSTEM 4
|
#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 */
|
#endif /* VIM__H */
|
||||||
|
Reference in New Issue
Block a user