diff options
author | Nick Mathewson <nickm@torproject.org> | 2012-05-30 12:14:38 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2012-05-30 12:14:38 -0400 |
commit | e28489467233bff4500a70f8a7b22e42ca3b3e68 (patch) | |
tree | fccba02270c6a44fca8978d71d0f4bc8b548a4ee /src/common/util.h | |
parent | 75fc4dbbcabaedc715f0f9e883ccab1c9634e787 (diff) | |
download | tor-e28489467233bff4500a70f8a7b22e42ca3b3e68.tar.gz tor-e28489467233bff4500a70f8a7b22e42ca3b3e68.zip |
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/util.h')
-rw-r--r-- | src/common/util.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/common/util.h b/src/common/util.h index b9db25ca73..d4771562ee 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -211,7 +211,11 @@ const char *escaped(const char *string); struct smartlist_t; void wrap_string(struct smartlist_t *out, const char *string, size_t width, const char *prefix0, const char *prefixRest); -int tor_vsscanf(const char *buf, const char *pattern, va_list ap); +int tor_vsscanf(const char *buf, const char *pattern, va_list ap) +#ifdef __GNUC__ + __attribute__((format(scanf, 2, 0))) +#endif + ; int tor_sscanf(const char *buf, const char *pattern, ...) #ifdef __GNUC__ __attribute__((format(scanf, 2, 3))) |