From 5fdff3854a4253681fb10aa626c8971e50834c10 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Sat, 11 Oct 2014 16:52:07 +0200 Subject: [PATCH] src: replace assert() with CHECK() Mechanically replace assert() statements with UNREACHABLE(), CHECK(), or CHECK_{EQ,NE,LT,GT,LE,GE}() statements. The exceptions are src/node.h and src/node_object_wrap.h because they are public headers. PR-URL: https://github.com/node-forward/node/pull/16 Reviewed-By: Fedor Indutny --- src/async-wrap-inl.h | 10 ++--- src/base-object-inl.h | 8 ++-- src/cares_wrap.cc | 57 ++++++++++++++------------- src/fs_event_wrap.cc | 8 ++-- src/handle_wrap.cc | 8 ++-- src/node.cc | 53 +++++++++++++------------ src/node_buffer.cc | 25 ++++++------ src/node_contextify.cc | 4 +- src/node_crypto.cc | 48 +++++++++++------------ src/node_crypto.h | 4 +- src/node_crypto_bio.cc | 32 ++++++++-------- src/node_crypto_bio.h | 5 ++- src/node_crypto_clienthello-inl.h | 5 ++- src/node_file.cc | 15 ++++---- src/node_http_parser.cc | 26 ++++++------- src/node_internals.h | 1 - src/node_stat_watcher.cc | 7 ++-- src/node_watchdog.cc | 1 - src/node_win32_etw_provider-inl.h | 2 +- src/node_win32_etw_provider.cc | 2 +- src/node_zlib.cc | 50 ++++++++++++------------ src/pipe_wrap.cc | 24 ++++++------ src/process_wrap.cc | 10 ++--- src/req_wrap.h | 4 +- src/signal_wrap.cc | 4 +- src/smalloc.cc | 35 ++++++++--------- src/spawn_sync.cc | 64 +++++++++++++++---------------- src/stream_wrap.cc | 44 ++++++++++----------- src/stream_wrap.h | 6 +-- src/string_bytes.cc | 23 ++++++----- src/tcp_wrap.cc | 40 +++++++++---------- src/timer_wrap.cc | 4 +- src/tls_wrap.cc | 24 ++++++------ src/tty_wrap.cc | 10 ++--- src/udp_wrap.cc | 34 ++++++++-------- src/util-inl.h | 10 ++--- 36 files changed, 348 insertions(+), 359 deletions(-) diff --git a/src/async-wrap-inl.h b/src/async-wrap-inl.h index 59157cc0f4..4cbf8f493b 100644 --- a/src/async-wrap-inl.h +++ b/src/async-wrap-inl.h @@ -29,9 +29,7 @@ #include "env-inl.h" #include "util.h" #include "util-inl.h" - #include "v8.h" -#include namespace node { @@ -74,7 +72,7 @@ inline v8::Handle AsyncWrap::MakeDomainCallback( const v8::Handle cb, int argc, v8::Handle* argv) { - assert(env()->context() == env()->isolate()->GetCurrentContext()); + CHECK_EQ(env()->context(), env()->isolate()->GetCurrentContext()); v8::Local context = object(); v8::Local process = env()->process_object(); @@ -169,7 +167,7 @@ inline v8::Handle AsyncWrap::MakeCallback( if (env()->using_domains()) return MakeDomainCallback(cb, argc, argv); - assert(env()->context() == env()->isolate()->GetCurrentContext()); + CHECK_EQ(env()->context(), env()->isolate()->GetCurrentContext()); v8::Local context = object(); v8::Local process = env()->process_object(); @@ -235,7 +233,7 @@ inline v8::Handle AsyncWrap::MakeCallback( v8::Handle* argv) { v8::Local cb_v = object()->Get(symbol); v8::Local cb = cb_v.As(); - assert(cb->IsFunction()); + CHECK(cb->IsFunction()); return MakeCallback(cb, argc, argv); } @@ -247,7 +245,7 @@ inline v8::Handle AsyncWrap::MakeCallback( v8::Handle* argv) { v8::Local cb_v = object()->Get(index); v8::Local cb = cb_v.As(); - assert(cb->IsFunction()); + CHECK(cb->IsFunction()); return MakeCallback(cb, argc, argv); } diff --git a/src/base-object-inl.h b/src/base-object-inl.h index 4d726df7ca..17540f4822 100644 --- a/src/base-object-inl.h +++ b/src/base-object-inl.h @@ -27,19 +27,17 @@ #include "util-inl.h" #include "v8.h" -#include - namespace node { inline BaseObject::BaseObject(Environment* env, v8::Local handle) : handle_(env->isolate(), handle), env_(env) { - assert(!handle.IsEmpty()); + CHECK_EQ(false, handle.IsEmpty()); } inline BaseObject::~BaseObject() { - assert(handle_.IsEmpty()); + CHECK(handle_.IsEmpty()); } @@ -71,7 +69,7 @@ template inline void BaseObject::MakeWeak(Type* ptr) { v8::HandleScope scope(env_->isolate()); v8::Local handle = object(); - assert(handle->InternalFieldCount() > 0); + CHECK_GT(handle->InternalFieldCount(), 0); Wrap(handle, ptr); handle_.MarkIndependent(); handle_.SetWeak(ptr, WeakCallback); diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc index c6ffcf0fac..db2526fd51 100644 --- a/src/cares_wrap.cc +++ b/src/cares_wrap.cc @@ -31,7 +31,6 @@ #include "util.h" #include "uv.h" -#include #include #include #include @@ -85,7 +84,7 @@ RB_GENERATE_STATIC(ares_task_list, ares_task_t, node, cmp_ares_tasks) /* call back into c-ares for possibly processing timeouts. */ static void ares_timeout(uv_timer_t* handle) { Environment* env = Environment::from_cares_timer_handle(handle); - assert(!RB_EMPTY(env->cares_task_list())); + CHECK_EQ(false, RB_EMPTY(env->cares_task_list())); ares_process_fd(env->cares_channel(), ARES_SOCKET_BAD, ARES_SOCKET_BAD); } @@ -159,7 +158,7 @@ static void ares_sockstate_cb(void* data, /* If this is the first socket then start the timer. */ uv_timer_t* timer_handle = env->cares_timer_handle(); if (!uv_is_active(reinterpret_cast(timer_handle))) { - assert(RB_EMPTY(env->cares_task_list())); + CHECK(RB_EMPTY(env->cares_task_list())); uv_timer_start(timer_handle, ares_timeout, 1000, 1000); } @@ -184,8 +183,8 @@ static void ares_sockstate_cb(void* data, /* read == 0 and write == 0 this is c-ares's way of notifying us that */ /* the socket is now closed. We must free the data associated with */ /* socket. */ - assert(task && - "When an ares socket is closed we should have a handle for it"); + CHECK(task && + "When an ares socket is closed we should have a handle for it"); RB_REMOVE(ares_task_list, env->cares_task_list(), task); uv_close(reinterpret_cast(&task->poll_watcher), @@ -233,18 +232,18 @@ class QueryWrap : public AsyncWrap { } virtual ~QueryWrap() { - assert(!persistent().IsEmpty()); + CHECK_EQ(false, persistent().IsEmpty()); persistent().Reset(); } // Subclasses should implement the appropriate Send method. virtual int Send(const char* name) { - assert(0); + UNREACHABLE(); return 0; } virtual int Send(const char* name, int family) { - assert(0); + UNREACHABLE(); return 0; } @@ -301,7 +300,7 @@ class QueryWrap : public AsyncWrap { } void ParseError(int status) { - assert(status != ARES_SUCCESS); + CHECK_NE(status, ARES_SUCCESS); HandleScope handle_scope(env()->isolate()); Context::Scope context_scope(env()->context()); Local arg; @@ -344,11 +343,11 @@ class QueryWrap : public AsyncWrap { // Subclasses should implement the appropriate Parse method. virtual void Parse(unsigned char* buf, int len) { - assert(0); + UNREACHABLE(); }; virtual void Parse(struct hostent* host) { - assert(0); + UNREACHABLE(); }; }; @@ -843,9 +842,9 @@ template static void Query(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args.GetIsolate()); - assert(!args.IsConstructCall()); - assert(args[0]->IsObject()); - assert(args[1]->IsString()); + CHECK_EQ(false, args.IsConstructCall()); + CHECK(args[0]->IsObject()); + CHECK(args[1]->IsString()); Local req_wrap_obj = args[0].As(); Local string = args[1].As(); @@ -894,7 +893,7 @@ void AfterGetAddrInfo(uv_getaddrinfo_t* req, int status, struct addrinfo* res) { // strings for each IP and filling the results array. address = res; while (address) { - assert(address->ai_socktype == SOCK_STREAM); + CHECK_EQ(address->ai_socktype, SOCK_STREAM); // Ignore random ai_family types. if (address->ai_family == AF_INET) { @@ -921,7 +920,7 @@ void AfterGetAddrInfo(uv_getaddrinfo_t* req, int status, struct addrinfo* res) { // Iterate over the IPv6 responses putting them in the array. address = res; while (address) { - assert(address->ai_socktype == SOCK_STREAM); + CHECK_EQ(address->ai_socktype, SOCK_STREAM); // Ignore random ai_family types. if (address->ai_family == AF_INET6) { @@ -1008,9 +1007,9 @@ static void IsIP(const FunctionCallbackInfo& args) { static void GetAddrInfo(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args.GetIsolate()); - assert(args[0]->IsObject()); - assert(args[1]->IsString()); - assert(args[2]->IsInt32()); + CHECK(args[0]->IsObject()); + CHECK(args[1]->IsString()); + CHECK(args[2]->IsInt32()); Local req_wrap_obj = args[0].As(); node::Utf8Value hostname(args[1]); @@ -1028,7 +1027,7 @@ static void GetAddrInfo(const FunctionCallbackInfo& args) { family = AF_INET6; break; default: - assert(0 && "bad address family"); + CHECK(0 && "bad address family"); abort(); } @@ -1097,7 +1096,7 @@ static void GetServers(const FunctionCallbackInfo& args) { ares_addr_node* servers; int r = ares_get_servers(env->cares_channel(), &servers); - assert(r == ARES_SUCCESS); + CHECK_EQ(r, ARES_SUCCESS); ares_addr_node* cur = servers; @@ -1106,7 +1105,7 @@ static void GetServers(const FunctionCallbackInfo& args) { const void* caddr = static_cast(&cur->addr); int err = uv_inet_ntop(cur->family, caddr, ip, sizeof(ip)); - assert(err == 0); + CHECK_EQ(err, 0); Local addr = OneByteString(env->isolate(), ip); server_array->Set(i, addr); @@ -1121,7 +1120,7 @@ static void GetServers(const FunctionCallbackInfo& args) { static void SetServers(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args.GetIsolate()); - assert(args[0]->IsArray()); + CHECK(args[0]->IsArray()); Local arr = Local::Cast(args[0]); @@ -1138,12 +1137,12 @@ static void SetServers(const FunctionCallbackInfo& args) { int err; for (uint32_t i = 0; i < len; i++) { - assert(arr->Get(i)->IsArray()); + CHECK(arr->Get(i)->IsArray()); Local elm = Local::Cast(arr->Get(i)); - assert(elm->Get(0)->Int32Value()); - assert(elm->Get(1)->IsString()); + CHECK(elm->Get(0)->Int32Value()); + CHECK(elm->Get(1)->IsString()); int fam = elm->Get(0)->Int32Value(); node::Utf8Value ip(elm->Get(1)); @@ -1160,7 +1159,7 @@ static void SetServers(const FunctionCallbackInfo& args) { err = uv_inet_pton(AF_INET6, *ip, &cur->addr); break; default: - assert(0 && "Bad address family."); + CHECK(0 && "Bad address family."); abort(); } @@ -1213,7 +1212,7 @@ static void Initialize(Handle target, Environment* env = Environment::GetCurrent(context); int r = ares_library_init(ARES_LIB_INIT_ALL); - assert(r == ARES_SUCCESS); + CHECK_EQ(r, ARES_SUCCESS); struct ares_options options; memset(&options, 0, sizeof(options)); @@ -1225,7 +1224,7 @@ static void Initialize(Handle target, r = ares_init_options(env->cares_channel_ptr(), &options, ARES_OPT_FLAGS | ARES_OPT_SOCK_STATE_CB); - assert(r == ARES_SUCCESS); + CHECK_EQ(r, ARES_SUCCESS); /* Initialize the timeout timer. The timer won't be started until the */ /* first socket is opened. */ diff --git a/src/fs_event_wrap.cc b/src/fs_event_wrap.cc index 133acec070..b054b86a6c 100644 --- a/src/fs_event_wrap.cc +++ b/src/fs_event_wrap.cc @@ -74,7 +74,7 @@ FSEventWrap::FSEventWrap(Environment* env, Handle object) FSEventWrap::~FSEventWrap() { - assert(initialized_ == false); + CHECK_EQ(initialized_, false); } @@ -95,7 +95,7 @@ void FSEventWrap::Initialize(Handle target, void FSEventWrap::New(const FunctionCallbackInfo& args) { - assert(args.IsConstructCall()); + CHECK(args.IsConstructCall()); Environment* env = Environment::GetCurrent(args.GetIsolate()); new FSEventWrap(env, args.This()); } @@ -144,7 +144,7 @@ void FSEventWrap::OnEvent(uv_fs_event_t* handle, const char* filename, HandleScope handle_scope(env->isolate()); Context::Scope context_scope(env->context()); - assert(wrap->persistent().IsEmpty() == false); + CHECK_EQ(wrap->persistent().IsEmpty(), false); // We're in a bind here. libuv can set both UV_RENAME and UV_CHANGE but // the Node API only lets us pass a single event to JS land. @@ -165,7 +165,7 @@ void FSEventWrap::OnEvent(uv_fs_event_t* handle, const char* filename, } else if (events & UV_CHANGE) { event_string = env->change_string(); } else { - assert(0 && "bad fs events flag"); + CHECK(0 && "bad fs events flag"); abort(); } diff --git a/src/handle_wrap.cc b/src/handle_wrap.cc index eeda93017f..403b61ac98 100644 --- a/src/handle_wrap.cc +++ b/src/handle_wrap.cc @@ -69,7 +69,7 @@ void HandleWrap::Close(const FunctionCallbackInfo& args) { if (wrap == NULL || wrap->handle__ == NULL) return; - assert(!wrap->persistent().IsEmpty()); + CHECK_EQ(false, wrap->persistent().IsEmpty()); uv_close(wrap->handle__, OnClose); wrap->handle__ = NULL; @@ -95,7 +95,7 @@ HandleWrap::HandleWrap(Environment* env, HandleWrap::~HandleWrap() { - assert(persistent().IsEmpty()); + CHECK(persistent().IsEmpty()); QUEUE_REMOVE(&handle_wrap_queue_); } @@ -106,10 +106,10 @@ void HandleWrap::OnClose(uv_handle_t* handle) { HandleScope scope(env->isolate()); // The wrap object should still be there. - assert(wrap->persistent().IsEmpty() == false); + CHECK_EQ(wrap->persistent().IsEmpty(), false); // But the handle pointer should be gone. - assert(wrap->handle__ == NULL); + CHECK_EQ(wrap->handle__, NULL); HandleScope handle_scope(env->isolate()); Context::Scope context_scope(env->context()); diff --git a/src/node.cc b/src/node.cc index 023ef1ee09..69fbf47edc 100644 --- a/src/node.cc +++ b/src/node.cc @@ -58,7 +58,6 @@ #include "v8-profiler.h" #include "zlib.h" -#include #include #include // PATH_MAX #include @@ -911,10 +910,10 @@ Local WinapiErrnoException(Isolate* isolate, void SetupAsyncListener(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args.GetIsolate()); - assert(args[0]->IsObject()); - assert(args[1]->IsFunction()); - assert(args[2]->IsFunction()); - assert(args[3]->IsFunction()); + CHECK(args[0]->IsObject()); + CHECK(args[1]->IsFunction()); + CHECK(args[2]->IsFunction()); + CHECK(args[3]->IsFunction()); env->set_async_listener_run_function(args[1].As()); env->set_async_listener_load_function(args[2].As()); @@ -955,8 +954,8 @@ void SetupDomainUse(const FunctionCallbackInfo& args) { process_object->Set(env->tick_callback_string(), tick_callback_function); env->set_tick_callback_function(tick_callback_function); - assert(args[0]->IsArray()); - assert(args[1]->IsObject()); + CHECK(args[0]->IsArray()); + CHECK(args[1]->IsObject()); env->set_domain_array(args[0].As()); @@ -980,9 +979,9 @@ void RunMicrotasks(const FunctionCallbackInfo& args) { void SetupNextTick(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args.GetIsolate()); - assert(args[0]->IsObject()); - assert(args[1]->IsFunction()); - assert(args[2]->IsObject()); + CHECK(args[0]->IsObject()); + CHECK(args[1]->IsFunction()); + CHECK(args[2]->IsObject()); // Values use to cross communicate with processNextTick. Local tick_info_obj = args[0].As(); @@ -1007,7 +1006,7 @@ Handle MakeDomainCallback(Environment* env, int argc, Handle argv[]) { // If you hit this assertion, you forgot to enter the v8::Context first. - assert(env->context() == env->isolate()->GetCurrentContext()); + CHECK_EQ(env->context(), env->isolate()->GetCurrentContext()); Local process = env->process_object(); Local object, domain; @@ -1118,7 +1117,7 @@ Handle MakeCallback(Environment* env, return MakeDomainCallback(env, recv, callback, argc, argv); // If you hit this assertion, you forgot to enter the v8::Context first. - assert(env->context() == env->isolate()->GetCurrentContext()); + CHECK_EQ(env->context(), env->isolate()->GetCurrentContext()); Local process = env->process_object(); @@ -1185,7 +1184,7 @@ Handle MakeCallback(Environment* env, int argc, Handle argv[]) { Local callback = recv->Get(index).As(); - assert(callback->IsFunction()); + CHECK(callback->IsFunction()); return MakeCallback(env, recv.As(), callback, argc, argv); } @@ -1197,7 +1196,7 @@ Handle MakeCallback(Environment* env, int argc, Handle argv[]) { Local callback = recv->Get(symbol).As(); - assert(callback->IsFunction()); + CHECK(callback->IsFunction()); return MakeCallback(env, recv.As(), callback, argc, argv); } @@ -1337,7 +1336,7 @@ ssize_t DecodeBytes(Isolate* isolate, if (val->IsArray()) { fprintf(stderr, "'raw' encoding (array of integers) has been removed. " "Use 'binary'.\n"); - assert(0); + UNREACHABLE(); return -1; } @@ -1414,7 +1413,7 @@ void AppendExceptionLine(Environment* env, filename_string, linenum, sourceline_string); - assert(off >= 0); + CHECK_GE(off, 0); // Print wavy underline (GetUnderline is deprecated). for (int i = 0; i < start; i++) { @@ -1422,7 +1421,7 @@ void AppendExceptionLine(Environment* env, static_cast(off) >= sizeof(arrow)) { break; } - assert(static_cast(off) < sizeof(arrow)); + CHECK_LT(static_cast(off), sizeof(arrow)); arrow[off++] = (sourceline_string[i] == '\t') ? '\t' : ' '; } for (int i = start; i < end; i++) { @@ -1430,10 +1429,10 @@ void AppendExceptionLine(Environment* env, static_cast(off) >= sizeof(arrow)) { break; } - assert(static_cast(off) < sizeof(arrow)); + CHECK_LT(static_cast(off), sizeof(arrow)); arrow[off++] = '^'; } - assert(static_cast(off - 1) <= sizeof(arrow) - 1); + CHECK_LE(static_cast(off - 1), sizeof(arrow) - 1); arrow[off++] = '\n'; arrow[off] = '\0'; @@ -2035,7 +2034,7 @@ extern "C" void node_module_register(void* m) { mp->nm_link = modlist_builtin; modlist_builtin = mp; } else { - assert(modpending == NULL); + CHECK_EQ(modpending, NULL); modpending = mp; } } @@ -2048,7 +2047,7 @@ struct node_module* get_builtin_module(const char* name) { break; } - assert(mp == NULL || (mp->nm_flags & NM_F_BUILTIN) != 0); + CHECK(mp == NULL || (mp->nm_flags & NM_F_BUILTIN) != 0); return (mp); } @@ -2230,8 +2229,8 @@ static void Binding(const FunctionCallbackInfo& args) { if (mod != NULL) { exports = Object::New(env->isolate()); // Internal bindings don't have a "module" object, only exports. - assert(mod->nm_register_func == NULL); - assert(mod->nm_context_register_func != NULL); + CHECK_EQ(mod->nm_register_func, NULL); + CHECK_NE(mod->nm_context_register_func, NULL); Local unused = Undefined(env->isolate()); mod->nm_context_register_func(exports, unused, env->context(), mod->nm_priv); @@ -2825,8 +2824,8 @@ static void SignalExit(int signo) { static void RawDebug(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args.GetIsolate()); - assert(args.Length() == 1 && args[0]->IsString() && - "must be called with a single string"); + CHECK(args.Length() == 1 && args[0]->IsString() && + "must be called with a single string"); node::Utf8Value message(args[0]); fprintf(stderr, "%s\n", *message); @@ -2860,7 +2859,7 @@ void LoadEnvironment(Environment* env) { ReportException(env, try_catch); exit(10); } - assert(f_value->IsFunction()); + CHECK(f_value->IsFunction()); Local f = Local::Cast(f_value); // Now we call 'f' with the 'process' variable that we've built up with @@ -3675,7 +3674,7 @@ int Start(int argc, char** argv) { InstallEarlyDebugSignalHandler(); #endif - assert(argc > 0); + CHECK_GT(argc, 0); // Hack around with the argv pointer. Used for process.title = "blah". argv = uv_setup_args(argc, argv); diff --git a/src/node_buffer.cc b/src/node_buffer.cc index ae33b03b38..90c0eb5750 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -30,7 +30,6 @@ #include "v8-profiler.h" #include "v8.h" -#include #include #include @@ -47,7 +46,7 @@ char* obj_data = static_cast( \ obj->GetIndexedPropertiesExternalArrayData()); \ if (obj_length > 0) \ - assert(obj_data != NULL); + CHECK_NE(obj_data, NULL); #define SLICE_START_END(start_arg, end_arg, end_max) \ size_t start; \ @@ -91,7 +90,7 @@ bool HasInstance(Handle obj) { char* Data(Handle val) { - assert(val->IsObject()); + CHECK(val->IsObject()); // Use a fully qualified name here to work around a bug in gcc 4.2. // It mistakes an unadorned call to Data() for the v8::String::Data type. return node::Buffer::Data(val.As()); @@ -99,19 +98,19 @@ char* Data(Handle val) { char* Data(Handle obj) { - assert(obj->HasIndexedPropertiesInExternalArrayData()); + CHECK(obj->HasIndexedPropertiesInExternalArrayData()); return static_cast(obj->GetIndexedPropertiesExternalArrayData()); } size_t Length(Handle val) { - assert(val->IsObject()); + CHECK(val->IsObject()); return Length(val.As()); } size_t Length(Handle obj) { - assert(obj->HasIndexedPropertiesInExternalArrayData()); + CHECK(obj->HasIndexedPropertiesInExternalArrayData()); return obj->GetIndexedPropertiesExternalArrayDataLength(); } @@ -141,7 +140,7 @@ Local New(Isolate* isolate, size_t length) { Local New(Environment* env, size_t length) { EscapableHandleScope scope(env->isolate()); - assert(length <= kMaxLength); + CHECK_LE(length, kMaxLength); Local arg = Uint32::NewFromUnsigned(env->isolate(), length); Local obj = env->buffer_constructor_function()->NewInstance(1, &arg); @@ -177,7 +176,7 @@ Local New(Isolate* isolate, const char* data, size_t length) { Local New(Environment* env, const char* data, size_t length) { EscapableHandleScope scope(env->isolate()); - assert(length <= kMaxLength); + CHECK_LE(length, kMaxLength); Local arg = Uint32::NewFromUnsigned(env->isolate(), length); Local obj = env->buffer_constructor_function()->NewInstance(1, &arg); @@ -220,7 +219,7 @@ Local New(Environment* env, void* hint) { EscapableHandleScope scope(env->isolate()); - assert(length <= kMaxLength); + CHECK_LE(length, kMaxLength); Local arg = Uint32::NewFromUnsigned(env->isolate(), length); Local obj = env->buffer_constructor_function()->NewInstance(1, &arg); @@ -242,7 +241,7 @@ Local Use(Isolate* isolate, char* data, uint32_t length) { Local Use(Environment* env, char* data, uint32_t length) { EscapableHandleScope scope(env->isolate()); - assert(length <= kMaxLength); + CHECK_LE(length, kMaxLength); Local arg = Uint32::NewFromUnsigned(env->isolate(), length); Local obj = env->buffer_constructor_function()->NewInstance(1, &arg); @@ -591,13 +590,13 @@ void Compare(const FunctionCallbackInfo &args) { void SetupBufferJS(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args.GetIsolate()); - assert(args[0]->IsFunction()); + CHECK(args[0]->IsFunction()); Local bv = args[0].As(); env->set_buffer_constructor_function(bv); Local proto_v = bv->Get(env->prototype_string()); - assert(proto_v->IsObject()); + CHECK(proto_v->IsObject()); Local proto = proto_v.As(); @@ -622,7 +621,7 @@ void SetupBufferJS(const FunctionCallbackInfo& args) { Uint32::New(env->isolate(), 0), v8::ReadOnly); - assert(args[1]->IsObject()); + CHECK(args[1]->IsObject()); Local internal = args[1].As(); ASSERT(internal->IsObject()); diff --git a/src/node_contextify.cc b/src/node_contextify.cc index bb7f4f1f37..89217386ad 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -184,7 +184,7 @@ class ContextifyContext { "binding:script"); Local