[Mesa-dev] [PATCH 1/2] gallium/util: move conditional from _pipe_debug_message() to macro
Brian Paul
brianp at vmware.com
Fri Dec 4 16:52:12 PST 2015
To avoid function calls when the pointer is null.
Also, assert that the pipe_debug_callback object is non-null. It looks
like all the drivers which use this feature never pass a non-null pointer.
---
src/gallium/auxiliary/util/u_debug.c | 3 +--
src/gallium/auxiliary/util/u_debug.h | 9 ++++++---
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/gallium/auxiliary/util/u_debug.c b/src/gallium/auxiliary/util/u_debug.c
index 7029536..c42505d 100644
--- a/src/gallium/auxiliary/util/u_debug.c
+++ b/src/gallium/auxiliary/util/u_debug.c
@@ -79,8 +79,7 @@ _pipe_debug_message(
{
va_list args;
va_start(args, fmt);
- if (cb && cb->debug_message)
- cb->debug_message(cb->data, id, type, fmt, args);
+ cb->debug_message(cb->data, id, type, fmt, args);
va_end(args);
}
diff --git a/src/gallium/auxiliary/util/u_debug.h b/src/gallium/auxiliary/util/u_debug.h
index 9900703..4cc3d63 100644
--- a/src/gallium/auxiliary/util/u_debug.h
+++ b/src/gallium/auxiliary/util/u_debug.h
@@ -268,9 +268,12 @@ void _debug_assert_fail(const char *expr,
*/
#define pipe_debug_message(cb, type, fmt, ...) do { \
static unsigned id = 0; \
- _pipe_debug_message(cb, &id, \
- PIPE_DEBUG_TYPE_ ## type, \
- fmt, ##__VA_ARGS__); \
+ assert(cb); \
+ if ((cb)->debug_message) { \
+ _pipe_debug_message(cb, &id, \
+ PIPE_DEBUG_TYPE_ ## type, \
+ fmt, ##__VA_ARGS__); \
+ } \
} while (0)
struct pipe_debug_callback;
--
1.9.1
More information about the mesa-dev
mailing list