From 117e3273dce5f6aa61b1867a64c8345b78dc1620 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Thu, 14 Jun 2012 13:25:10 -0400 Subject: [PATCH] Add GCC annotations so that the vsprintf functions get checked properly --- include/event2/buffer.h | 6 +++++- include/event2/util.h | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/event2/buffer.h b/include/event2/buffer.h index 16236c4b..37f424e1 100644 --- a/include/event2/buffer.h +++ b/include/event2/buffer.h @@ -488,7 +488,11 @@ int evbuffer_add_printf(struct evbuffer *buf, const char *fmt, ...) @param ap a varargs va_list argument array that will be passed to vprintf(3) @return The number of bytes added if successful, or -1 if an error occurred. */ -int evbuffer_add_vprintf(struct evbuffer *buf, const char *fmt, va_list ap); +int evbuffer_add_vprintf(struct evbuffer *buf, const char *fmt, va_list ap) +#ifdef __GNUC__ + __attribute__((format(printf, 2, 0))) +#endif +; /** diff --git a/include/event2/util.h b/include/event2/util.h index 45d8f1de..4b7e8b45 100644 --- a/include/event2/util.h +++ b/include/event2/util.h @@ -449,7 +449,11 @@ int evutil_snprintf(char *buf, size_t buflen, const char *format, ...) /** Replacement for vsnprintf to get consistent behavior on platforms for which the return value of snprintf does not conform to C99. */ -int evutil_vsnprintf(char *buf, size_t buflen, const char *format, va_list ap); +int evutil_vsnprintf(char *buf, size_t buflen, const char *format, va_list ap) +#ifdef __GNUC__ + __attribute__((format(printf, 3, 0))) +#endif +; /** Replacement for inet_ntop for platforms which lack it. */ const char *evutil_inet_ntop(int af, const void *src, char *dst, size_t len);