From 23c48917799bfe9e2a2fe3782daa17072e51428d Mon Sep 17 00:00:00 2001 From: MyungJoo Ham Date: Fri, 24 Jul 2020 18:58:09 +0900 Subject: [PATCH] Test/Fix potential macro bug What if you do: ``` if (WHATSOEVER) _print_log (MESSAGE); else do_something (); ``` Signed-off-by: MyungJoo Ham --- tests/nnstreamer_plugins/unittest_plugins.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/nnstreamer_plugins/unittest_plugins.cc b/tests/nnstreamer_plugins/unittest_plugins.cc index 5b884bf..eac0e2d 100644 --- a/tests/nnstreamer_plugins/unittest_plugins.cc +++ b/tests/nnstreamer_plugins/unittest_plugins.cc @@ -38,7 +38,11 @@ /** * @brief Macro for debug message. */ -#define _print_log(...) if (DBG) g_message (__VA_ARGS__) +#define _print_log(...) \ + do { \ + if (DBG) \ + g_message (__VA_ARGS__); \ + } while (0) #define str(s) #s #define TEST_TRANSFORM_TYPECAST(name, num_bufs, size, from_t, from_nns_t, to_t, str_to_t, to_nns_t, accel) \ -- 2.7.4