From: Dirk Mueller Date: Mon, 24 Sep 2007 13:25:24 +0000 (+0000) Subject: add format argument checking. might find useful portability issues X-Git-Tag: svn/VALGRIND_3_3_0~198 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3bcfe3312747f23de36230ed9be6b4aa2f068915;p=thirdparty%2Fvalgrind.git add format argument checking. might find useful portability issues git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6909 --- diff --git a/include/pub_tool_libcprint.h b/include/pub_tool_libcprint.h index 9b706b9bfd..33ede5f598 100644 --- a/include/pub_tool_libcprint.h +++ b/include/pub_tool_libcprint.h @@ -35,19 +35,26 @@ Basic printing ------------------------------------------------------------------ */ +#ifdef __GNUC__ +# define PRINTF_CHECK(x,y) __attribute__((format(__printf__, x, y))) +#else +# define PRINTF_CHECK(x,y) /* x, y */ +#endif + /* Note that they all output to the file descriptor given by the * --log-fd/--log-file/--log-socket argument, which defaults to 2 (stderr). * Hence no need for VG_(fprintf)(). */ -extern UInt VG_(printf) ( const HChar *format, ... ); + +extern UInt VG_(printf) ( const HChar *format, ... ) PRINTF_CHECK(1,2); extern UInt VG_(vprintf) ( const HChar *format, va_list vargs ); /* too noisy ... __attribute__ ((format (printf, 1, 2))) ; */ -extern UInt VG_(sprintf) ( Char* buf, const HChar* format, ... ); +extern UInt VG_(sprintf) ( Char* buf, const HChar* format, ... ) PRINTF_CHECK(2,3); extern UInt VG_(vsprintf) ( Char* buf, const HChar* format, va_list vargs ); extern UInt VG_(snprintf) ( Char* buf, Int size, - const HChar *format, ... ); + const HChar *format, ... ) PRINTF_CHECK(3,4); extern UInt VG_(vsnprintf)( Char* buf, Int size, const HChar *format, va_list vargs );