gallium/util: check callback pointers for non-null in pipe_debug_message()
authorBrian Paul <brianp@vmware.com>
Sat, 5 Dec 2015 00:44:29 +0000 (17:44 -0700)
committerBrian Paul <brianp@vmware.com>
Mon, 7 Dec 2015 15:56:51 +0000 (08:56 -0700)
So the callers don't have to do it.

v2: also check cb!=NULL in the macro

Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: José Fonseca <jfonseca@vmware.com>
src/gallium/auxiliary/util/u_debug.h

index 99007039a7c6b08e0158426f3d94c7a5b08e5d7d..5307072fa3a1cd8b48192827f62982f885b17de7 100644 (file)
@@ -268,9 +268,11 @@ 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__); \
+   if ((cb) && (cb)->debug_message) { \
+      _pipe_debug_message(cb, &id, \
+                          PIPE_DEBUG_TYPE_ ## type, \
+                          fmt, ##__VA_ARGS__); \
+   } \
 } while (0)
 
 struct pipe_debug_callback;