summaryrefslogtreecommitdiff
path: root/src/stream_wrap.cc
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2014-10-11 16:52:07 +0200
committerFedor Indutny <fedor@indutny.com>2014-10-12 02:09:46 +0400
commit5fdff3854a4253681fb10aa626c8971e50834c10 (patch)
treebaa8b219fff28467b641d4f4f36a5b090f6cc6b2 /src/stream_wrap.cc
parent75a461d0997e0a040c2194c5309c148f179563e9 (diff)
downloadandroid-node-v8-5fdff3854a4253681fb10aa626c8971e50834c10.tar.gz
android-node-v8-5fdff3854a4253681fb10aa626c8971e50834c10.tar.bz2
android-node-v8-5fdff3854a4253681fb10aa626c8971e50834c10.zip
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>
Diffstat (limited to 'src/stream_wrap.cc')
-rw-r--r--src/stream_wrap.cc44
1 files changed, 22 insertions, 22 deletions
diff --git a/src/stream_wrap.cc b/src/stream_wrap.cc
index 3c7fb3388f..a274b0bca3 100644
--- a/src/stream_wrap.cc
+++ b/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()) {