aboutsummaryrefslogtreecommitdiff
path: root/src/common/compat.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2012-05-30 12:14:38 -0400
committerNick Mathewson <nickm@torproject.org>2012-05-30 12:14:38 -0400
commite28489467233bff4500a70f8a7b22e42ca3b3e68 (patch)
treefccba02270c6a44fca8978d71d0f4bc8b548a4ee /src/common/compat.h
parent75fc4dbbcabaedc715f0f9e883ccab1c9634e787 (diff)
downloadtor-e28489467233bff4500a70f8a7b22e42ca3b3e68.tar
tor-e28489467233bff4500a70f8a7b22e42ca3b3e68.tar.gz
Add __attribute__(format)s for our varargs printf/scanf wrappers
It turns out that if you set the third argument of __attribute__(format) to 0, GCC and Clang will check the format argument without expecting to find variadic arguments. This is the correct behavior for vsnprintf, vasprintf, and vscanf. I'm hoping this will fix bug 5969 (a clang warning) by telling clang that the format argument to tor_vasprintf is indeed a format string.
Diffstat (limited to 'src/common/compat.h')
-rw-r--r--src/common/compat.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/common/compat.h b/src/common/compat.h
index d2f1fd129..fc70caf50 100644
--- a/src/common/compat.h
+++ b/src/common/compat.h
@@ -261,11 +261,12 @@ void tor_munmap_file(tor_mmap_t *handle) ATTR_NONNULL((1));
int tor_snprintf(char *str, size_t size, const char *format, ...)
CHECK_PRINTF(3,4) ATTR_NONNULL((1,3));
int tor_vsnprintf(char *str, size_t size, const char *format, va_list args)
- ATTR_NONNULL((1,3));
+ CHECK_PRINTF(3,0) ATTR_NONNULL((1,3));
int tor_asprintf(char **strp, const char *fmt, ...)
CHECK_PRINTF(2,3);
-int tor_vasprintf(char **strp, const char *fmt, va_list args);
+int tor_vasprintf(char **strp, const char *fmt, va_list args)
+ CHECK_PRINTF(2,0);
const void *tor_memmem(const void *haystack, size_t hlen, const void *needle,
size_t nlen) ATTR_PURE ATTR_NONNULL((1,3));