summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2017-07-25 12:20:40 +0200
committerBen Noordhuis <info@bnoordhuis.nl>2017-07-27 17:11:08 +0200
commit1b7372f2fb55f704b885e1097e2ec0381068c855 (patch)
treefe5ca729487cca97831c5bbd6edafd280a9c5814 /src
parent1fa67c7fc2ef9fc226545f5de22c51964dbc27e1 (diff)
downloadandroid-node-v8-1b7372f2fb55f704b885e1097e2ec0381068c855.tar.gz
android-node-v8-1b7372f2fb55f704b885e1097e2ec0381068c855.tar.bz2
android-node-v8-1b7372f2fb55f704b885e1097e2ec0381068c855.zip
src: replace ASSERT with CHECK
Builds always have asserts enabled so there is no point distinguishing between debug-only checks and run-time checks. Replace calls to ASSERT and friends with their CHECK counterparts. Fixes: https://github.com/nodejs/node/issues/14461 PR-URL: https://github.com/nodejs/node/pull/14474 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaƫl Zasso <targos@protonmail.com> Reviewed-By: Nikolai Vavilov <vvnicholas@gmail.com> Reviewed-By: XadillaX <admin@xcoder.in>
Diffstat (limited to 'src')
-rw-r--r--src/env-inl.h4
-rw-r--r--src/inspector_socket.cc12
-rw-r--r--src/node_buffer.cc18
-rw-r--r--src/node_crypto.cc2
-rw-r--r--src/node_crypto.h2
-rw-r--r--src/string_bytes.cc2
-rw-r--r--src/string_search.h10
-rw-r--r--src/util.h15
8 files changed, 26 insertions, 39 deletions
diff --git a/src/env-inl.h b/src/env-inl.h
index cf7304c98d..e160fe27d8 100644
--- a/src/env-inl.h
+++ b/src/env-inl.h
@@ -272,14 +272,14 @@ inline Environment* Environment::GetCurrent(v8::Local<v8::Context> context) {
inline Environment* Environment::GetCurrent(
const v8::FunctionCallbackInfo<v8::Value>& info) {
- ASSERT(info.Data()->IsExternal());
+ CHECK(info.Data()->IsExternal());
return static_cast<Environment*>(info.Data().As<v8::External>()->Value());
}
template <typename T>
inline Environment* Environment::GetCurrent(
const v8::PropertyCallbackInfo<T>& info) {
- ASSERT(info.Data()->IsExternal());
+ CHECK(info.Data()->IsExternal());
// XXX(bnoordhuis) Work around a g++ 4.9.2 template type inferrer bug
// when the expression is written as info.Data().As<v8::External>().
v8::Local<v8::Value> data = info.Data();
diff --git a/src/inspector_socket.cc b/src/inspector_socket.cc
index 85984b7fa1..2d5054bb80 100644
--- a/src/inspector_socket.cc
+++ b/src/inspector_socket.cc
@@ -157,7 +157,7 @@ static std::vector<char> encode_frame_hybi17(const char* message,
}
frame.insert(frame.end(), extended_payload_length,
extended_payload_length + 8);
- ASSERT_EQ(0, remaining);
+ CHECK_EQ(0, remaining);
}
frame.insert(frame.end(), message, message + data_length);
return frame;
@@ -361,8 +361,8 @@ static void websockets_data_cb(uv_stream_t* stream, ssize_t nread,
int inspector_read_start(InspectorSocket* inspector,
uv_alloc_cb alloc_cb, uv_read_cb read_cb) {
- ASSERT(inspector->ws_mode);
- ASSERT(!inspector->shutting_down || read_cb == nullptr);
+ CHECK(inspector->ws_mode);
+ CHECK(!inspector->shutting_down || read_cb == nullptr);
inspector->ws_state->close_sent = false;
inspector->ws_state->alloc_cb = alloc_cb;
inspector->ws_state->read_cb = read_cb;
@@ -561,7 +561,7 @@ static void init_handshake(InspectorSocket* socket) {
int inspector_accept(uv_stream_t* server, InspectorSocket* socket,
handshake_cb callback) {
- ASSERT_NE(callback, nullptr);
+ CHECK_NE(callback, nullptr);
CHECK_EQ(socket->http_parsing_state, nullptr);
socket->http_parsing_state = new http_parsing_state_s();
@@ -597,8 +597,8 @@ void inspector_close(InspectorSocket* inspector,
inspector_cb callback) {
// libuv throws assertions when closing stream that's already closed - we
// need to do the same.
- ASSERT(!uv_is_closing(reinterpret_cast<uv_handle_t*>(&inspector->tcp)));
- ASSERT(!inspector->shutting_down);
+ CHECK(!uv_is_closing(reinterpret_cast<uv_handle_t*>(&inspector->tcp)));
+ CHECK(!inspector->shutting_down);
inspector->shutting_down = true;
inspector->ws_state->close_cb = callback;
if (inspector->connection_eof) {
diff --git a/src/node_buffer.cc b/src/node_buffer.cc
index b3f5793f89..dc67844553 100644
--- a/src/node_buffer.cc
+++ b/src/node_buffer.cc
@@ -953,9 +953,9 @@ int64_t IndexOfOffset(size_t length,
}
void IndexOfString(const FunctionCallbackInfo<Value>& args) {
- ASSERT(args[1]->IsString());
- ASSERT(args[2]->IsNumber());
- ASSERT(args[4]->IsBoolean());
+ CHECK(args[1]->IsString());
+ CHECK(args[2]->IsNumber());
+ CHECK(args[4]->IsBoolean());
enum encoding enc = ParseEncoding(args.GetIsolate(),
args[3],
@@ -1069,9 +1069,9 @@ void IndexOfString(const FunctionCallbackInfo<Value>& args) {
}
void IndexOfBuffer(const FunctionCallbackInfo<Value>& args) {
- ASSERT(args[1]->IsObject());
- ASSERT(args[2]->IsNumber());
- ASSERT(args[4]->IsBoolean());
+ CHECK(args[1]->IsObject());
+ CHECK(args[2]->IsNumber());
+ CHECK(args[4]->IsBoolean());
enum encoding enc = ParseEncoding(args.GetIsolate(),
args[3],
@@ -1143,9 +1143,9 @@ void IndexOfBuffer(const FunctionCallbackInfo<Value>& args) {
}
void IndexOfNumber(const FunctionCallbackInfo<Value>& args) {
- ASSERT(args[1]->IsNumber());
- ASSERT(args[2]->IsNumber());
- ASSERT(args[3]->IsBoolean());
+ CHECK(args[1]->IsNumber());
+ CHECK(args[2]->IsNumber());
+ CHECK(args[3]->IsBoolean());
THROW_AND_RETURN_UNLESS_BUFFER(Environment::GetCurrent(args), args[0]);
SPREAD_BUFFER_ARG(args[0], ts_obj);
diff --git a/src/node_crypto.cc b/src/node_crypto.cc
index 84f006b00f..d03d8ad2f2 100644
--- a/src/node_crypto.cc
+++ b/src/node_crypto.cc
@@ -5193,7 +5193,7 @@ void ECDH::SetPublicKey(const FunctionCallbackInfo<Value>& args) {
bool ECDH::IsKeyValidForCurve(const BIGNUM* private_key) {
- ASSERT_NE(group_, nullptr);
+ CHECK_NE(group_, nullptr);
CHECK_NE(private_key, nullptr);
// Private keys must be in the range [1, n-1].
// Ref: Section 3.2.1 - http://www.secg.org/sec1-v2.pdf
diff --git a/src/node_crypto.h b/src/node_crypto.h
index 1d823bcb35..b406fb8aa6 100644
--- a/src/node_crypto.h
+++ b/src/node_crypto.h
@@ -718,7 +718,7 @@ class ECDH : public BaseObject {
key_(key),
group_(EC_KEY_get0_group(key_)) {
MakeWeak<ECDH>(this);
- ASSERT_NE(group_, nullptr);
+ CHECK_NE(group_, nullptr);
}
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
diff --git a/src/string_bytes.cc b/src/string_bytes.cc
index cbf30afc7a..5aa3b8ca77 100644
--- a/src/string_bytes.cc
+++ b/src/string_bytes.cc
@@ -321,7 +321,7 @@ size_t StringBytes::WriteUCS2(char* buf,
uint16_t* aligned_dst =
reinterpret_cast<uint16_t*>(buf + sizeof(*dst) - alignment);
- ASSERT_EQ(reinterpret_cast<uintptr_t>(aligned_dst) % sizeof(*dst), 0);
+ CHECK_EQ(reinterpret_cast<uintptr_t>(aligned_dst) % sizeof(*dst), 0);
// Write all but the last char
nchars = str->Write(aligned_dst, 0, max_chars - 1, flags);
diff --git a/src/string_search.h b/src/string_search.h
index 6040888110..dfdb8e9a16 100644
--- a/src/string_search.h
+++ b/src/string_search.h
@@ -28,7 +28,7 @@ class Vector {
public:
Vector(T* data, size_t length, bool isForward)
: start_(data), length_(length), is_forward_(isForward) {
- ASSERT(length > 0 && data != nullptr);
+ CHECK(length > 0 && data != nullptr);
}
// Returns the start of the memory range.
@@ -44,7 +44,7 @@ class Vector {
// Access individual vector elements - checks bounds in debug mode.
T& operator[](size_t index) const {
- ASSERT(index < length_);
+ CHECK(index < length_);
return start_[is_forward_ ? index : (length_ - index - 1)];
}
@@ -342,7 +342,7 @@ size_t StringSearch<Char>::LinearSearch(
i = FindFirstCharacter(pattern, subject, i);
if (i == subject.length())
return subject.length();
- ASSERT_LE(i, n);
+ CHECK_LE(i, n);
bool matches = true;
for (size_t j = 1; j < pattern_length; j++) {
@@ -591,7 +591,7 @@ size_t StringSearch<Char>::InitialSearch(
i = FindFirstCharacter(pattern, subject, i);
if (i == subject.length())
return subject.length();
- ASSERT_LE(i, n);
+ CHECK_LE(i, n);
size_t j = 1;
do {
if (pattern[j] != subject[i + j]) {
@@ -644,7 +644,7 @@ size_t SearchString(const Char* haystack,
needle, needle_length, is_forward);
Vector<const Char> v_haystack = Vector<const Char>(
haystack, haystack_length, is_forward);
- ASSERT(haystack_length >= needle_length);
+ CHECK(haystack_length >= needle_length);
size_t diff = haystack_length - needle_length;
size_t relative_start_index;
if (is_forward) {
diff --git a/src/util.h b/src/util.h
index 175db0c82c..1272de1893 100644
--- a/src/util.h
+++ b/src/util.h
@@ -77,7 +77,7 @@ void LowMemoryNotification();
#endif
// The slightly odd function signature for Assert() is to ease
-// instruction cache pressure in calls from ASSERT and CHECK.
+// instruction cache pressure in calls from CHECK.
NO_RETURN void Abort();
NO_RETURN void Assert(const char* const (*args)[4]);
void DumpBacktrace(FILE* fp);
@@ -124,19 +124,6 @@ template <typename T> using remove_reference = std::remove_reference<T>;
} \
} while (0)
-#ifdef NDEBUG
-#define ASSERT(expr)
-#else
-#define ASSERT(expr) CHECK(expr)
-#endif
-
-#define ASSERT_EQ(a, b) ASSERT((a) == (b))
-#define ASSERT_GE(a, b) ASSERT((a) >= (b))
-#define ASSERT_GT(a, b) ASSERT((a) > (b))
-#define ASSERT_LE(a, b) ASSERT((a) <= (b))
-#define ASSERT_LT(a, b) ASSERT((a) < (b))
-#define ASSERT_NE(a, b) ASSERT((a) != (b))
-
#define CHECK_EQ(a, b) CHECK((a) == (b))
#define CHECK_GE(a, b) CHECK((a) >= (b))
#define CHECK_GT(a, b) CHECK((a) > (b))