From: dana koch Date: Thu, 13 Jun 2013 12:04:01 +0000 (+1000) Subject: Instead of testing for __GNUC__, use CHECK_SCANF, like CHECK_PRINTF. X-Git-Tag: tor-0.2.5.1-alpha~147 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7f67becf307e383eeda94dc4a7dbf5629436ef8c;p=thirdparty%2Ftor.git Instead of testing for __GNUC__, use CHECK_SCANF, like CHECK_PRINTF. This lets us have the possibility of fine-tuning the check in the tor_sscanf test cases at a later date. --- diff --git a/src/common/compat.h b/src/common/compat.h index 8ab7190526..258fc99020 100644 --- a/src/common/compat.h +++ b/src/common/compat.h @@ -84,13 +84,19 @@ /* ===== 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 diff --git a/src/common/util.h b/src/common/util.h index 018316e1b5..5596378bca 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -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);