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/proto.h b/src/proto.h
index 5513746..231c53f 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -119,13 +119,21 @@
# 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 @@
# 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)