From 82098bb97bbed9404da1f6386490837a05318d5e Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Thu, 19 Dec 2013 10:02:19 +0400 Subject: [PATCH] util: introduce CHECK_EQ/CHECK_NE --- src/node_watchdog.cc | 8 ++++---- src/util.h | 12 ++++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/node_watchdog.cc b/src/node_watchdog.cc index d5ad88f63b..cec9aa52c9 100644 --- a/src/node_watchdog.cc +++ b/src/node_watchdog.cc @@ -33,16 +33,16 @@ Watchdog::Watchdog(uint64_t ms) : destroyed_(false) { CHECK(loop_); int rc = uv_async_init(loop_, &async_, &Watchdog::Async); - CHECK(0 == rc); // NOLINT(readability/check) + CHECK_EQ(0, rc); rc = uv_timer_init(loop_, &timer_); - CHECK(0 == rc); // NOLINT(readability/check) + CHECK_EQ(0, rc); rc = uv_timer_start(&timer_, &Watchdog::Timer, ms, 0); - CHECK(0 == rc); // NOLINT(readability/check) + CHECK_EQ(0, rc); rc = uv_thread_create(&thread_, &Watchdog::Run, this); - CHECK(0 == rc); // NOLINT(readability/check) + CHECK_EQ(0, rc); } diff --git a/src/util.h b/src/util.h index 84ca8b876e..9545475cc4 100644 --- a/src/util.h +++ b/src/util.h @@ -44,14 +44,18 @@ namespace node { TypeName(const TypeName&) #if defined(NDEBUG) -#define ASSERT(expression) -#define CHECK(expression) \ +# define ASSERT(expression) +# define CHECK(expression) \ do { \ if (!(expression)) abort(); \ } while (0) +# define CHECK_EQ(a, b) CHECK((a) == (b)) +# define CHECK_NE(a, b) CHECK((a) != (b)) #else -#define ASSERT(expression) assert(expression) -#define CHECK(expression) assert(expression) +# define ASSERT(expression) assert(expression) +# define CHECK(expression) assert(expression) +# define CHECK_EQ(a, b) assert((a) == (b)) +# define CHECK_NE(a, b) assert((a) != (b)) #endif #define UNREACHABLE() abort()