lima: move dump check to macro for lima_dump_command_stream_print
authorQiang Yu <yuq825@gmail.com>
Mon, 10 Feb 2020 08:09:31 +0000 (16:09 +0800)
committerMarge Bot <eric+marge@anholt.net>
Mon, 17 Feb 2020 02:54:15 +0000 (02:54 +0000)
This can prevent the execution of some function like lima_ctx_buff_va
which is passed in as parameter when no dump case.

Reviewed-by: Vasily Khoruzhick <anarsoul@gmail.com>
Signed-off-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3755>

src/gallium/drivers/lima/lima_util.c
src/gallium/drivers/lima/lima_util.h

index 4ad88f5829a5185426e804bc6ce2c05bcfe6cb04..dca9307c991c2456eacf896b1eb919082a379ac2 100644 (file)
@@ -165,12 +165,9 @@ lima_dump_free(struct lima_dump *dump)
 }
 
 void
-lima_dump_command_stream_print(struct lima_dump *dump, void *data,
-                               int size, bool is_float, const char *fmt, ...)
+_lima_dump_command_stream_print(struct lima_dump *dump, void *data,
+                                int size, bool is_float, const char *fmt, ...)
 {
-   if (!dump)
-      return;
-
    va_list ap;
    va_start(ap, fmt);
    vfprintf(dump->fp, fmt, ap);
index 30c97d2f8728459396c402a2b2c8a01239ec6625..3749523f3a122148af586ae48ab451af76cb4b87 100644 (file)
@@ -45,7 +45,13 @@ void lima_dump_rsw_command_stream_print(struct lima_dump *dump, void *data,
                                         int size, uint32_t start);
 void lima_dump_texture_descriptor(struct lima_dump *dump, void *data,
                                   int size, uint32_t start, uint32_t offset);
-void lima_dump_command_stream_print(struct lima_dump *dump, void *data,
-                                    int size, bool is_float, const char *fmt, ...);
+
+void _lima_dump_command_stream_print(struct lima_dump *dump, void *data,
+                                     int size, bool is_float, const char *fmt, ...);
+#define lima_dump_command_stream_print(dump, ...) \
+   do { \
+      if (dump) \
+         _lima_dump_command_stream_print(dump, __VA_ARGS__); \
+   } while (0)
 
 #endif