Author: dirk Date: 2007-09-24 14:25:24 +0100 (Mon, 24 Sep 2007) New Revision: 6909
Log: add format argument checking. might find useful portability issues Modified: trunk/include/pub_tool_libcprint.h Modified: trunk/include/pub_tool_libcprint.h =================================================================== --- trunk/include/pub_tool_libcprint.h 2007-09-24 13:24:50 UTC (rev 6908) +++ trunk/include/pub_tool_libcprint.h 2007-09-24 13:25:24 UTC (rev 6909) @@ -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 ); ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Valgrind-developers mailing list Valgrind-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/valgrind-developers