Add GCC annotations so that the vsprintf functions get checked properly

This commit is contained in:
Nick Mathewson 2012-06-14 13:25:10 -04:00
parent 60f6540341
commit 117e3273dc
2 changed files with 10 additions and 2 deletions

View File

@ -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) @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. @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
;
/** /**

View File

@ -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 /** Replacement for vsnprintf to get consistent behavior on platforms for
which the return value of snprintf does not conform to C99. 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. */ /** Replacement for inet_ntop for platforms which lack it. */
const char *evutil_inet_ntop(int af, const void *src, char *dst, size_t len); const char *evutil_inet_ntop(int af, const void *src, char *dst, size_t len);