From 3b951037a43822e10683c06921f7db5bc2c93406 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Tue, 18 Oct 2016 16:13:53 -0700 Subject: [PATCH] spdk_cunit: only evaluate assert condition once Change-Id: I2e8591df23fcb686c3189b0f6215759d749b84bd Signed-off-by: Daniel Verkamp --- test/spdk_cunit.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/spdk_cunit.h b/test/spdk_cunit.h index 832f9a3a2..919d00e77 100644 --- a/test/spdk_cunit.h +++ b/test/spdk_cunit.h @@ -43,7 +43,14 @@ * static analyzers figure out that it really doesn't return. * The abort() will never actually execute. */ -#define SPDK_CU_ASSERT_FATAL(cond) do { CU_ASSERT_FATAL(cond); if (!(cond)) { abort(); } } while (0) +#define SPDK_CU_ASSERT_FATAL(cond) \ + do { \ + int result_ = !!(cond); \ + CU_ASSERT_FATAL(result_); \ + if (!result_) { \ + abort(); \ + } \ + } while (0) int spdk_cunit_print_results(const char *filename);