Mesa (mesa_7_7_branch): util: better fix for unused variable warnings with asserts

Keith Whitwell keithw at kemper.freedesktop.org
Mon Dec 28 11:09:17 UTC 2009


Module: Mesa
Branch: mesa_7_7_branch
Commit: f0ba7d897d1c22202531acb70f134f2edc30557d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=f0ba7d897d1c22202531acb70f134f2edc30557d

Author: Keith Whitwell <keithw at vmware.com>
Date:   Mon Dec 28 11:05:06 2009 +0000

util: better fix for unused variable warnings with asserts

Modify the non-debug (ie disabled) version of assert to expose the
value in the expression to the compiler (avoiding the unused variable
messages) while still expanding to a noop.

---

 src/gallium/auxiliary/util/u_debug.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_debug.h b/src/gallium/auxiliary/util/u_debug.h
index abd834c..facc30a 100644
--- a/src/gallium/auxiliary/util/u_debug.h
+++ b/src/gallium/auxiliary/util/u_debug.h
@@ -188,7 +188,7 @@ void _debug_assert_fail(const char *expr,
 #ifdef DEBUG
 #define debug_assert(expr) ((expr) ? (void)0 : _debug_assert_fail(#expr, __FILE__, __LINE__, __FUNCTION__))
 #else
-#define debug_assert(expr) ((void)0)
+#define debug_assert(expr) do { } while (0 && (expr))
 #endif
 
 




More information about the mesa-commit mailing list