summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2014-06-07 12:26:39 +0200
committerGuillem Jover <guillem@debian.org>2014-08-09 22:04:12 +0200
commit66c070b9b83ca500d2038252240540bc70edd922 (patch)
tree83d9a535d6f6b65a2157683fd280e5bb48617ed5
parent338374a655d6d8ca97196cc6bca80109d955b278 (diff)
downloaddpkg-66c070b9b83ca500d2038252240540bc70edd922.tar.gz
libcompat: Mark compat functions with attribute printf and vprintf
We duplicate these macros here too so that we can quiesce some warnings when building the compatibility code.
-rw-r--r--lib/compat/compat.h20
1 files changed, 16 insertions, 4 deletions
diff --git a/lib/compat/compat.h b/lib/compat/compat.h
index a6935b7f1..52379ec8e 100644
--- a/lib/compat/compat.h
+++ b/lib/compat/compat.h
@@ -47,6 +47,14 @@
#define LIBCOMPAT_GCC_VERSION 0
#endif
+#if LIBCOMPAT_GCC_VERSION >= 0x0300
+#define LIBCOMPAT_ATTR_PRINTF(n) __attribute__((format(printf, n, n + 1)))
+#define LIBCOMPAT_ATTR_VPRINTF(n) __attribute__((format(printf, n, 0)))
+#else
+#define LIBCOMPAT_ATTR_PRINTF(n)
+#define LIBCOMPAT_ATTR_VPRINTF(n)
+#endif
+
/* For C++, define a __func__ fallback in case it's not natively supported. */
#if defined(__cplusplus) && __cplusplus < 201103L
# if LIBCOMPAT_GCC_VERSION >= 0x0200
@@ -118,13 +126,17 @@ extern "C" {
#endif
#if TEST_LIBCOMPAT || !defined(HAVE_C99_SNPRINTF)
-int snprintf(char *str, size_t n, char const *fmt, ...);
-int vsnprintf(char *buf, size_t maxsize, const char *fmt, va_list args);
+int snprintf(char *str, size_t n, char const *fmt, ...)
+ LIBCOMPAT_ATTR_PRINTF(3);
+int vsnprintf(char *buf, size_t maxsize, const char *fmt, va_list args)
+ LIBCOMPAT_ATTR_VPRINTF(3);
#endif
#if TEST_LIBCOMPAT || !defined(HAVE_ASPRINTF)
-int asprintf(char **str, char const *fmt, ...);
-int vasprintf(char **str, const char *fmt, va_list args);
+int asprintf(char **str, char const *fmt, ...)
+ LIBCOMPAT_ATTR_PRINTF(2);
+int vasprintf(char **str, const char *fmt, va_list args)
+ LIBCOMPAT_ATTR_VPRINTF(2);
#endif
#if TEST_LIBCOMPAT || !defined(HAVE_STRNLEN)