From 02daa8df46c0be859a6802bd22aae5f7d0398881 Mon Sep 17 00:00:00 2001 From: Jonathon Reinhart Date: Mon, 21 Sep 2015 07:56:02 -0400 Subject: [PATCH] test/unit: simplify uc_assert_fail() macro This removes the UC_ASSERT_ERR_ANY constant, which was causing a compilation error on OSX: error: comparison of constant 3735928559 with expression of type 'uc_err' (aka 'enum uc_err') is always true [-Werror,-Wtautological-constant-out-of-range-compare] I could have probably changed 0xDEADBEEF to a constant < 0x80000000 but this seems cleaner anyway. --- test/unit/unicorn_test.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/test/unit/unicorn_test.h b/test/unit/unicorn_test.h index ccb53d75..9342566d 100644 --- a/test/unit/unicorn_test.h +++ b/test/unit/unicorn_test.h @@ -7,16 +7,13 @@ #include #include -#define UC_ASSERT_ERR_ANY 0xDEADBEEF - /** * Assert that err matches expect */ #define uc_assert_err(expect, err) \ do { \ uc_err __err = err; \ - if ((__err != expect) \ - || (expect == UC_ASSERT_ERR_ANY && __err == UC_ERR_OK)) { \ + if (__err != expect) { \ fail_msg("%s", uc_strerror(__err)); \ } \ } while (0) @@ -33,7 +30,13 @@ do { \ * as this serves to document which errors a function will return * in various scenarios. */ -#define uc_assert_fail(err) uc_assert_err(UC_ASSERT_ERR_ANY, err) +#define uc_assert_fail(err) \ +do { \ + uc_err __err = err; \ + if (__err == UC_ERR_OK) { \ + fail_msg("%s", uc_strerror(__err)); \ + } \ +} while (0) #endif /* UNICORN_TEST_H */