Skip to content

Commit 82098bb

Browse files
indutnytjfontaine
authored andcommitted
util: introduce CHECK_EQ/CHECK_NE
1 parent 87cde44 commit 82098bb

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

src/node_watchdog.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ Watchdog::Watchdog(uint64_t ms) : destroyed_(false) {
3333
CHECK(loop_);
3434

3535
int rc = uv_async_init(loop_, &async_, &Watchdog::Async);
36-
CHECK(0 == rc); // NOLINT(readability/check)
36+
CHECK_EQ(0, rc);
3737

3838
rc = uv_timer_init(loop_, &timer_);
39-
CHECK(0 == rc); // NOLINT(readability/check)
39+
CHECK_EQ(0, rc);
4040

4141
rc = uv_timer_start(&timer_, &Watchdog::Timer, ms, 0);
42-
CHECK(0 == rc); // NOLINT(readability/check)
42+
CHECK_EQ(0, rc);
4343

4444
rc = uv_thread_create(&thread_, &Watchdog::Run, this);
45-
CHECK(0 == rc); // NOLINT(readability/check)
45+
CHECK_EQ(0, rc);
4646
}
4747

4848

src/util.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,18 @@ namespace node {
4444
TypeName(const TypeName&)
4545

4646
#if defined(NDEBUG)
47-
#define ASSERT(expression)
48-
#define CHECK(expression) \
47+
# define ASSERT(expression)
48+
# define CHECK(expression) \
4949
do { \
5050
if (!(expression)) abort(); \
5151
} while (0)
52+
# define CHECK_EQ(a, b) CHECK((a) == (b))
53+
# define CHECK_NE(a, b) CHECK((a) != (b))
5254
#else
53-
#define ASSERT(expression) assert(expression)
54-
#define CHECK(expression) assert(expression)
55+
# define ASSERT(expression) assert(expression)
56+
# define CHECK(expression) assert(expression)
57+
# define CHECK_EQ(a, b) assert((a) == (b))
58+
# define CHECK_NE(a, b) assert((a) != (b))
5559
#endif
5660

5761
#define UNREACHABLE() abort()

0 commit comments

Comments
 (0)