Browse Source

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 <fedor@indutny.com>
archived-io.js-v0.12
Ben Noordhuis 10 years ago
committed by Fedor Indutny
parent
commit
5fdff3854a
  1. 10
      src/async-wrap-inl.h
  2. 8
      src/base-object-inl.h
  3. 57
      src/cares_wrap.cc
  4. 8
      src/fs_event_wrap.cc
  5. 8
      src/handle_wrap.cc
  6. 53
      src/node.cc
  7. 25
      src/node_buffer.cc
  8. 4
      src/node_contextify.cc
  9. 48
      src/node_crypto.cc
  10. 4
      src/node_crypto.h
  11. 32
      src/node_crypto_bio.cc
  12. 5
      src/node_crypto_bio.h
  13. 5
      src/node_crypto_clienthello-inl.h
  14. 15
      src/node_file.cc
  15. 26
      src/node_http_parser.cc
  16. 1
      src/node_internals.h
  17. 7
      src/node_stat_watcher.cc
  18. 1
      src/node_watchdog.cc
  19. 2
      src/node_win32_etw_provider-inl.h
  20. 2
      src/node_win32_etw_provider.cc
  21. 50
      src/node_zlib.cc
  22. 24
      src/pipe_wrap.cc
  23. 10
      src/process_wrap.cc
  24. 4
      src/req_wrap.h
  25. 4
      src/signal_wrap.cc
  26. 35
      src/smalloc.cc
  27. 64
      src/spawn_sync.cc
  28. 44
      src/stream_wrap.cc
  29. 6
      src/stream_wrap.h
  30. 23
      src/string_bytes.cc
  31. 40
      src/tcp_wrap.cc
  32. 4
      src/timer_wrap.cc
  33. 24
      src/tls_wrap.cc
  34. 10
      src/tty_wrap.cc
  35. 34
      src/udp_wrap.cc
  36. 10
      src/util-inl.h

10
src/async-wrap-inl.h

@ -29,9 +29,7 @@
#include "env-inl.h"
#include "util.h"
#include "util-inl.h"
#include "v8.h"
#include <assert.h>
namespace node {
@ -74,7 +72,7 @@ inline v8::Handle<v8::Value> AsyncWrap::MakeDomainCallback(
const v8::Handle<v8::Function> cb,
int argc,
v8::Handle<v8::Value>* argv) {
assert(env()->context() == env()->isolate()->GetCurrentContext());
CHECK_EQ(env()->context(), env()->isolate()->GetCurrentContext());
v8::Local<v8::Object> context = object();
v8::Local<v8::Object> process = env()->process_object();
@ -169,7 +167,7 @@ inline v8::Handle<v8::Value> 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<v8::Object> context = object();
v8::Local<v8::Object> process = env()->process_object();
@ -235,7 +233,7 @@ inline v8::Handle<v8::Value> AsyncWrap::MakeCallback(
v8::Handle<v8::Value>* argv) {
v8::Local<v8::Value> cb_v = object()->Get(symbol);
v8::Local<v8::Function> cb = cb_v.As<v8::Function>();
assert(cb->IsFunction());
CHECK(cb->IsFunction());
return MakeCallback(cb, argc, argv);
}
@ -247,7 +245,7 @@ inline v8::Handle<v8::Value> AsyncWrap::MakeCallback(
v8::Handle<v8::Value>* argv) {
v8::Local<v8::Value> cb_v = object()->Get(index);
v8::Local<v8::Function> cb = cb_v.As<v8::Function>();
assert(cb->IsFunction());
CHECK(cb->IsFunction());
return MakeCallback(cb, argc, argv);
}

8
src/base-object-inl.h

@ -27,19 +27,17 @@
#include "util-inl.h"
#include "v8.h"
#include <assert.h>
namespace node {
inline BaseObject::BaseObject(Environment* env, v8::Local<v8::Object> 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 <typename Type>
inline void BaseObject::MakeWeak(Type* ptr) {
v8::HandleScope scope(env_->isolate());
v8::Local<v8::Object> handle = object();
assert(handle->InternalFieldCount() > 0);
CHECK_GT(handle->InternalFieldCount(), 0);
Wrap<Type>(handle, ptr);
handle_.MarkIndependent();
handle_.SetWeak<Type>(ptr, WeakCallback<Type>);

57
src/cares_wrap.cc

@ -31,7 +31,6 @@
#include "util.h"
#include "uv.h"
#include <assert.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
@ -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<uv_handle_t*>(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<uv_handle_t*>(&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<Value> 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 <class Wrap>
static void Query(const FunctionCallbackInfo<Value>& 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<Object> req_wrap_obj = args[0].As<Object>();
Local<String> string = args[1].As<String>();
@ -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<Value>& args) {
static void GetAddrInfo(const FunctionCallbackInfo<Value>& 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<Object> req_wrap_obj = args[0].As<Object>();
node::Utf8Value hostname(args[1]);
@ -1028,7 +1027,7 @@ static void GetAddrInfo(const FunctionCallbackInfo<Value>& 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<Value>& 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<Value>& args) {
const void* caddr = static_cast<const void*>(&cur->addr);
int err = uv_inet_ntop(cur->family, caddr, ip, sizeof(ip));
assert(err == 0);
CHECK_EQ(err, 0);
Local<String> addr = OneByteString(env->isolate(), ip);
server_array->Set(i, addr);
@ -1121,7 +1120,7 @@ static void GetServers(const FunctionCallbackInfo<Value>& args) {
static void SetServers(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
assert(args[0]->IsArray());
CHECK(args[0]->IsArray());
Local<Array> arr = Local<Array>::Cast(args[0]);
@ -1138,12 +1137,12 @@ static void SetServers(const FunctionCallbackInfo<Value>& args) {
int err;
for (uint32_t i = 0; i < len; i++) {
assert(arr->Get(i)->IsArray());
CHECK(arr->Get(i)->IsArray());
Local<Array> elm = Local<Array>::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<Value>& 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<Object> 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<Object> 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. */

8
src/fs_event_wrap.cc

@ -74,7 +74,7 @@ FSEventWrap::FSEventWrap(Environment* env, Handle<Object> object)
FSEventWrap::~FSEventWrap() {
assert(initialized_ == false);
CHECK_EQ(initialized_, false);
}
@ -95,7 +95,7 @@ void FSEventWrap::Initialize(Handle<Object> target,
void FSEventWrap::New(const FunctionCallbackInfo<Value>& 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();
}

8
src/handle_wrap.cc

@ -69,7 +69,7 @@ void HandleWrap::Close(const FunctionCallbackInfo<Value>& 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());

53
src/node.cc

@ -58,7 +58,6 @@
#include "v8-profiler.h"
#include "zlib.h"
#include <assert.h>
#include <errno.h>
#include <limits.h> // PATH_MAX
#include <locale.h>
@ -911,10 +910,10 @@ Local<Value> WinapiErrnoException(Isolate* isolate,
void SetupAsyncListener(const FunctionCallbackInfo<Value>& 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<Function>());
env->set_async_listener_load_function(args[2].As<Function>());
@ -955,8 +954,8 @@ void SetupDomainUse(const FunctionCallbackInfo<Value>& 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<Array>());
@ -980,9 +979,9 @@ void RunMicrotasks(const FunctionCallbackInfo<Value>& args) {
void SetupNextTick(const FunctionCallbackInfo<Value>& 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<Object> tick_info_obj = args[0].As<Object>();
@ -1007,7 +1006,7 @@ Handle<Value> MakeDomainCallback(Environment* env,
int argc,
Handle<Value> 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<Object> process = env->process_object();
Local<Object> object, domain;
@ -1118,7 +1117,7 @@ Handle<Value> 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<Object> process = env->process_object();
@ -1185,7 +1184,7 @@ Handle<Value> MakeCallback(Environment* env,
int argc,
Handle<Value> argv[]) {
Local<Function> callback = recv->Get(index).As<Function>();
assert(callback->IsFunction());
CHECK(callback->IsFunction());
return MakeCallback(env, recv.As<Value>(), callback, argc, argv);
}
@ -1197,7 +1196,7 @@ Handle<Value> MakeCallback(Environment* env,
int argc,
Handle<Value> argv[]) {
Local<Function> callback = recv->Get(symbol).As<Function>();
assert(callback->IsFunction());
CHECK(callback->IsFunction());
return MakeCallback(env, recv.As<Value>(), 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<size_t>(off) >= sizeof(arrow)) {
break;
}
assert(static_cast<size_t>(off) < sizeof(arrow));
CHECK_LT(static_cast<size_t>(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<size_t>(off) >= sizeof(arrow)) {
break;
}
assert(static_cast<size_t>(off) < sizeof(arrow));
CHECK_LT(static_cast<size_t>(off), sizeof(arrow));
arrow[off++] = '^';
}
assert(static_cast<size_t>(off - 1) <= sizeof(arrow) - 1);
CHECK_LE(static_cast<size_t>(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<Value>& 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<Value> 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<Value>& 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<Function> f = Local<Function>::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);

25
src/node_buffer.cc

@ -30,7 +30,6 @@
#include "v8-profiler.h"
#include "v8.h"
#include <assert.h>
#include <string.h>
#include <limits.h>
@ -47,7 +46,7 @@
char* obj_data = static_cast<char*>( \
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<Object> obj) {
char* Data(Handle<Value> 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<Object>());
@ -99,19 +98,19 @@ char* Data(Handle<Value> val) {
char* Data(Handle<Object> obj) {
assert(obj->HasIndexedPropertiesInExternalArrayData());
CHECK(obj->HasIndexedPropertiesInExternalArrayData());
return static_cast<char*>(obj->GetIndexedPropertiesExternalArrayData());
}
size_t Length(Handle<Value> val) {
assert(val->IsObject());
CHECK(val->IsObject());
return Length(val.As<Object>());
}
size_t Length(Handle<Object> obj) {
assert(obj->HasIndexedPropertiesInExternalArrayData());
CHECK(obj->HasIndexedPropertiesInExternalArrayData());
return obj->GetIndexedPropertiesExternalArrayDataLength();
}
@ -141,7 +140,7 @@ Local<Object> New(Isolate* isolate, size_t length) {
Local<Object> New(Environment* env, size_t length) {
EscapableHandleScope scope(env->isolate());
assert(length <= kMaxLength);
CHECK_LE(length, kMaxLength);
Local<Value> arg = Uint32::NewFromUnsigned(env->isolate(), length);
Local<Object> obj = env->buffer_constructor_function()->NewInstance(1, &arg);
@ -177,7 +176,7 @@ Local<Object> New(Isolate* isolate, const char* data, size_t length) {
Local<Object> New(Environment* env, const char* data, size_t length) {
EscapableHandleScope scope(env->isolate());
assert(length <= kMaxLength);
CHECK_LE(length, kMaxLength);
Local<Value> arg = Uint32::NewFromUnsigned(env->isolate(), length);
Local<Object> obj = env->buffer_constructor_function()->NewInstance(1, &arg);
@ -220,7 +219,7 @@ Local<Object> New(Environment* env,
void* hint) {
EscapableHandleScope scope(env->isolate());
assert(length <= kMaxLength);
CHECK_LE(length, kMaxLength);
Local<Value> arg = Uint32::NewFromUnsigned(env->isolate(), length);
Local<Object> obj = env->buffer_constructor_function()->NewInstance(1, &arg);
@ -242,7 +241,7 @@ Local<Object> Use(Isolate* isolate, char* data, uint32_t length) {
Local<Object> Use(Environment* env, char* data, uint32_t length) {
EscapableHandleScope scope(env->isolate());
assert(length <= kMaxLength);
CHECK_LE(length, kMaxLength);
Local<Value> arg = Uint32::NewFromUnsigned(env->isolate(), length);
Local<Object> obj = env->buffer_constructor_function()->NewInstance(1, &arg);
@ -591,13 +590,13 @@ void Compare(const FunctionCallbackInfo<Value> &args) {
void SetupBufferJS(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
assert(args[0]->IsFunction());
CHECK(args[0]->IsFunction());
Local<Function> bv = args[0].As<Function>();
env->set_buffer_constructor_function(bv);
Local<Value> proto_v = bv->Get(env->prototype_string());
assert(proto_v->IsObject());
CHECK(proto_v->IsObject());
Local<Object> proto = proto_v.As<Object>();
@ -622,7 +621,7 @@ void SetupBufferJS(const FunctionCallbackInfo<Value>& args) {
Uint32::New(env->isolate(), 0),
v8::ReadOnly);
assert(args[1]->IsObject());
CHECK(args[1]->IsObject());
Local<Object> internal = args[1].As<Object>();
ASSERT(internal->IsObject());

4
src/node_contextify.cc

@ -184,7 +184,7 @@ class ContextifyContext {
"binding:script");
Local<Script> script = Script::Compile(code, fname);
clone_property_method = Local<Function>::Cast(script->Run());
assert(clone_property_method->IsFunction());
CHECK(clone_property_method->IsFunction());
}
Local<Value> args[] = { global, key, sandbox };
clone_property_method->Call(global, ARRAY_SIZE(args), args);
@ -276,7 +276,7 @@ class ContextifyContext {
FIXED_ONE_BYTE_STRING(env->isolate(), "_contextifyHidden");
// Don't allow contextifying a sandbox multiple times.
assert(sandbox->GetHiddenValue(hidden_name).IsEmpty());
CHECK(sandbox->GetHiddenValue(hidden_name).IsEmpty());
TryCatch try_catch;
ContextifyContext* context = new ContextifyContext(env, sandbox);

48
src/node_crypto.cc

@ -168,8 +168,8 @@ static void crypto_lock_init(void) {
static void crypto_lock_cb(int mode, int n, const char* file, int line) {
assert((mode & CRYPTO_LOCK) || (mode & CRYPTO_UNLOCK));
assert((mode & CRYPTO_READ) || (mode & CRYPTO_WRITE));
CHECK((mode & CRYPTO_LOCK) || (mode & CRYPTO_UNLOCK));
CHECK((mode & CRYPTO_READ) || (mode & CRYPTO_WRITE));
if (mode & CRYPTO_LOCK) {
if (mode & CRYPTO_READ)
@ -669,7 +669,7 @@ void SecureContext::AddCRL(const FunctionCallbackInfo<Value>& args) {
void SecureContext::AddRootCerts(const FunctionCallbackInfo<Value>& args) {
SecureContext* sc = Unwrap<SecureContext>(args.Holder());
assert(sc->ca_store_ == NULL);
CHECK_EQ(sc->ca_store_, NULL);
if (!root_cert_store) {
root_cert_store = X509_STORE_new();
@ -1149,10 +1149,10 @@ static Local<Object> X509ToObject(Environment* env, X509* cert) {
int rv;
ext = X509_get_ext(cert, index);
assert(ext != NULL);
CHECK_NE(ext, NULL);
rv = X509V3_EXT_print(bio, ext, 0, 0);
assert(rv == 1);
CHECK_EQ(rv, 1);
BIO_get_mem_ptr(bio, &mem);
info->Set(keys[i],
@ -1386,7 +1386,7 @@ void SSLWrap<Base>::GetSession(const FunctionCallbackInfo<Value>& args) {
return;
int slen = i2d_SSL_SESSION(sess, NULL);
assert(slen > 0);
CHECK_GT(slen, 0);
unsigned char* sbuf = new unsigned char[slen];
unsigned char* p = sbuf;
@ -1806,7 +1806,7 @@ int SSLWrap<Base>::TLSExtStatusCallback(SSL* s, void* arg) {
// OpenSSL takes control of the pointer after accepting it
char* data = reinterpret_cast<char*>(malloc(len));
assert(data != NULL);
CHECK_NE(data, NULL);
memcpy(data, resp, len);
if (!SSL_set_tlsext_status_ocsp_resp(s, data, len))
@ -1930,7 +1930,7 @@ int Connection::HandleSSLError(const char* func,
BUF_MEM* mem;
BIO *bio;
assert(err == SSL_ERROR_SSL || err == SSL_ERROR_SYSCALL);
CHECK(err == SSL_ERROR_SSL || err == SSL_ERROR_SYSCALL);
// XXX We need to drain the error queue for this thread or else OpenSSL
// has the possibility of blocking connections? This problem is not well
@ -1963,7 +1963,7 @@ void Connection::ClearError() {
// We should clear the error in JS-land
Local<String> error_key = ssl_env()->error_string();
Local<Value> error = object()->Get(error_key);
assert(error->BooleanValue() == false);
CHECK_EQ(error->BooleanValue(), false);
#endif // NDEBUG
}
@ -2477,7 +2477,7 @@ void CipherBase::Initialize(Environment* env, Handle<Object> target) {
void CipherBase::New(const FunctionCallbackInfo<Value>& args) {
assert(args.IsConstructCall() == true);
CHECK_EQ(args.IsConstructCall(), true);
CipherKind kind = args[0]->IsTrue() ? kCipher : kDecipher;
Environment* env = Environment::GetCurrent(args.GetIsolate());
new CipherBase(env, args.This(), kind);
@ -2489,7 +2489,7 @@ void CipherBase::Init(const char* cipher_type,
int key_buf_len) {
HandleScope scope(env()->isolate());
assert(cipher_ == NULL);
CHECK_EQ(cipher_, NULL);
cipher_ = EVP_get_cipherbyname(cipher_type);
if (cipher_ == NULL) {
return env()->ThrowError("Unknown cipher");
@ -2851,7 +2851,7 @@ void Hmac::New(const FunctionCallbackInfo<Value>& args) {
void Hmac::HmacInit(const char* hash_type, const char* key, int key_len) {
HandleScope scope(env()->isolate());
assert(md_ == NULL);
CHECK_EQ(md_, NULL);
md_ = EVP_get_digestbyname(hash_type);
if (md_ == NULL) {
return env()->ThrowError("Unknown message digest");
@ -2994,7 +2994,7 @@ void Hash::New(const FunctionCallbackInfo<Value>& args) {
bool Hash::HashInit(const char* hash_type) {
assert(md_ == NULL);
CHECK_EQ(md_, NULL);
md_ = EVP_get_digestbyname(hash_type);
if (md_ == NULL)
return false;
@ -3137,7 +3137,7 @@ void Sign::New(const FunctionCallbackInfo<Value>& args) {
SignBase::Error Sign::SignInit(const char* sign_type) {
assert(md_ == NULL);
CHECK_EQ(md_, NULL);
md_ = EVP_get_digestbyname(sign_type);
if (!md_)
return kSignUnknownDigest;
@ -3314,7 +3314,7 @@ void Verify::New(const FunctionCallbackInfo<Value>& args) {
SignBase::Error Verify::VerifyInit(const char* verify_type) {
assert(md_ == NULL);
CHECK_EQ(md_, NULL);
md_ = EVP_get_digestbyname(verify_type);
if (md_ == NULL)
return kSignUnknownDigest;
@ -3485,7 +3485,7 @@ void Verify::VerifyFinal(const FunctionCallbackInfo<Value>& args) {
hlen,
args[1],
encoding);
assert(hwritten == hlen);
CHECK_EQ(hwritten, hlen);
} else {
hbuf = Buffer::Data(args[1]);
}
@ -3943,14 +3943,14 @@ void DiffieHellman::ComputeSecret(const FunctionCallbackInfo<Value>& args) {
}
BN_free(key);
assert(size >= 0);
CHECK_GE(size, 0);
// DH_size returns number of bytes in a prime number
// DH_compute_key returns number of bytes in a remainder of exponent, which
// may have less bytes than a prime number. Therefore add 0-padding to the
// allocated buffer.
if (size != dataSize) {
assert(dataSize > size);
CHECK(dataSize > size);
memmove(data + dataSize - size, data, size);
memset(data, 0, dataSize - size);
}
@ -4363,7 +4363,7 @@ void EIO_PBKDF2After(PBKDF2Request* req, Local<Value> argv[2]) {
void EIO_PBKDF2After(uv_work_t* work_req, int status) {
assert(status == 0);
CHECK_EQ(status, 0);
PBKDF2Request* req = ContainerOf(&PBKDF2Request::work_req_, work_req);
Environment* env = req->env();
HandleScope handle_scope(env->isolate());
@ -4600,7 +4600,7 @@ void RandomBytesCheck(RandomBytesRequest* req, Local<Value> argv[2]) {
void RandomBytesAfter(uv_work_t* work_req, int status) {
assert(status == 0);
CHECK_EQ(status, 0);
RandomBytesRequest* req =
ContainerOf(&RandomBytesRequest::work_req_, work_req);
Environment* env = req->env();
@ -4789,7 +4789,7 @@ void Certificate::VerifySpkac(const FunctionCallbackInfo<Value>& args) {
return args.GetReturnValue().Set(i);
char* data = Buffer::Data(args[0]);
assert(data != NULL);
CHECK_NE(data, NULL);
i = certificate->VerifySpkac(data, length);
@ -4853,7 +4853,7 @@ void Certificate::ExportPublicKey(const FunctionCallbackInfo<Value>& args) {
return args.GetReturnValue().SetEmptyString();
char* data = Buffer::Data(args[0]);
assert(data != NULL);
CHECK_NE(data, NULL);
const char* pkey = certificate->ExportPublicKey(data, length);
if (pkey == NULL)
@ -4896,7 +4896,7 @@ void Certificate::ExportChallenge(const FunctionCallbackInfo<Value>& args) {
return args.GetReturnValue().SetEmptyString();
char* data = Buffer::Data(args[0]);
assert(data != NULL);
CHECK_NE(data, NULL);
const char* cert = crt->ExportChallenge(data, len);
if (cert == NULL)
@ -4927,7 +4927,7 @@ void InitCryptoOnce() {
STACK_OF(SSL_COMP)* comp_methods = SSL_COMP_get_compression_methods();
#endif
sk_SSL_COMP_zero(comp_methods);
assert(sk_SSL_COMP_num(comp_methods) == 0);
CHECK_EQ(sk_SSL_COMP_num(comp_methods), 0);
#endif
#ifndef OPENSSL_NO_ENGINE

4
src/node_crypto.h

@ -139,7 +139,7 @@ class SecureContext : public BaseObject {
cert_ = NULL;
issuer_ = NULL;
} else {
assert(ca_store_ == NULL);
CHECK_EQ(ca_store_, NULL);
}
}
};
@ -161,7 +161,7 @@ class SSLWrap {
session_callbacks_(false),
new_session_wait_(false) {
ssl_ = SSL_new(sc->ctx_);
assert(ssl_ != NULL);
CHECK_NE(ssl_, NULL);
}
~SSLWrap() {

32
src/node_crypto_bio.cc

@ -21,6 +21,8 @@
#include "node_crypto_bio.h"
#include "openssl/bio.h"
#include "util.h"
#include "util-inl.h"
#include <string.h>
namespace node {
@ -185,11 +187,11 @@ long NodeBIO::Ctrl(BIO* bio, int cmd, long num, void* ptr) {
*reinterpret_cast<void**>(ptr) = NULL;
break;
case BIO_C_SET_BUF_MEM:
assert(0 && "Can't use SET_BUF_MEM_PTR with NodeBIO");
CHECK(0 && "Can't use SET_BUF_MEM_PTR with NodeBIO");
abort();
break;
case BIO_C_GET_BUF_MEM_PTR:
assert(0 && "Can't use GET_BUF_MEM_PTR with NodeBIO");
CHECK(0 && "Can't use GET_BUF_MEM_PTR with NodeBIO");
ret = 0;
break;
case BIO_CTRL_GET_CLOSE:
@ -244,7 +246,7 @@ size_t NodeBIO::Read(char* out, size_t size) {
size_t left = size;
while (bytes_read < expected) {
assert(read_head_->read_pos_ <= read_head_->write_pos_);
CHECK_LE(read_head_->read_pos_, read_head_->write_pos_);
size_t avail = read_head_->write_pos_ - read_head_->read_pos_;
if (avail > left)
avail = left;
@ -261,7 +263,7 @@ size_t NodeBIO::Read(char* out, size_t size) {
TryMoveReadHead();
}
assert(expected == bytes_read);
CHECK_EQ(expected, bytes_read);
length_ -= bytes_read;
// Free all empty buffers, but write_head's child
@ -283,8 +285,8 @@ void NodeBIO::FreeEmpty() {
Buffer* prev = child;
while (cur != read_head_) {
assert(cur != write_head_);
assert(cur->write_pos_ == cur->read_pos_);
CHECK_NE(cur, write_head_);
CHECK_EQ(cur->write_pos_, cur->read_pos_);
Buffer* next = cur->next_;
delete cur;
@ -301,7 +303,7 @@ size_t NodeBIO::IndexOf(char delim, size_t limit) {
Buffer* current = read_head_;
while (bytes_read < max) {
assert(current->read_pos_ <= current->write_pos_);
CHECK_LE(current->read_pos_, current->write_pos_);
size_t avail = current->write_pos_ - current->read_pos_;
if (avail > left)
avail = left;
@ -328,7 +330,7 @@ size_t NodeBIO::IndexOf(char delim, size_t limit) {
current = current->next_;
}
}
assert(max == bytes_read);
CHECK_EQ(max, bytes_read);
return max;
}
@ -343,7 +345,7 @@ void NodeBIO::Write(const char* data, size_t size) {
while (left > 0) {
size_t to_write = left;
assert(write_head_->write_pos_ <= write_head_->len_);
CHECK_LE(write_head_->write_pos_, write_head_->len_);
size_t avail = write_head_->len_ - write_head_->write_pos_;
if (to_write > avail)
@ -359,11 +361,11 @@ void NodeBIO::Write(const char* data, size_t size) {
offset += to_write;
length_ += to_write;
write_head_->write_pos_ += to_write;
assert(write_head_->write_pos_ <= write_head_->len_);
CHECK_LE(write_head_->write_pos_, write_head_->len_);
// Go to next buffer if there still are some bytes to write
if (left != 0) {
assert(write_head_->write_pos_ == write_head_->len_);
CHECK_EQ(write_head_->write_pos_, write_head_->len_);
TryAllocateForWrite(left);
write_head_ = write_head_->next_;
@ -372,7 +374,7 @@ void NodeBIO::Write(const char* data, size_t size) {
TryMoveReadHead();
}
}
assert(left == 0);
CHECK_EQ(left, 0);
}
@ -392,7 +394,7 @@ char* NodeBIO::PeekWritable(size_t* size) {
void NodeBIO::Commit(size_t size) {
write_head_->write_pos_ += size;
length_ += size;
assert(write_head_->write_pos_ <= write_head_->len_);
CHECK_LE(write_head_->write_pos_, write_head_->len_);
// Allocate new buffer if write head is full,
// and there're no other place to go
@ -437,7 +439,7 @@ void NodeBIO::Reset() {
return;
while (read_head_->read_pos_ != read_head_->write_pos_) {
assert(read_head_->write_pos_ > read_head_->read_pos_);
CHECK(read_head_->write_pos_ > read_head_->read_pos_);
length_ -= read_head_->write_pos_ - read_head_->read_pos_;
read_head_->write_pos_ = 0;
@ -446,7 +448,7 @@ void NodeBIO::Reset() {
read_head_ = read_head_->next_;
}
write_head_ = read_head_;
assert(length_ == 0);
CHECK_EQ(length_, 0);
}

5
src/node_crypto_bio.h

@ -23,7 +23,8 @@
#define SRC_NODE_CRYPTO_BIO_H_
#include "openssl/bio.h"
#include <assert.h>
#include "util.h"
#include "util-inl.h"
namespace node {
@ -88,7 +89,7 @@ class NodeBIO {
}
static inline NodeBIO* FromBIO(BIO* bio) {
assert(bio->ptr != NULL);
CHECK_NE(bio->ptr, NULL);
return static_cast<NodeBIO*>(bio->ptr);
}

5
src/node_crypto_clienthello-inl.h

@ -22,7 +22,8 @@
#ifndef SRC_NODE_CRYPTO_CLIENTHELLO_INL_H_
#define SRC_NODE_CRYPTO_CLIENTHELLO_INL_H_
#include <assert.h>
#include "util.h"
#include "util-inl.h"
namespace node {
@ -45,7 +46,7 @@ inline void ClientHelloParser::Start(ClientHelloParser::OnHelloCb onhello_cb,
return;
Reset();
assert(onhello_cb != NULL);
CHECK_NE(onhello_cb, NULL);
state_ = kWaiting;
onhello_cb_ = onhello_cb;

15
src/node_file.cc

@ -34,7 +34,6 @@
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <assert.h>
#include <string.h>
#include <errno.h>
#include <limits.h>
@ -116,7 +115,7 @@ static inline bool IsInt64(double x) {
static void After(uv_fs_t *req) {
FSReqWrap* req_wrap = static_cast<FSReqWrap*>(req->data);
assert(&req_wrap->req_ == req);
CHECK_EQ(&req_wrap->req_, req);
req_wrap->ReleaseEarly(); // Free memory that's no longer used now.
Environment* env = req_wrap->env();
@ -234,7 +233,7 @@ static void After(uv_fs_t *req) {
break;
default:
assert(0 && "Unhandled eio response");
CHECK(0 && "Unhandled eio response");
}
}
@ -330,7 +329,7 @@ static void Close(const FunctionCallbackInfo<Value>& args) {
Local<Value> BuildStatsObject(Environment* env, const uv_stat_t* s) {
// 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());
EscapableHandleScope handle_scope(env->isolate());
@ -699,7 +698,7 @@ static void ReadDir(const FunctionCallbackInfo<Value>& args) {
} else {
SYNC_CALL(readdir, *path, *path, 0 /*flags*/)
assert(SYNC_REQ.result >= 0);
CHECK_GE(SYNC_REQ.result, 0);
int r;
Local<Array> names = Array::New(env->isolate(), 0);
@ -763,8 +762,8 @@ static void Open(const FunctionCallbackInfo<Value>& args) {
static void WriteBuffer(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
assert(args[0]->IsInt32());
assert(Buffer::HasInstance(args[1]));
CHECK(args[0]->IsInt32());
CHECK(Buffer::HasInstance(args[1]));
int fd = args[0]->Int32Value();
Local<Object> obj = args[1].As<Object>();
@ -1090,7 +1089,7 @@ static void FUTimes(const FunctionCallbackInfo<Value>& args) {
void FSInitialize(const FunctionCallbackInfo<Value>& args) {
Local<Function> stats_constructor = args[0].As<Function>();
assert(stats_constructor->IsFunction());
CHECK(stats_constructor->IsFunction());
Environment* env = Environment::GetCurrent(args.GetIsolate());
env->set_fs_stats_constructor_function(stats_constructor);

26
src/node_http_parser.cc

@ -213,8 +213,8 @@ class Parser : public BaseObject {
fields_[num_fields_ - 1].Reset();
}
assert(num_fields_ < static_cast<int>(ARRAY_SIZE(fields_)));
assert(num_fields_ == num_values_ + 1);
CHECK_LT(num_fields_, static_cast<int>(ARRAY_SIZE(fields_)));
CHECK_EQ(num_fields_, num_values_ + 1);
fields_[num_fields_ - 1].Update(at, length);
@ -229,8 +229,8 @@ class Parser : public BaseObject {
values_[num_values_ - 1].Reset();
}
assert(num_values_ < static_cast<int>(ARRAY_SIZE(values_)));
assert(num_values_ == num_fields_);
CHECK_LT(num_values_, static_cast<int>(ARRAY_SIZE(values_)));
CHECK_EQ(num_values_, num_fields_);
values_[num_values_ - 1].Update(at, length);
@ -353,7 +353,7 @@ class Parser : public BaseObject {
Environment* env = Environment::GetCurrent(args.GetIsolate());
http_parser_type type =
static_cast<http_parser_type>(args[0]->Int32Value());
assert(type == HTTP_REQUEST || type == HTTP_RESPONSE);
CHECK(type == HTTP_REQUEST || type == HTTP_RESPONSE);
new Parser(env, args.This(), type);
}
@ -383,10 +383,10 @@ class Parser : public BaseObject {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Parser* parser = Unwrap<Parser>(args.Holder());
assert(parser->current_buffer_.IsEmpty());
assert(parser->current_buffer_len_ == 0);
assert(parser->current_buffer_data_ == NULL);
assert(Buffer::HasInstance(args[0]) == true);
CHECK(parser->current_buffer_.IsEmpty());
CHECK_EQ(parser->current_buffer_len_, 0);
CHECK_EQ(parser->current_buffer_data_, NULL);
CHECK_EQ(Buffer::HasInstance(args[0]), true);
Local<Object> buffer_obj = args[0].As<Object>();
char* buffer_data = Buffer::Data(buffer_obj);
@ -438,7 +438,7 @@ class Parser : public BaseObject {
Parser* parser = Unwrap<Parser>(args.Holder());
assert(parser->current_buffer_.IsEmpty());
CHECK(parser->current_buffer_.IsEmpty());
parser->got_exception_ = false;
int rv = http_parser_execute(&(parser->parser_), &settings, NULL, 0);
@ -466,10 +466,10 @@ class Parser : public BaseObject {
http_parser_type type =
static_cast<http_parser_type>(args[0]->Int32Value());
assert(type == HTTP_REQUEST || type == HTTP_RESPONSE);
CHECK(type == HTTP_REQUEST || type == HTTP_RESPONSE);
Parser* parser = Unwrap<Parser>(args.Holder());
// Should always be called from the same context.
assert(env == parser->env());
CHECK_EQ(env, parser->env());
parser->Init(type);
}
@ -479,7 +479,7 @@ class Parser : public BaseObject {
Environment* env = Environment::GetCurrent(args.GetIsolate());
Parser* parser = Unwrap<Parser>(args.Holder());
// Should always be called from the same context.
assert(env == parser->env());
CHECK_EQ(env, parser->env());
http_parser_pause(&parser->parser_, should_pause);
}

1
src/node_internals.h

@ -28,7 +28,6 @@
#include "uv.h"
#include "v8.h"
#include <assert.h>
#include <stdint.h>
#include <stdlib.h>

7
src/node_stat_watcher.cc

@ -27,7 +27,6 @@
#include "util.h"
#include "util-inl.h"
#include <assert.h>
#include <string.h>
#include <stdlib.h>
@ -85,7 +84,7 @@ void StatWatcher::Callback(uv_fs_poll_t* handle,
const uv_stat_t* prev,
const uv_stat_t* curr) {
StatWatcher* wrap = static_cast<StatWatcher*>(handle->data);
assert(wrap->watcher_ == handle);
CHECK_EQ(wrap->watcher_, handle);
Environment* env = wrap->env();
HandleScope handle_scope(env->isolate());
Context::Scope context_scope(env->context());
@ -99,14 +98,14 @@ void StatWatcher::Callback(uv_fs_poll_t* handle,
void StatWatcher::New(const FunctionCallbackInfo<Value>& args) {
assert(args.IsConstructCall());
CHECK(args.IsConstructCall());
Environment* env = Environment::GetCurrent(args.GetIsolate());
new StatWatcher(env, args.This());
}
void StatWatcher::Start(const FunctionCallbackInfo<Value>& args) {
assert(args.Length() == 3);
CHECK_EQ(args.Length(), 3);
StatWatcher* wrap = Unwrap<StatWatcher>(args.Holder());
node::Utf8Value path(args[0]);

1
src/node_watchdog.cc

@ -23,7 +23,6 @@
#include "env.h"
#include "env-inl.h"
#include "util.h"
#include <assert.h>
namespace node {

2
src/node_win32_etw_provider-inl.h

@ -113,7 +113,7 @@ extern int events_enabled;
sizeof(dataDescriptors) / \
sizeof(*dataDescriptors), \
dataDescriptors); \
assert(status == ERROR_SUCCESS);
CHECK_EQ(status, ERROR_SUCCESS);
void NODE_HTTP_SERVER_REQUEST(node_dtrace_http_server_request_t* req,

2
src/node_win32_etw_provider.cc

@ -183,7 +183,7 @@ void init_etw() {
etw_events_enable_callback,
NULL,
&node_provider);
assert(status == ERROR_SUCCESS);
CHECK_EQ(status, ERROR_SUCCESS);
}
}
}

50
src/node_zlib.cc

@ -94,7 +94,7 @@ class ZCtx : public AsyncWrap {
~ZCtx() {
assert(!write_in_progress_ && "write in progress");
CHECK_EQ(false, write_in_progress_ && "write in progress");
Close();
}
@ -105,8 +105,8 @@ class ZCtx : public AsyncWrap {
}
pending_close_ = false;
assert(init_done_ && "close before init");
assert(mode_ <= UNZIP);
CHECK(init_done_ && "close before init");
CHECK_LE(mode_, UNZIP);
if (mode_ == DEFLATE || mode_ == GZIP || mode_ == DEFLATERAW) {
(void)deflateEnd(&strm_);
@ -136,18 +136,18 @@ class ZCtx : public AsyncWrap {
// write(flush, in, in_off, in_len, out, out_off, out_len)
template <bool async>
static void Write(const FunctionCallbackInfo<Value>& args) {
assert(args.Length() == 7);
CHECK_EQ(args.Length(), 7);
ZCtx* ctx = Unwrap<ZCtx>(args.Holder());
assert(ctx->init_done_ && "write before init");
assert(ctx->mode_ != NONE && "already finalized");
CHECK(ctx->init_done_ && "write before init");
CHECK(ctx->mode_ != NONE && "already finalized");
assert(!ctx->write_in_progress_ && "write already in progress");
assert(!ctx->pending_close_ && "close is pending");
CHECK_EQ(false, ctx->write_in_progress_ && "write already in progress");
CHECK_EQ(false, ctx->pending_close_ && "close is pending");
ctx->write_in_progress_ = true;
ctx->Ref();
assert(!args[0]->IsUndefined() && "must provide flush value");
CHECK_EQ(false, args[0]->IsUndefined() && "must provide flush value");
unsigned int flush = args[0]->Uint32Value();
@ -157,7 +157,7 @@ class ZCtx : public AsyncWrap {
flush != Z_FULL_FLUSH &&
flush != Z_FINISH &&
flush != Z_BLOCK) {
assert(0 && "Invalid flush value");
CHECK(0 && "Invalid flush value");
}
Bytef *in;
@ -171,21 +171,21 @@ class ZCtx : public AsyncWrap {
in_len = 0;
in_off = 0;
} else {
assert(Buffer::HasInstance(args[1]));
CHECK(Buffer::HasInstance(args[1]));
Local<Object> in_buf;
in_buf = args[1]->ToObject();
in_off = args[2]->Uint32Value();
in_len = args[3]->Uint32Value();
assert(Buffer::IsWithinBounds(in_off, in_len, Buffer::Length(in_buf)));
CHECK(Buffer::IsWithinBounds(in_off, in_len, Buffer::Length(in_buf)));
in = reinterpret_cast<Bytef *>(Buffer::Data(in_buf) + in_off);
}
assert(Buffer::HasInstance(args[4]));
CHECK(Buffer::HasInstance(args[4]));
Local<Object> out_buf = args[4]->ToObject();
out_off = args[5]->Uint32Value();
out_len = args[6]->Uint32Value();
assert(Buffer::IsWithinBounds(out_off, out_len, Buffer::Length(out_buf)));
CHECK(Buffer::IsWithinBounds(out_off, out_len, Buffer::Length(out_buf)));
out = reinterpret_cast<Bytef *>(Buffer::Data(out_buf) + out_off);
// build up the work request
@ -276,7 +276,7 @@ class ZCtx : public AsyncWrap {
}
break;
default:
assert(0 && "wtf?");
CHECK(0 && "wtf?");
}
// pass any errors back to the main thread to deal with.
@ -313,7 +313,7 @@ class ZCtx : public AsyncWrap {
// v8 land!
static void After(uv_work_t* work_req, int status) {
assert(status == 0);
CHECK_EQ(status, 0);
ZCtx* ctx = ContainerOf(&ZCtx::work_req_, work_req);
Environment* env = ctx->env();
@ -344,7 +344,7 @@ class ZCtx : public AsyncWrap {
Environment* env = ctx->env();
// 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());
if (ctx->strm_.msg != NULL) {
message = ctx->strm_.msg;
@ -383,22 +383,22 @@ class ZCtx : public AsyncWrap {
static void Init(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
assert((args.Length() == 4 || args.Length() == 5) &&
CHECK((args.Length() == 4 || args.Length() == 5) &&
"init(windowBits, level, memLevel, strategy, [dictionary])");
ZCtx* ctx = Unwrap<ZCtx>(args.Holder());
int windowBits = args[0]->Uint32Value();
assert((windowBits >= 8 && windowBits <= 15) && "invalid windowBits");
CHECK((windowBits >= 8 && windowBits <= 15) && "invalid windowBits");
int level = args[1]->Int32Value();
assert((level >= -1 && level <= 9) && "invalid compression level");
CHECK((level >= -1 && level <= 9) && "invalid compression level");
int memLevel = args[2]->Uint32Value();
assert((memLevel >= 1 && memLevel <= 9) && "invalid memlevel");
CHECK((memLevel >= 1 && memLevel <= 9) && "invalid memlevel");
int strategy = args[3]->Uint32Value();
assert((strategy == Z_FILTERED ||
CHECK((strategy == Z_FILTERED ||
strategy == Z_HUFFMAN_ONLY ||
strategy == Z_RLE ||
strategy == Z_FIXED ||
@ -423,7 +423,7 @@ class ZCtx : public AsyncWrap {
static void Params(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
assert(args.Length() == 2 && "params(level, strategy)");
CHECK(args.Length() == 2 && "params(level, strategy)");
ZCtx* ctx = Unwrap<ZCtx>(args.Holder());
@ -488,7 +488,7 @@ class ZCtx : public AsyncWrap {
->AdjustAmountOfExternalAllocatedMemory(kInflateContextSize);
break;
default:
assert(0 && "wtf?");
CHECK(0 && "wtf?");
}
if (ctx->err_ != Z_OK) {
@ -571,7 +571,7 @@ class ZCtx : public AsyncWrap {
}
void Unref() {
assert(refs_ > 0);
CHECK_GT(refs_, 0);
if (--refs_ == 0) {
MakeWeak<ZCtx>(this);
}

24
src/pipe_wrap.cc

@ -61,11 +61,11 @@ uv_pipe_t* PipeWrap::UVHandle() {
Local<Object> PipeWrap::Instantiate(Environment* env) {
EscapableHandleScope handle_scope(env->isolate());
assert(!env->pipe_constructor_template().IsEmpty());
CHECK_EQ(false, env->pipe_constructor_template().IsEmpty());
Local<Function> constructor = env->pipe_constructor_template()->GetFunction();
assert(!constructor.IsEmpty());
CHECK_EQ(false, constructor.IsEmpty());
Local<Object> instance = constructor->NewInstance();
assert(!instance.IsEmpty());
CHECK_EQ(false, instance.IsEmpty());
return handle_scope.Escape(instance);
}
@ -126,7 +126,7 @@ void PipeWrap::New(const FunctionCallbackInfo<Value>& args) {
// This constructor should not be exposed to public javascript.
// Therefore we assert that we are not trying to call this as a
// normal function.
assert(args.IsConstructCall());
CHECK(args.IsConstructCall());
Environment* env = Environment::GetCurrent(args.GetIsolate());
new PipeWrap(env, args.This(), args[0]->IsTrue());
}
@ -138,7 +138,7 @@ PipeWrap::PipeWrap(Environment* env, Handle<Object> object, bool ipc)
reinterpret_cast<uv_stream_t*>(&handle_),
AsyncWrap::PROVIDER_PIPEWRAP) {
int r = uv_pipe_init(env->event_loop(), &handle_, ipc);
assert(r == 0); // How do we proxy this error up to javascript?
CHECK_EQ(r, 0); // How do we proxy this error up to javascript?
// Suggestion: uv_pipe_init() returns void.
UpdateWriteQueueSize();
}
@ -174,7 +174,7 @@ void PipeWrap::Listen(const FunctionCallbackInfo<Value>& args) {
// TODO(bnoordhuis) maybe share with TCPWrap?
void PipeWrap::OnConnection(uv_stream_t* handle, int status) {
PipeWrap* pipe_wrap = static_cast<PipeWrap*>(handle->data);
assert(&pipe_wrap->handle_ == reinterpret_cast<uv_pipe_t*>(handle));
CHECK_EQ(&pipe_wrap->handle_, reinterpret_cast<uv_pipe_t*>(handle));
Environment* env = pipe_wrap->env();
HandleScope handle_scope(env->isolate());
@ -182,7 +182,7 @@ void PipeWrap::OnConnection(uv_stream_t* handle, int status) {
// We should not be getting this callback if someone as already called
// uv_close() on the handle.
assert(pipe_wrap->persistent().IsEmpty() == false);
CHECK_EQ(pipe_wrap->persistent().IsEmpty(), false);
Local<Value> argv[] = {
Integer::New(env->isolate(), status),
@ -212,15 +212,15 @@ void PipeWrap::OnConnection(uv_stream_t* handle, int status) {
void PipeWrap::AfterConnect(uv_connect_t* req, int status) {
ConnectWrap* req_wrap = static_cast<ConnectWrap*>(req->data);
PipeWrap* wrap = static_cast<PipeWrap*>(req->handle->data);
assert(req_wrap->env() == wrap->env());
CHECK_EQ(req_wrap->env(), wrap->env());
Environment* env = wrap->env();
HandleScope handle_scope(env->isolate());
Context::Scope context_scope(env->context());
// The wrap and request objects should still be there.
assert(req_wrap->persistent().IsEmpty() == false);
assert(wrap->persistent().IsEmpty() == false);
CHECK_EQ(req_wrap->persistent().IsEmpty(), false);
CHECK_EQ(wrap->persistent().IsEmpty(), false);
bool readable, writable;
@ -265,8 +265,8 @@ void PipeWrap::Connect(const FunctionCallbackInfo<Value>& args) {
PipeWrap* wrap = Unwrap<PipeWrap>(args.Holder());
assert(args[0]->IsObject());
assert(args[1]->IsString());
CHECK(args[0]->IsObject());
CHECK(args[1]->IsString());
Local<Object> req_wrap_obj = args[0].As<Object>();
node::Utf8Value name(args[1]);

10
src/process_wrap.cc

@ -73,7 +73,7 @@ class ProcessWrap : public HandleWrap {
// This constructor should not be exposed to public javascript.
// Therefore we assert that we are not trying to call this as a
// normal function.
assert(args.IsConstructCall());
CHECK(args.IsConstructCall());
Environment* env = Environment::GetCurrent(args.GetIsolate());
new ProcessWrap(env, args.This());
}
@ -116,7 +116,7 @@ class ProcessWrap : public HandleWrap {
Local<String> handle_key = env->handle_string();
Local<Object> handle = stdio->Get(handle_key).As<Object>();
uv_stream_t* stream = HandleToStream(env, handle);
assert(stream != NULL);
CHECK_NE(stream, NULL);
options->stdio[i].flags = UV_INHERIT_STREAM;
options->stdio[i].data.stream = stream;
@ -231,7 +231,7 @@ class ProcessWrap : public HandleWrap {
int err = uv_spawn(env->event_loop(), &wrap->process_, &options);
if (err == 0) {
assert(wrap->process_.data == wrap);
CHECK_EQ(wrap->process_.data, wrap);
wrap->object()->Set(env->pid_string(),
Integer::New(env->isolate(), wrap->process_.pid));
}
@ -262,8 +262,8 @@ class ProcessWrap : public HandleWrap {
int64_t exit_status,
int term_signal) {
ProcessWrap* wrap = static_cast<ProcessWrap*>(handle->data);
assert(wrap != NULL);
assert(&wrap->process_ == handle);
CHECK_NE(wrap, NULL);
CHECK_EQ(&wrap->process_, handle);
Environment* env = wrap->env();
HandleScope handle_scope(env->isolate());

4
src/req_wrap.h

@ -48,8 +48,8 @@ class ReqWrap : public AsyncWrap {
~ReqWrap() {
QUEUE_REMOVE(&req_wrap_queue_);
// Assert that someone has called Dispatched()
assert(req_.data == this);
assert(!persistent().IsEmpty());
CHECK_EQ(req_.data, this);
CHECK_EQ(false, persistent().IsEmpty());
persistent().Reset();
}

4
src/signal_wrap.cc

@ -67,7 +67,7 @@ class SignalWrap : public HandleWrap {
// This constructor should not be exposed to public javascript.
// Therefore we assert that we are not trying to call this as a
// normal function.
assert(args.IsConstructCall());
CHECK(args.IsConstructCall());
Environment* env = Environment::GetCurrent(args.GetIsolate());
new SignalWrap(env, args.This());
}
@ -78,7 +78,7 @@ class SignalWrap : public HandleWrap {
reinterpret_cast<uv_handle_t*>(&handle_),
AsyncWrap::PROVIDER_SIGNALWRAP) {
int r = uv_signal_init(env->event_loop(), &handle_);
assert(r == 0);
CHECK_EQ(r, 0);
}
~SignalWrap() {

35
src/smalloc.cc

@ -29,7 +29,6 @@
#include "v8.h"
#include <string.h>
#include <assert.h>
#define ALLOC_ID (0xA10C)
@ -251,8 +250,8 @@ void SliceOnto(const FunctionCallbackInfo<Value>& args) {
Local<Object> source = args[0].As<Object>();
Local<Object> dest = args[1].As<Object>();
assert(source->HasIndexedPropertiesInExternalArrayData());
assert(!dest->HasIndexedPropertiesInExternalArrayData());
CHECK(source->HasIndexedPropertiesInExternalArrayData());
CHECK_EQ(false, dest->HasIndexedPropertiesInExternalArrayData());
char* source_data = static_cast<char*>(
source->GetIndexedPropertiesExternalArrayData());
@ -261,20 +260,20 @@ void SliceOnto(const FunctionCallbackInfo<Value>& args) {
source->GetIndexedPropertiesExternalArrayDataType();
size_t source_size = ExternalArraySize(source_type);
assert(source_size != 0);
CHECK_NE(source_size, 0);
size_t start = args[2]->Uint32Value();
size_t end = args[3]->Uint32Value();
size_t length = end - start;
if (source_size > 1) {
assert(length * source_size >= length);
CHECK_GE(length * source_size, length);
length *= source_size;
}
assert(source_data != NULL || length == 0);
assert(end <= source_len);
assert(start <= end);
CHECK(source_data != NULL || length == 0);
CHECK_LE(end, source_len);
CHECK_LE(start, end);
dest->SetIndexedPropertiesToExternalArrayData(source_data + start,
source_type,
@ -303,7 +302,7 @@ void Alloc(const FunctionCallbackInfo<Value>& args) {
} else {
array_type = static_cast<ExternalArrayType>(args[2]->Uint32Value());
size_t type_length = ExternalArraySize(array_type);
assert(type_length * length >= length);
CHECK_GE(type_length * length, length);
length *= type_length;
}
@ -318,8 +317,8 @@ void Alloc(Environment* env,
enum ExternalArrayType type) {
size_t type_size = ExternalArraySize(type);
assert(length <= kMaxLength);
assert(type_size > 0);
CHECK_LE(length, kMaxLength);
CHECK_GT(type_size, 0);
if (length == 0)
return Alloc(env, obj, NULL, length, type);
@ -339,7 +338,7 @@ void Alloc(Environment* env,
char* data,
size_t length,
enum ExternalArrayType type) {
assert(!obj->HasIndexedPropertiesInExternalArrayData());
CHECK_EQ(false, obj->HasIndexedPropertiesInExternalArrayData());
env->isolate()->AdjustAmountOfExternalAllocatedMemory(length);
size_t size = length / ExternalArraySize(type);
obj->SetIndexedPropertiesToExternalArrayData(data, type, size);
@ -373,8 +372,8 @@ void AllocDispose(Environment* env, Handle<Object> obj) {
obj->GetIndexedPropertiesExternalArrayDataType();
size_t array_size = ExternalArraySize(array_type);
assert(array_size > 0);
assert(length * array_size >= length);
CHECK_GT(array_size, 0);
CHECK_GE(length * array_size, length);
length *= array_size;
@ -397,12 +396,12 @@ void Alloc(Environment* env,
FreeCallback fn,
void* hint,
enum ExternalArrayType type) {
assert(length <= kMaxLength);
CHECK_LE(length, kMaxLength);
size_t type_size = ExternalArraySize(type);
assert(type_size > 0);
assert(length * type_size >= length);
CHECK_GT(type_size, 0);
CHECK_GE(length * type_size, length);
length *= type_size;
@ -418,7 +417,7 @@ void Alloc(Environment* env,
FreeCallback fn,
void* hint,
enum ExternalArrayType type) {
assert(!obj->HasIndexedPropertiesInExternalArrayData());
CHECK_EQ(false, obj->HasIndexedPropertiesInExternalArrayData());
Isolate* isolate = env->isolate();
HandleScope handle_scope(isolate);
env->set_using_smalloc_alloc_cb(true);

64
src/spawn_sync.cc

@ -63,7 +63,7 @@ void SyncProcessOutputBuffer::OnAlloc(size_t suggested_size,
void SyncProcessOutputBuffer::OnRead(const uv_buf_t* buf, size_t nread) {
// If we hand out the same chunk twice, this should catch it.
assert(buf->base == data_ + used());
CHECK_EQ(buf->base, data_ + used());
used_ += static_cast<unsigned int>(nread);
}
@ -111,12 +111,12 @@ SyncProcessStdioPipe::SyncProcessStdioPipe(SyncProcessRunner* process_handler,
shutdown_req_(),
lifecycle_(kUninitialized) {
assert(readable || writable);
CHECK(readable || writable);
}
SyncProcessStdioPipe::~SyncProcessStdioPipe() {
assert(lifecycle_ == kUninitialized || lifecycle_ == kClosed);
CHECK(lifecycle_ == kUninitialized || lifecycle_ == kClosed);
SyncProcessOutputBuffer* buf;
SyncProcessOutputBuffer* next;
@ -129,7 +129,7 @@ SyncProcessStdioPipe::~SyncProcessStdioPipe() {
int SyncProcessStdioPipe::Initialize(uv_loop_t* loop) {
assert(lifecycle_ == kUninitialized);
CHECK_EQ(lifecycle_, kUninitialized);
int r = uv_pipe_init(loop, uv_pipe(), 0);
if (r < 0)
@ -143,7 +143,7 @@ int SyncProcessStdioPipe::Initialize(uv_loop_t* loop) {
int SyncProcessStdioPipe::Start() {
assert(lifecycle_ == kInitialized);
CHECK_EQ(lifecycle_, kInitialized);
// Set the busy flag already. If this function fails no recovery is
// possible.
@ -151,7 +151,7 @@ int SyncProcessStdioPipe::Start() {
if (readable()) {
if (input_buffer_.len > 0) {
assert(input_buffer_.base != NULL);
CHECK_NE(input_buffer_.base, NULL);
int r = uv_write(&write_req_,
uv_stream(),
@ -178,7 +178,7 @@ int SyncProcessStdioPipe::Start() {
void SyncProcessStdioPipe::Close() {
assert(lifecycle_ == kInitialized || lifecycle_ == kStarted);
CHECK(lifecycle_ == kInitialized || lifecycle_ == kStarted);
uv_close(uv_handle(), CloseCallback);
@ -218,7 +218,7 @@ uv_stdio_flags SyncProcessStdioPipe::uv_flags() const {
uv_pipe_t* SyncProcessStdioPipe::uv_pipe() const {
assert(lifecycle_ < kClosing);
CHECK_LT(lifecycle_, kClosing);
return &uv_pipe_;
}
@ -309,7 +309,7 @@ void SyncProcessStdioPipe::OnClose() {
void SyncProcessStdioPipe::SetError(int error) {
assert(error != 0);
CHECK_NE(error, 0);
process_handler_->SetPipeError(error);
}
@ -406,7 +406,7 @@ SyncProcessRunner::SyncProcessRunner(Environment* env)
SyncProcessRunner::~SyncProcessRunner() {
assert(lifecycle_ == kHandlesClosed);
CHECK_EQ(lifecycle_, kHandlesClosed);
if (stdio_pipes_ != NULL) {
for (size_t i = 0; i < stdio_count_; i++) {
@ -432,7 +432,7 @@ Environment* SyncProcessRunner::env() const {
Local<Object> SyncProcessRunner::Run(Local<Value> options) {
EscapableHandleScope scope(env()->isolate());
assert(lifecycle_ == kUninitialized);
CHECK_EQ(lifecycle_, kUninitialized);
TryInitializeAndRunLoop(options);
CloseHandlesAndDeleteLoop();
@ -448,7 +448,7 @@ void SyncProcessRunner::TryInitializeAndRunLoop(Local<Value> options) {
// There is no recovery from failure inside TryInitializeAndRunLoop - the
// only option we'd have is to close all handles and destroy the loop.
assert(lifecycle_ == kUninitialized);
CHECK_EQ(lifecycle_, kUninitialized);
lifecycle_ = kInitialized;
uv_loop_ = new uv_loop_t;
@ -500,12 +500,12 @@ void SyncProcessRunner::TryInitializeAndRunLoop(Local<Value> options) {
abort();
// If we get here the process should have exited.
assert(exit_status_ >= 0);
CHECK_GE(exit_status_, 0);
}
void SyncProcessRunner::CloseHandlesAndDeleteLoop() {
assert(lifecycle_ < kHandlesClosed);
CHECK_LT(lifecycle_, kHandlesClosed);
if (uv_loop_ != NULL) {
CloseStdioPipes();
@ -528,8 +528,8 @@ void SyncProcessRunner::CloseHandlesAndDeleteLoop() {
} else {
// If the loop doesn't exist, neither should any pipes or timers.
assert(!stdio_pipes_initialized_);
assert(!kill_timer_initialized_);
CHECK_EQ(false, stdio_pipes_initialized_);
CHECK_EQ(false, kill_timer_initialized_);
}
lifecycle_ = kHandlesClosed;
@ -537,11 +537,11 @@ void SyncProcessRunner::CloseHandlesAndDeleteLoop() {
void SyncProcessRunner::CloseStdioPipes() {
assert(lifecycle_ < kHandlesClosed);
CHECK_LT(lifecycle_, kHandlesClosed);
if (stdio_pipes_initialized_) {
assert(stdio_pipes_ != NULL);
assert(uv_loop_ != NULL);
CHECK_NE(stdio_pipes_, NULL);
CHECK_NE(uv_loop_, NULL);
for (uint32_t i = 0; i < stdio_count_; i++) {
if (stdio_pipes_[i] != NULL)
@ -554,11 +554,11 @@ void SyncProcessRunner::CloseStdioPipes() {
void SyncProcessRunner::CloseKillTimer() {
assert(lifecycle_ < kHandlesClosed);
CHECK_LT(lifecycle_, kHandlesClosed);
if (kill_timer_initialized_) {
assert(timeout_ > 0);
assert(uv_loop_ != NULL);
CHECK_GT(timeout_, 0);
CHECK_NE(uv_loop_, NULL);
uv_handle_t* uv_timer_handle = reinterpret_cast<uv_handle_t*>(&uv_timer_);
uv_ref(uv_timer_handle);
@ -590,7 +590,7 @@ void SyncProcessRunner::Kill() {
SetError(r);
r = uv_process_kill(&uv_process_, SIGKILL);
assert(r >= 0 || r == UV_ESRCH);
CHECK(r >= 0 || r == UV_ESRCH);
}
}
@ -683,8 +683,8 @@ Local<Object> SyncProcessRunner::BuildResultObject() {
Local<Array> SyncProcessRunner::BuildOutputArray() {
assert(lifecycle_ >= kInitialized);
assert(stdio_pipes_ != NULL);
CHECK_GE(lifecycle_, kInitialized);
CHECK_NE(stdio_pipes_, NULL);
EscapableHandleScope scope(env()->isolate());
Local<Array> js_output = Array::New(env()->isolate(), stdio_count_);
@ -868,15 +868,15 @@ int SyncProcessRunner::ParseStdioOption(int child_fd,
return AddStdioInheritFD(child_fd, inherit_fd);
} else {
assert(0 && "invalid child stdio type");
CHECK(0 && "invalid child stdio type");
return UV_EINVAL;
}
}
int SyncProcessRunner::AddStdioIgnore(uint32_t child_fd) {
assert(child_fd < stdio_count_);
assert(stdio_pipes_[child_fd] == NULL);
CHECK_LT(child_fd, stdio_count_);
CHECK_EQ(stdio_pipes_[child_fd], NULL);
uv_stdio_containers_[child_fd].flags = UV_IGNORE;
@ -888,8 +888,8 @@ int SyncProcessRunner::AddStdioPipe(uint32_t child_fd,
bool readable,
bool writable,
uv_buf_t input_buffer) {
assert(child_fd < stdio_count_);
assert(stdio_pipes_[child_fd] == NULL);
CHECK_LT(child_fd, stdio_count_);
CHECK_EQ(stdio_pipes_[child_fd], NULL);
SyncProcessStdioPipe* h = new SyncProcessStdioPipe(this,
readable,
@ -912,8 +912,8 @@ int SyncProcessRunner::AddStdioPipe(uint32_t child_fd,
int SyncProcessRunner::AddStdioInheritFD(uint32_t child_fd, int inherit_fd) {
assert(child_fd < stdio_count_);
assert(stdio_pipes_[child_fd] == NULL);
CHECK_LT(child_fd, stdio_count_);
CHECK_EQ(stdio_pipes_[child_fd], NULL);
uv_stdio_containers_[child_fd].flags = UV_INHERIT_FD;
uv_stdio_containers_[child_fd].data.fd = inherit_fd;

44
src/stream_wrap.cc

@ -107,7 +107,7 @@ void StreamWrap::OnAlloc(uv_handle_t* handle,
size_t suggested_size,
uv_buf_t* buf) {
StreamWrap* wrap = static_cast<StreamWrap*>(handle->data);
assert(wrap->stream() == reinterpret_cast<uv_stream_t*>(handle));
CHECK_EQ(wrap->stream(), reinterpret_cast<uv_stream_t*>(handle));
wrap->callbacks()->DoAlloc(handle, suggested_size, buf);
}
@ -140,7 +140,7 @@ void StreamWrap::OnReadCommon(uv_stream_t* handle,
// We should not be getting this callback if someone as already called
// uv_close() on the handle.
assert(wrap->persistent().IsEmpty() == false);
CHECK_EQ(wrap->persistent().IsEmpty(), false);
if (nread > 0) {
if (wrap->is_tcp()) {
@ -170,7 +170,7 @@ void StreamWrap::OnRead(uv_stream_t* handle,
size_t StreamWrap::WriteBuffer(Handle<Value> val, uv_buf_t* buf) {
assert(Buffer::HasInstance(val));
CHECK(Buffer::HasInstance(val));
// Simple non-writev case
buf->base = Buffer::Data(val);
@ -185,8 +185,8 @@ void StreamWrap::WriteBuffer(const FunctionCallbackInfo<Value>& args) {
StreamWrap* wrap = Unwrap<StreamWrap>(args.Holder());
assert(args[0]->IsObject());
assert(Buffer::HasInstance(args[1]));
CHECK(args[0]->IsObject());
CHECK(Buffer::HasInstance(args[1]));
Local<Object> req_wrap_obj = args[0].As<Object>();
Local<Object> buf_obj = args[1].As<Object>();
@ -206,7 +206,7 @@ void StreamWrap::WriteBuffer(const FunctionCallbackInfo<Value>& args) {
goto done;
if (count == 0)
goto done;
assert(count == 1);
CHECK_EQ(count, 1);
// Allocate, or write rest
storage = new char[sizeof(WriteWrap)];
@ -242,8 +242,8 @@ void StreamWrap::WriteStringImpl(const FunctionCallbackInfo<Value>& args) {
StreamWrap* wrap = Unwrap<StreamWrap>(args.Holder());
assert(args[0]->IsObject());
assert(args[1]->IsString());
CHECK(args[0]->IsObject());
CHECK(args[1]->IsString());
Local<Object> req_wrap_obj = args[0].As<Object>();
Local<String> string = args[1].As<String>();
@ -293,7 +293,7 @@ void StreamWrap::WriteStringImpl(const FunctionCallbackInfo<Value>& args) {
goto done;
// Partial write
assert(count == 1);
CHECK_EQ(count, 1);
}
storage = new char[sizeof(WriteWrap) + storage_size + 15];
@ -315,7 +315,7 @@ void StreamWrap::WriteStringImpl(const FunctionCallbackInfo<Value>& args) {
encoding);
}
assert(data_size <= storage_size);
CHECK_LE(data_size, storage_size);
buf = uv_buf_init(data, data_size);
@ -334,7 +334,7 @@ void StreamWrap::WriteStringImpl(const FunctionCallbackInfo<Value>& args) {
send_handle = wrap->GetHandle();
// Reference StreamWrap instance to prevent it from being garbage
// collected before `AfterWrite` is called.
assert(!req_wrap->persistent().IsEmpty());
CHECK_EQ(false, req_wrap->persistent().IsEmpty());
req_wrap->object()->Set(env->handle_string(), send_handle_obj);
}
@ -369,8 +369,8 @@ void StreamWrap::Writev(const FunctionCallbackInfo<Value>& args) {
StreamWrap* wrap = Unwrap<StreamWrap>(args.Holder());
assert(args[0]->IsObject());
assert(args[1]->IsArray());
CHECK(args[0]->IsObject());
CHECK(args[1]->IsArray());
Local<Object> req_wrap_obj = args[0].As<Object>();
Local<Array> chunks = args[1].As<Array>();
@ -429,7 +429,7 @@ void StreamWrap::Writev(const FunctionCallbackInfo<Value>& args) {
// Write string
offset = ROUND_UP(offset, 16);
assert(offset < storage_size);
CHECK_LT(offset, storage_size);
char* str_storage = storage + offset;
size_t str_size = storage_size - offset;
@ -494,7 +494,7 @@ void StreamWrap::WriteBinaryString(const FunctionCallbackInfo<Value>& args) {
void StreamWrap::SetBlocking(const FunctionCallbackInfo<Value>& args) {
StreamWrap* wrap = Unwrap<StreamWrap>(args.Holder());
assert(args.Length() > 0);
CHECK_GT(args.Length(), 0);
int err = uv_stream_set_blocking(wrap->stream(), args[0]->IsTrue());
args.GetReturnValue().Set(err);
}
@ -508,8 +508,8 @@ void StreamWrap::AfterWrite(uv_write_t* req, int status) {
Context::Scope context_scope(env->context());
// The wrap and request objects should still be there.
assert(req_wrap->persistent().IsEmpty() == false);
assert(wrap->persistent().IsEmpty() == false);
CHECK_EQ(req_wrap->persistent().IsEmpty(), false);
CHECK_EQ(wrap->persistent().IsEmpty(), false);
// Unref handle property
Local<Object> req_wrap_obj = req_wrap->object();
@ -539,7 +539,7 @@ void StreamWrap::Shutdown(const FunctionCallbackInfo<Value>& args) {
StreamWrap* wrap = Unwrap<StreamWrap>(args.Holder());
assert(args[0]->IsObject());
CHECK(args[0]->IsObject());
Local<Object> req_wrap_obj = args[0].As<Object>();
ShutdownWrap* req_wrap = new ShutdownWrap(env,
@ -559,8 +559,8 @@ void StreamWrap::AfterShutdown(uv_shutdown_t* req, int status) {
Environment* env = wrap->env();
// The wrap and request objects should still be there.
assert(req_wrap->persistent().IsEmpty() == false);
assert(wrap->persistent().IsEmpty() == false);
CHECK_EQ(req_wrap->persistent().IsEmpty(), false);
CHECK_EQ(wrap->persistent().IsEmpty(), false);
HandleScope handle_scope(env->isolate());
Context::Scope context_scope(env->context());
@ -699,7 +699,7 @@ void StreamWrapCallbacks::DoRead(uv_stream_t* handle,
}
char* base = static_cast<char*>(realloc(buf->base, nread));
assert(static_cast<size_t>(nread) <= buf->len);
CHECK_LE(static_cast<size_t>(nread), buf->len);
argv[1] = Buffer::Use(env, base, nread);
Local<Object> pending_obj;
@ -710,7 +710,7 @@ void StreamWrapCallbacks::DoRead(uv_stream_t* handle,
} else if (pending == UV_UDP) {
pending_obj = AcceptHandle<UDPWrap, uv_udp_t>(env, handle);
} else {
assert(pending == UV_UNKNOWN_HANDLE);
CHECK_EQ(pending, UV_UNKNOWN_HANDLE);
}
if (!pending_obj.IsEmpty()) {

6
src/stream_wrap.h

@ -48,7 +48,7 @@ class WriteWrap: public ReqWrap<uv_write_t> {
// This is just to keep the compiler happy. It should never be called, since
// we don't use exceptions in node.
void operator delete(void* ptr, char* storage) { assert(0); }
void operator delete(void* ptr, char* storage) { UNREACHABLE(); }
inline StreamWrap* wrap() const {
return wrap_;
@ -57,8 +57,8 @@ class WriteWrap: public ReqWrap<uv_write_t> {
private:
// People should not be using the non-placement new and delete operator on a
// WriteWrap. Ensure this never happens.
void* operator new(size_t size) { assert(0); }
void operator delete(void* ptr) { assert(0); }
void* operator new(size_t size) { UNREACHABLE(); }
void operator delete(void* ptr) { UNREACHABLE(); }
StreamWrap* const wrap_;
};

23
src/string_bytes.cc

@ -25,7 +25,6 @@
#include "node_buffer.h"
#include "v8.h"
#include <assert.h>
#include <limits.h>
#include <string.h> // memcpy
@ -378,7 +377,7 @@ size_t StringBytes::Write(Isolate* isolate,
break;
default:
assert(0 && "unknown encoding");
CHECK(0 && "unknown encoding");
break;
}
@ -435,12 +434,12 @@ size_t StringBytes::StorageSize(Isolate* isolate,
break;
case HEX:
assert(str->Length() % 2 == 0 && "invalid hex string length");
CHECK(str->Length() % 2 == 0 && "invalid hex string length");
data_size = str->Length() / 2;
break;
default:
assert(0 && "unknown encoding");
CHECK(0 && "unknown encoding");
break;
}
@ -490,7 +489,7 @@ size_t StringBytes::Size(Isolate* isolate,
break;
default:
assert(0 && "unknown encoding");
CHECK(0 && "unknown encoding");
break;
}
@ -610,8 +609,8 @@ static size_t base64_encode(const char* src,
char* dst,
size_t dlen) {
// We know how much we'll write, just make sure that there's space.
assert(dlen >= base64_encoded_size(slen) &&
"not enough space provided for base64 encode");
CHECK(dlen >= base64_encoded_size(slen) &&
"not enough space provided for base64 encode");
dlen = base64_encoded_size(slen);
@ -671,7 +670,7 @@ static size_t base64_encode(const char* src,
static size_t hex_encode(const char* src, size_t slen, char* dst, size_t dlen) {
// We know how much we'll write, just make sure that there's space.
assert(dlen >= slen * 2 &&
CHECK(dlen >= slen * 2 &&
"not enough space provided for hex encode");
dlen = slen * 2;
@ -693,7 +692,7 @@ Local<Value> StringBytes::Encode(Isolate* isolate,
enum encoding encoding) {
EscapableHandleScope scope(isolate);
assert(buflen <= Buffer::kMaxLength);
CHECK_LE(buflen, Buffer::kMaxLength);
if (!buflen && encoding != BUFFER)
return scope.Escape(String::Empty(isolate));
@ -739,7 +738,7 @@ Local<Value> StringBytes::Encode(Isolate* isolate,
char* dst = new char[dlen];
size_t written = base64_encode(buf, buflen, dst, dlen);
assert(written == dlen);
CHECK_EQ(written, dlen);
if (dlen < EXTERN_APEX) {
val = OneByteString(isolate, dst, dlen);
@ -780,7 +779,7 @@ Local<Value> StringBytes::Encode(Isolate* isolate,
size_t dlen = buflen * 2;
char* dst = new char[dlen];
size_t written = hex_encode(buf, buflen, dst, dlen);
assert(written == dlen);
CHECK_EQ(written, dlen);
if (dlen < EXTERN_APEX) {
val = OneByteString(isolate, dst, dlen);
@ -792,7 +791,7 @@ Local<Value> StringBytes::Encode(Isolate* isolate,
}
default:
assert(0 && "unknown encoding");
CHECK(0 && "unknown encoding");
break;
}

40
src/tcp_wrap.cc

@ -57,11 +57,11 @@ typedef class ReqWrap<uv_connect_t> ConnectWrap;
Local<Object> TCPWrap::Instantiate(Environment* env) {
EscapableHandleScope handle_scope(env->isolate());
assert(env->tcp_constructor_template().IsEmpty() == false);
CHECK_EQ(env->tcp_constructor_template().IsEmpty(), false);
Local<Function> constructor = env->tcp_constructor_template()->GetFunction();
assert(constructor.IsEmpty() == false);
CHECK_EQ(constructor.IsEmpty(), false);
Local<Object> instance = constructor->NewInstance();
assert(instance.IsEmpty() == false);
CHECK_EQ(instance.IsEmpty(), false);
return handle_scope.Escape(instance);
}
@ -147,10 +147,10 @@ void TCPWrap::New(const FunctionCallbackInfo<Value>& args) {
// This constructor should not be exposed to public javascript.
// Therefore we assert that we are not trying to call this as a
// normal function.
assert(args.IsConstructCall());
CHECK(args.IsConstructCall());
Environment* env = Environment::GetCurrent(args.GetIsolate());
TCPWrap* wrap = new TCPWrap(env, args.This());
assert(wrap);
CHECK(wrap);
}
@ -160,14 +160,14 @@ TCPWrap::TCPWrap(Environment* env, Handle<Object> object)
reinterpret_cast<uv_stream_t*>(&handle_),
AsyncWrap::PROVIDER_TCPWRAP) {
int r = uv_tcp_init(env->event_loop(), &handle_);
assert(r == 0); // How do we proxy this error up to javascript?
CHECK_EQ(r, 0); // How do we proxy this error up to javascript?
// Suggestion: uv_tcp_init() returns void.
UpdateWriteQueueSize();
}
TCPWrap::~TCPWrap() {
assert(persistent().IsEmpty());
CHECK(persistent().IsEmpty());
}
@ -177,7 +177,7 @@ void TCPWrap::GetSockName(const FunctionCallbackInfo<Value>& args) {
TCPWrap* wrap = Unwrap<TCPWrap>(args.Holder());
assert(args[0]->IsObject());
CHECK(args[0]->IsObject());
Local<Object> out = args[0].As<Object>();
int addrlen = sizeof(address);
@ -199,7 +199,7 @@ void TCPWrap::GetPeerName(const FunctionCallbackInfo<Value>& args) {
TCPWrap* wrap = Unwrap<TCPWrap>(args.Holder());
assert(args[0]->IsObject());
CHECK(args[0]->IsObject());
Local<Object> out = args[0].As<Object>();
int addrlen = sizeof(address);
@ -291,7 +291,7 @@ void TCPWrap::Listen(const FunctionCallbackInfo<Value>& args) {
void TCPWrap::OnConnection(uv_stream_t* handle, int status) {
TCPWrap* tcp_wrap = static_cast<TCPWrap*>(handle->data);
assert(&tcp_wrap->handle_ == reinterpret_cast<uv_tcp_t*>(handle));
CHECK_EQ(&tcp_wrap->handle_, reinterpret_cast<uv_tcp_t*>(handle));
Environment* env = tcp_wrap->env();
HandleScope handle_scope(env->isolate());
@ -299,7 +299,7 @@ void TCPWrap::OnConnection(uv_stream_t* handle, int status) {
// We should not be getting this callback if someone as already called
// uv_close() on the handle.
assert(tcp_wrap->persistent().IsEmpty() == false);
CHECK_EQ(tcp_wrap->persistent().IsEmpty(), false);
Local<Value> argv[2] = {
Integer::New(env->isolate(), status),
@ -327,15 +327,15 @@ void TCPWrap::OnConnection(uv_stream_t* handle, int status) {
void TCPWrap::AfterConnect(uv_connect_t* req, int status) {
ConnectWrap* req_wrap = static_cast<ConnectWrap*>(req->data);
TCPWrap* wrap = static_cast<TCPWrap*>(req->handle->data);
assert(req_wrap->env() == wrap->env());
CHECK_EQ(req_wrap->env(), wrap->env());
Environment* env = wrap->env();
HandleScope handle_scope(env->isolate());
Context::Scope context_scope(env->context());
// The wrap and request objects should still be there.
assert(req_wrap->persistent().IsEmpty() == false);
assert(wrap->persistent().IsEmpty() == false);
CHECK_EQ(req_wrap->persistent().IsEmpty(), false);
CHECK_EQ(wrap->persistent().IsEmpty(), false);
Local<Object> req_wrap_obj = req_wrap->object();
Local<Value> argv[5] = {
@ -357,9 +357,9 @@ void TCPWrap::Connect(const FunctionCallbackInfo<Value>& args) {
TCPWrap* wrap = Unwrap<TCPWrap>(args.Holder());
assert(args[0]->IsObject());
assert(args[1]->IsString());
assert(args[2]->Uint32Value());
CHECK(args[0]->IsObject());
CHECK(args[1]->IsString());
CHECK(args[2]->Uint32Value());
Local<Object> req_wrap_obj = args[0].As<Object>();
node::Utf8Value ip_address(args[1]);
@ -390,9 +390,9 @@ void TCPWrap::Connect6(const FunctionCallbackInfo<Value>& args) {
TCPWrap* wrap = Unwrap<TCPWrap>(args.Holder());
assert(args[0]->IsObject());
assert(args[1]->IsString());
assert(args[2]->Uint32Value());
CHECK(args[0]->IsObject());
CHECK(args[1]->IsString());
CHECK(args[2]->Uint32Value());
Local<Object> req_wrap_obj = args[0].As<Object>();
node::Utf8Value ip_address(args[1]);

4
src/timer_wrap.cc

@ -78,7 +78,7 @@ class TimerWrap : public HandleWrap {
// This constructor should not be exposed to public javascript.
// Therefore we assert that we are not trying to call this as a
// normal function.
assert(args.IsConstructCall());
CHECK(args.IsConstructCall());
Environment* env = Environment::GetCurrent(args.GetIsolate());
new TimerWrap(env, args.This());
}
@ -89,7 +89,7 @@ class TimerWrap : public HandleWrap {
reinterpret_cast<uv_handle_t*>(&handle_),
AsyncWrap::PROVIDER_TIMERWRAP) {
int r = uv_timer_init(env->event_loop(), &handle_);
assert(r == 0);
CHECK_EQ(r, 0);
}
~TimerWrap() {

24
src/tls_wrap.cc

@ -272,7 +272,7 @@ void TLSCallbacks::Start(const FunctionCallbackInfo<Value>& args) {
wrap->started_ = true;
// Send ClientHello handshake
assert(wrap->is_client());
CHECK(wrap->is_client());
wrap->ClearOut();
wrap->EncOut();
}
@ -336,7 +336,7 @@ void TLSCallbacks::EncOut() {
size_t size[ARRAY_SIZE(data)];
size_t count = ARRAY_SIZE(data);
write_size_ = NodeBIO::FromBIO(enc_out_)->PeekMultiple(data, size, &count);
assert(write_size_ != 0 && count != 0);
CHECK(write_size_ != 0 && count != 0);
write_req_.data = this;
uv_buf_t buf[ARRAY_SIZE(data)];
@ -387,7 +387,7 @@ int TLSCallbacks::PrintErrorsCb(const char* str, size_t len, void* arg) {
memcpy(error_buf_, str, avail);
error_off_ += avail;
assert(error_off_ < sizeof(error_buf_));
CHECK_LT(error_off_, sizeof(error_buf_));
// Zero-terminate
error_buf_[error_off_] = '\0';
@ -418,7 +418,7 @@ Local<Value> TLSCallbacks::GetSSLError(int status, int* err, const char** msg) {
break;
default:
{
assert(*err == SSL_ERROR_SSL || *err == SSL_ERROR_SYSCALL);
CHECK(*err == SSL_ERROR_SSL || *err == SSL_ERROR_SYSCALL);
const char* buf = PrintErrors();
@ -427,7 +427,7 @@ Local<Value> TLSCallbacks::GetSSLError(int status, int* err, const char** msg) {
Local<Value> exception = Exception::Error(message);
if (msg != NULL) {
assert(*msg == NULL);
CHECK_EQ(*msg, NULL);
*msg = buf;
}
@ -450,7 +450,7 @@ void TLSCallbacks::ClearOut() {
HandleScope handle_scope(env()->isolate());
Context::Scope context_scope(env()->context());
assert(ssl_ != NULL);
CHECK_NE(ssl_, NULL);
char out[kClearOutChunkSize];
int read;
@ -502,7 +502,7 @@ bool TLSCallbacks::ClearIn() {
size_t avail = 0;
char* data = clear_in_->Peek(&avail);
written = SSL_write(ssl_, data, avail);
assert(written == -1 || written == static_cast<int>(avail));
CHECK(written == -1 || written == static_cast<int>(avail));
if (written == -1)
break;
clear_in_->Read(NULL, avail);
@ -510,7 +510,7 @@ bool TLSCallbacks::ClearIn() {
// All written
if (clear_in_->Length() == 0) {
assert(written >= 0);
CHECK_GE(written, 0);
return true;
}
@ -549,7 +549,7 @@ int TLSCallbacks::DoWrite(WriteWrap* w,
size_t count,
uv_stream_t* send_handle,
uv_write_cb cb) {
assert(send_handle == NULL);
CHECK_EQ(send_handle, NULL);
bool empty = true;
@ -589,7 +589,7 @@ int TLSCallbacks::DoWrite(WriteWrap* w,
int written = 0;
for (i = 0; i < count; i++) {
written = SSL_write(ssl_, bufs[i].base, bufs[i].len);
assert(written == -1 || written == static_cast<int>(bufs[i].len));
CHECK(written == -1 || written == static_cast<int>(bufs[i].len));
if (written == -1)
break;
}
@ -651,7 +651,7 @@ void TLSCallbacks::DoRead(uv_stream_t* handle,
}
// Only client connections can receive data
assert(ssl_ != NULL);
CHECK_NE(ssl_, NULL);
// Commit read data
NodeBIO* enc_in = NodeBIO::FromBIO(enc_in_);
@ -661,7 +661,7 @@ void TLSCallbacks::DoRead(uv_stream_t* handle,
if (!hello_parser_.IsEnded()) {
size_t avail = 0;
uint8_t* data = reinterpret_cast<uint8_t*>(enc_in->Peek(&avail));
assert(avail == 0 || data != NULL);
CHECK(avail == 0 || data != NULL);
return hello_parser_.Parse(data, avail);
}

10
src/tty_wrap.cc

@ -100,7 +100,7 @@ uv_tty_t* TTYWrap::UVHandle() {
void TTYWrap::GuessHandleType(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
int fd = args[0]->Int32Value();
assert(fd >= 0);
CHECK_GE(fd, 0);
uv_handle_type t = uv_guess_handle(fd);
const char* type = NULL;
@ -122,7 +122,7 @@ void TTYWrap::GuessHandleType(const FunctionCallbackInfo<Value>& args) {
void TTYWrap::IsTTY(const FunctionCallbackInfo<Value>& args) {
int fd = args[0]->Int32Value();
assert(fd >= 0);
CHECK_GE(fd, 0);
bool rc = uv_guess_handle(fd) == UV_TTY;
args.GetReturnValue().Set(rc);
}
@ -132,7 +132,7 @@ void TTYWrap::GetWindowSize(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
TTYWrap* wrap = Unwrap<TTYWrap>(args.Holder());
assert(args[0]->IsArray());
CHECK(args[0]->IsArray());
int width, height;
int err = uv_tty_get_winsize(&wrap->handle_, &width, &height);
@ -160,10 +160,10 @@ void TTYWrap::New(const FunctionCallbackInfo<Value>& args) {
// This constructor should not be exposed to public javascript.
// Therefore we assert that we are not trying to call this as a
// normal function.
assert(args.IsConstructCall());
CHECK(args.IsConstructCall());
int fd = args[0]->Int32Value();
assert(fd >= 0);
CHECK_GE(fd, 0);
TTYWrap* wrap = new TTYWrap(env, args.This(), fd, args[1]->IsTrue());
wrap->UpdateWriteQueueSize();

34
src/udp_wrap.cc

@ -78,7 +78,7 @@ UDPWrap::UDPWrap(Environment* env, Handle<Object> object)
reinterpret_cast<uv_handle_t*>(&handle_),
AsyncWrap::PROVIDER_UDPWRAP) {
int r = uv_udp_init(env->event_loop(), &handle_);
assert(r == 0); // can't fail anyway
CHECK_EQ(r, 0); // can't fail anyway
}
@ -128,7 +128,7 @@ void UDPWrap::Initialize(Handle<Object> target,
void UDPWrap::New(const FunctionCallbackInfo<Value>& args) {
assert(args.IsConstructCall());
CHECK(args.IsConstructCall());
Environment* env = Environment::GetCurrent(args.GetIsolate());
new UDPWrap(env, args.This());
}
@ -149,7 +149,7 @@ void UDPWrap::DoBind(const FunctionCallbackInfo<Value>& args, int family) {
UDPWrap* wrap = Unwrap<UDPWrap>(args.Holder());
// bind(ip, port, flags)
assert(args.Length() == 3);
CHECK_EQ(args.Length(), 3);
node::Utf8Value address(args[0]);
const int port = args[1]->Uint32Value();
@ -165,7 +165,7 @@ void UDPWrap::DoBind(const FunctionCallbackInfo<Value>& args, int family) {
err = uv_ip6_addr(*address, port, reinterpret_cast<sockaddr_in6*>(&addr));
break;
default:
assert(0 && "unexpected address family");
CHECK(0 && "unexpected address family");
abort();
}
@ -192,7 +192,7 @@ void UDPWrap::Bind6(const FunctionCallbackInfo<Value>& args) {
#define X(name, fn) \
void UDPWrap::name(const FunctionCallbackInfo<Value>& args) { \
UDPWrap* wrap = Unwrap<UDPWrap>(args.Holder()); \
assert(args.Length() == 1); \
CHECK_EQ(args.Length(), 1); \
int flag = args[0]->Int32Value(); \
int err = fn(&wrap->handle_, flag); \
args.GetReturnValue().Set(err); \
@ -210,7 +210,7 @@ void UDPWrap::SetMembership(const FunctionCallbackInfo<Value>& args,
uv_membership membership) {
UDPWrap* wrap = Unwrap<UDPWrap>(args.Holder());
assert(args.Length() == 2);
CHECK_EQ(args.Length(), 2);
node::Utf8Value address(args[0]);
node::Utf8Value iface(args[1]);
@ -244,13 +244,13 @@ void UDPWrap::DoSend(const FunctionCallbackInfo<Value>& args, int family) {
UDPWrap* wrap = Unwrap<UDPWrap>(args.Holder());
// send(req, buffer, offset, length, port, address)
assert(args[0]->IsObject());
assert(Buffer::HasInstance(args[1]));
assert(args[2]->IsUint32());
assert(args[3]->IsUint32());
assert(args[4]->IsUint32());
assert(args[5]->IsString());
assert(args[6]->IsBoolean());
CHECK(args[0]->IsObject());
CHECK(Buffer::HasInstance(args[1]));
CHECK(args[2]->IsUint32());
CHECK(args[3]->IsUint32());
CHECK(args[4]->IsUint32());
CHECK(args[5]->IsString());
CHECK(args[6]->IsBoolean());
Local<Object> req_wrap_obj = args[0].As<Object>();
Local<Object> buffer_obj = args[1].As<Object>();
@ -260,7 +260,7 @@ void UDPWrap::DoSend(const FunctionCallbackInfo<Value>& args, int family) {
node::Utf8Value address(args[5]);
const bool have_callback = args[6]->IsTrue();
assert(length <= Buffer::Length(buffer_obj) - offset);
CHECK_LE(length, Buffer::Length(buffer_obj) - offset);
SendWrap* req_wrap = new SendWrap(env, req_wrap_obj, have_callback);
@ -277,7 +277,7 @@ void UDPWrap::DoSend(const FunctionCallbackInfo<Value>& args, int family) {
err = uv_ip6_addr(*address, port, reinterpret_cast<sockaddr_in6*>(&addr));
break;
default:
assert(0 && "unexpected address family");
CHECK(0 && "unexpected address family");
abort();
}
@ -331,7 +331,7 @@ void UDPWrap::GetSockName(const FunctionCallbackInfo<Value>& args) {
struct sockaddr_storage address;
UDPWrap* wrap = Unwrap<UDPWrap>(args.Holder());
assert(args[0]->IsObject());
CHECK(args[0]->IsObject());
Local<Object> obj = args[0].As<Object>();
int addrlen = sizeof(address);
@ -416,7 +416,7 @@ void UDPWrap::OnRecv(uv_udp_t* handle,
Local<Object> UDPWrap::Instantiate(Environment* env) {
// If this assert fires then Initialize hasn't been called yet.
assert(env->udp_constructor_function().IsEmpty() == false);
CHECK_EQ(env->udp_constructor_function().IsEmpty(), false);
return env->udp_constructor_function()->NewInstance();
}

10
src/util-inl.h

@ -24,8 +24,6 @@
#include "util.h"
#include <assert.h>
namespace node {
template <typename Inner, typename Outer>
@ -102,8 +100,8 @@ inline v8::Local<v8::String> OneByteString(v8::Isolate* isolate,
template <typename TypeName>
void Wrap(v8::Local<v8::Object> object, TypeName* pointer) {
assert(!object.IsEmpty());
assert(object->InternalFieldCount() > 0);
CHECK_EQ(false, object.IsEmpty());
CHECK_GT(object->InternalFieldCount(), 0);
object->SetAlignedPointerInInternalField(0, pointer);
}
@ -113,8 +111,8 @@ void ClearWrap(v8::Local<v8::Object> object) {
template <typename TypeName>
TypeName* Unwrap(v8::Local<v8::Object> object) {
assert(!object.IsEmpty());
assert(object->InternalFieldCount() > 0);
CHECK_EQ(false, object.IsEmpty());
CHECK_GT(object->InternalFieldCount(), 0);
void* pointer = object->GetAlignedPointerFromInternalField(0);
return static_cast<TypeName*>(pointer);
}

Loading…
Cancel
Save