diff --git a/subsys/testsuite/ztest/include/zephyr/ztest_assert.h b/subsys/testsuite/ztest/include/zephyr/ztest_assert.h index 0773d3abccd..482f70e5027 100644 --- a/subsys/testsuite/ztest/include/zephyr/ztest_assert.h +++ b/subsys/testsuite/ztest/include/zephyr/ztest_assert.h @@ -132,8 +132,10 @@ static inline bool z_zassume(bool cond, const char *default_msg, const char *fil */ #define zassert(cond, default_msg, msg, ...) \ do { \ - bool _ret = z_zassert(cond, msg ? ("(" default_msg ")") : (default_msg), __FILE__, \ - __LINE__, __func__, msg ? msg : "", ##__VA_ARGS__); \ + bool _msg = (msg != NULL); \ + bool _ret = z_zassert(cond, _msg ? ("(" default_msg ")") : (default_msg), __FILE__,\ + __LINE__, __func__, _msg ? msg : "", ##__VA_ARGS__); \ + (void)_msg; \ if (!_ret) { \ /* If kernel but without multithreading return. */ \ COND_CODE_1(KERNEL, (COND_CODE_1(CONFIG_MULTITHREADING, (), (return;))), \ @@ -161,8 +163,10 @@ static inline bool z_zassume(bool cond, const char *default_msg, const char *fil */ #define zassume(cond, default_msg, msg, ...) \ do { \ - bool _ret = z_zassume(cond, msg ? ("(" default_msg ")") : (default_msg), __FILE__, \ - __LINE__, __func__, msg ? msg : "", ##__VA_ARGS__); \ + bool _msg = (msg != NULL); \ + bool _ret = z_zassume(cond, _msg ? ("(" default_msg ")") : (default_msg), __FILE__,\ + __LINE__, __func__, _msg ? msg : "", ##__VA_ARGS__); \ + (void)_msg; \ if (!_ret) { \ /* If kernel but without multithreading return. */ \ COND_CODE_1(KERNEL, (COND_CODE_1(CONFIG_MULTITHREADING, (), (return;))), \