Mesa (master): mesa: Add __printf__ attribute to printf-like functions to get warnings.

Eric Anholt anholt at kemper.freedesktop.org
Thu Sep 2 00:09:52 UTC 2010


Module: Mesa
Branch: master
Commit: 3cddc15d9dcf44a0998dd5f29ae6f6d17370584e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=3cddc15d9dcf44a0998dd5f29ae6f6d17370584e

Author: Eric Anholt <eric at anholt.net>
Date:   Wed Sep  1 14:39:50 2010 -0700

mesa: Add __printf__ attribute to printf-like functions to get warnings.

---

 src/mesa/main/compiler.h |    5 +++++
 src/mesa/main/imports.h  |   10 +++++-----
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/src/mesa/main/compiler.h b/src/mesa/main/compiler.h
index e0507cc..ded69c3 100644
--- a/src/mesa/main/compiler.h
+++ b/src/mesa/main/compiler.h
@@ -316,6 +316,11 @@ static INLINE GLuint CPU_TO_LE32(GLuint x)
 #endif
 #endif
 
+#if (__GNUC__ >= 3)
+#define PRINTFLIKE(f, a) __attribute__ ((format(__printf__, f, a)))
+#else
+#define PRINTFLIKE(f, a)
+#endif
 
 #ifndef NULL
 #define NULL 0
diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index 317e2b7..751f206 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -566,19 +566,19 @@ extern unsigned int
 _mesa_str_checksum(const char *str);
 
 extern int
-_mesa_snprintf( char *str, size_t size, const char *fmt, ... );
+_mesa_snprintf( char *str, size_t size, const char *fmt, ... ) PRINTFLIKE(3, 4);
 
 extern void
-_mesa_warning( __GLcontext *gc, const char *fmtString, ... );
+_mesa_warning( __GLcontext *gc, const char *fmtString, ... ) PRINTFLIKE(2, 3);
 
 extern void
-_mesa_problem( const __GLcontext *ctx, const char *fmtString, ... );
+_mesa_problem( const __GLcontext *ctx, const char *fmtString, ... ) PRINTFLIKE(2, 3);
 
 extern void
-_mesa_error( __GLcontext *ctx, GLenum error, const char *fmtString, ... );
+_mesa_error( __GLcontext *ctx, GLenum error, const char *fmtString, ... ) PRINTFLIKE(3, 4);
 
 extern void
-_mesa_debug( const __GLcontext *ctx, const char *fmtString, ... );
+_mesa_debug( const __GLcontext *ctx, const char *fmtString, ... ) PRINTFLIKE(2, 3);
 
 
 #if defined(_MSC_VER) && !defined(snprintf)




More information about the mesa-commit mailing list