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.
diff --git a/src/ops.c b/src/ops.c
index cb019cf..8b895d8 100644
--- a/src/ops.c
+++ b/src/ops.c
@@ -5976,13 +5976,17 @@
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 @@
_("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 @@
(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);
}
}