]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Instead of testing for __GNUC__, use CHECK_SCANF, like CHECK_PRINTF.
authordana koch <dsk@google.com>
Thu, 13 Jun 2013 12:04:01 +0000 (22:04 +1000)
committerNick Mathewson <nickm@torproject.org>
Fri, 14 Jun 2013 14:52:00 +0000 (10:52 -0400)
This lets us have the possibility of fine-tuning the check in the tor_sscanf test cases at a later date.

src/common/compat.h
src/common/util.h

index 8ab7190526334113c9ec0b336d31950f0560878b..258fc99020e98309c23c567b8fdcd0648a287b98 100644 (file)
 
 /* ===== Compiler compatibility */
 
-/* GCC can check printf types on arbitrary functions. */
+/* GCC can check printf and scanf types on arbitrary functions. */
 #ifdef __GNUC__
 #define CHECK_PRINTF(formatIdx, firstArg) \
    __attribute__ ((format(printf, formatIdx, firstArg)))
 #else
 #define CHECK_PRINTF(formatIdx, firstArg)
 #endif
+#ifdef __GNUC__
+#define CHECK_SCANF(formatIdx, firstArg) \
+   __attribute__ ((format(scanf, formatIdx, firstArg)))
+#else
+#define CHECK_SCANF(formatIdx, firstArg)
+#endif
 
 /* inline is __inline on windows. */
 #ifdef _WIN32
index 018316e1b50ffdbadb80c23348d2e0cfbe6dc6ac..5596378bca2e9111fde21cee3d06196ff9b0d74c 100644 (file)
@@ -233,16 +233,10 @@ const char *escaped(const char *string);
 char *tor_escape_str_for_socks_arg(const char *string);
 
 struct smartlist_t;
-int tor_vsscanf(const char *buf, const char *pattern, va_list ap)
-#ifdef __GNUC__
-  __attribute__((format(scanf, 2, 0)))
-#endif
-  ;
+int tor_vsscanf(const char *buf, const char *pattern, va_list ap) \
+  CHECK_SCANF(2, 0);
 int tor_sscanf(const char *buf, const char *pattern, ...)
-#ifdef __GNUC__
-  __attribute__((format(scanf, 2, 3)))
-#endif
-  ;
+  CHECK_SCANF(2, 3);
 
 void smartlist_add_asprintf(struct smartlist_t *sl, const char *pattern, ...)
   CHECK_PRINTF(2, 3);