summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZYSzys <17367077526@163.com>2019-02-04 15:38:51 +0800
committerDaniel Bevenius <daniel.bevenius@gmail.com>2019-02-07 07:22:38 +0100
commit93e0c6ae8997e0ded6013078efd0ccc652ca2595 (patch)
tree335126a828eb71730196f0df21998a3eaf0f5328 /src
parent2a212549dc0517f1700db90d66ed5cf09e9513b8 (diff)
downloadandroid-node-v8-93e0c6ae8997e0ded6013078efd0ccc652ca2595.tar.gz
android-node-v8-93e0c6ae8997e0ded6013078efd0ccc652ca2595.tar.bz2
android-node-v8-93e0c6ae8997e0ded6013078efd0ccc652ca2595.zip
src: use NULL check macros to check nullptr
PR-URL: https://github.com/nodejs/node/pull/25916 Refs: https://github.com/nodejs/node/pull/20914 Reviewed-By: Masashi Hirano <shisama07@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Diffstat (limited to 'src')
-rw-r--r--src/async_wrap.cc2
-rw-r--r--src/env-inl.h2
-rw-r--r--src/inspector/main_thread_interface.cc4
-rw-r--r--src/inspector_agent.cc2
-rw-r--r--src/inspector_socket_server.cc2
-rw-r--r--src/node.cc2
-rw-r--r--src/node_api.cc14
-rw-r--r--src/node_crypto.cc2
-rw-r--r--src/node_http2.cc2
-rw-r--r--src/node_http_parser_impl.h2
-rw-r--r--src/node_messaging.cc6
-rw-r--r--src/node_native_module.cc2
-rw-r--r--src/node_platform.cc4
-rw-r--r--src/node_union_bytes.h8
-rw-r--r--src/node_worker.cc12
-rw-r--r--src/sharedarraybuffer_metadata.cc2
16 files changed, 34 insertions, 34 deletions
diff --git a/src/async_wrap.cc b/src/async_wrap.cc
index 8f20d4f837..61455b2fcc 100644
--- a/src/async_wrap.cc
+++ b/src/async_wrap.cc
@@ -206,7 +206,7 @@ PromiseWrap* PromiseWrap::New(Environment* env,
obj->SetInternalField(PromiseWrap::kIsChainedPromiseField,
parent_wrap != nullptr ? v8::True(env->isolate())
: v8::False(env->isolate()));
- CHECK_EQ(promise->GetAlignedPointerFromInternalField(0), nullptr);
+ CHECK_NULL(promise->GetAlignedPointerFromInternalField(0));
promise->SetInternalField(0, obj);
return new PromiseWrap(env, obj, silent);
}
diff --git a/src/env-inl.h b/src/env-inl.h
index 748577a254..60dafc04e1 100644
--- a/src/env-inl.h
+++ b/src/env-inl.h
@@ -667,7 +667,7 @@ inline worker::Worker* Environment::worker_context() const {
}
inline void Environment::set_worker_context(worker::Worker* context) {
- CHECK_EQ(worker_context_, nullptr); // Should be set only once.
+ CHECK_NULL(worker_context_); // Should be set only once.
worker_context_ = context;
}
diff --git a/src/inspector/main_thread_interface.cc b/src/inspector/main_thread_interface.cc
index 15ffb49d74..1bcf65134f 100644
--- a/src/inspector/main_thread_interface.cc
+++ b/src/inspector/main_thread_interface.cc
@@ -307,7 +307,7 @@ std::shared_ptr<MainThreadHandle> MainThreadInterface::GetHandle() {
void MainThreadInterface::AddObject(int id,
std::unique_ptr<Deletable> object) {
- CHECK_NE(nullptr, object);
+ CHECK_NOT_NULL(object);
managed_objects_[id] = std::move(object);
}
@@ -319,7 +319,7 @@ Deletable* MainThreadInterface::GetObject(int id) {
Deletable* pointer = GetObjectIfExists(id);
// This would mean the object is requested after it was disposed, which is
// a coding error.
- CHECK_NE(nullptr, pointer);
+ CHECK_NOT_NULL(pointer);
return pointer;
}
diff --git a/src/inspector_agent.cc b/src/inspector_agent.cc
index f6255489fc..272f1a986d 100644
--- a/src/inspector_agent.cc
+++ b/src/inspector_agent.cc
@@ -682,7 +682,7 @@ bool Agent::Start(const std::string& path,
bool is_main) {
path_ = path;
debug_options_ = options;
- CHECK_NE(host_port, nullptr);
+ CHECK_NOT_NULL(host_port);
host_port_ = host_port;
client_ = std::make_shared<NodeInspectorClient>(parent_env_, is_main);
diff --git a/src/inspector_socket_server.cc b/src/inspector_socket_server.cc
index 1621b408b4..5e77ff5b3f 100644
--- a/src/inspector_socket_server.cc
+++ b/src/inspector_socket_server.cc
@@ -352,7 +352,7 @@ std::string InspectorSocketServer::GetFrontendURL(bool is_compat,
}
bool InspectorSocketServer::Start() {
- CHECK_NE(delegate_, nullptr);
+ CHECK_NOT_NULL(delegate_);
CHECK_EQ(state_, ServerState::kNew);
std::unique_ptr<SocketServerDelegate> delegate_holder;
// We will return it if startup is successful
diff --git a/src/node.cc b/src/node.cc
index dfd691facd..7d9075b5e0 100644
--- a/src/node.cc
+++ b/src/node.cc
@@ -336,7 +336,7 @@ void MarkBootstrapComplete(const FunctionCallbackInfo<Value>& args) {
MaybeLocal<Value> StartExecution(Environment* env, const char* main_script_id) {
EscapableHandleScope scope(env->isolate());
- CHECK_NE(main_script_id, nullptr);
+ CHECK_NOT_NULL(main_script_id);
std::vector<Local<String>> parameters = {
env->process_string(),
diff --git a/src/node_api.cc b/src/node_api.cc
index 7d843c08f5..ff2e12f571 100644
--- a/src/node_api.cc
+++ b/src/node_api.cc
@@ -1043,8 +1043,8 @@ napi_create_threadsafe_function(napi_env env,
napi_status
napi_get_threadsafe_function_context(napi_threadsafe_function func,
void** result) {
- CHECK(func != nullptr);
- CHECK(result != nullptr);
+ CHECK_NOT_NULL(func);
+ CHECK_NOT_NULL(result);
*result = reinterpret_cast<v8impl::ThreadSafeFunction*>(func)->Context();
return napi_ok;
@@ -1054,32 +1054,32 @@ napi_status
napi_call_threadsafe_function(napi_threadsafe_function func,
void* data,
napi_threadsafe_function_call_mode is_blocking) {
- CHECK(func != nullptr);
+ CHECK_NOT_NULL(func);
return reinterpret_cast<v8impl::ThreadSafeFunction*>(func)->Push(data,
is_blocking);
}
napi_status
napi_acquire_threadsafe_function(napi_threadsafe_function func) {
- CHECK(func != nullptr);
+ CHECK_NOT_NULL(func);
return reinterpret_cast<v8impl::ThreadSafeFunction*>(func)->Acquire();
}
napi_status
napi_release_threadsafe_function(napi_threadsafe_function func,
napi_threadsafe_function_release_mode mode) {
- CHECK(func != nullptr);
+ CHECK_NOT_NULL(func);
return reinterpret_cast<v8impl::ThreadSafeFunction*>(func)->Release(mode);
}
napi_status
napi_unref_threadsafe_function(napi_env env, napi_threadsafe_function func) {
- CHECK(func != nullptr);
+ CHECK_NOT_NULL(func);
return reinterpret_cast<v8impl::ThreadSafeFunction*>(func)->Unref();
}
napi_status
napi_ref_threadsafe_function(napi_env env, napi_threadsafe_function func) {
- CHECK(func != nullptr);
+ CHECK_NOT_NULL(func);
return reinterpret_cast<v8impl::ThreadSafeFunction*>(func)->Ref();
}
diff --git a/src/node_crypto.cc b/src/node_crypto.cc
index 056ebbc555..78a8addaad 100644
--- a/src/node_crypto.cc
+++ b/src/node_crypto.cc
@@ -5408,7 +5408,7 @@ void CryptoJob::AfterThreadPoolWork(int status) {
void CryptoJob::Run(std::unique_ptr<CryptoJob> job, Local<Value> wrap) {
CHECK(wrap->IsObject());
- CHECK_EQ(nullptr, job->async_wrap);
+ CHECK_NULL(job->async_wrap);
job->async_wrap.reset(Unwrap<AsyncWrap>(wrap.As<Object>()));
CHECK_EQ(false, job->async_wrap->persistent().IsWeak());
job->ScheduleWork();
diff --git a/src/node_http2.cc b/src/node_http2.cc
index 4e19432efb..1dd1f37c70 100644
--- a/src/node_http2.cc
+++ b/src/node_http2.cc
@@ -530,7 +530,7 @@ class Http2Session::MemoryAllocatorInfo {
static void H2Free(void* ptr, void* user_data) {
if (ptr == nullptr) return; // free(null); happens quite often.
void* result = H2Realloc(ptr, 0, user_data);
- CHECK_EQ(result, nullptr);
+ CHECK_NULL(result);
}
static void* H2Realloc(void* ptr, size_t size, void* user_data) {
diff --git a/src/node_http_parser_impl.h b/src/node_http_parser_impl.h
index 7a955cc1e9..7d5ea34720 100644
--- a/src/node_http_parser_impl.h
+++ b/src/node_http_parser_impl.h
@@ -744,7 +744,7 @@ class Parser : public AsyncWrap, public StreamListener {
Local<String> reason;
if (err == HPE_USER) {
const char* colon = strchr(errno_reason, ':');
- CHECK_NE(colon, nullptr);
+ CHECK_NOT_NULL(colon);
code = OneByteString(env()->isolate(), errno_reason,
colon - errno_reason);
reason = OneByteString(env()->isolate(), colon + 1);
diff --git a/src/node_messaging.cc b/src/node_messaging.cc
index 9952043f7b..896f43cd23 100644
--- a/src/node_messaging.cc
+++ b/src/node_messaging.cc
@@ -376,7 +376,7 @@ void Message::MemoryInfo(MemoryTracker* tracker) const {
MessagePortData::MessagePortData(MessagePort* owner) : owner_(owner) { }
MessagePortData::~MessagePortData() {
- CHECK_EQ(owner_, nullptr);
+ CHECK_NULL(owner_);
Disentangle();
}
@@ -402,8 +402,8 @@ bool MessagePortData::IsSiblingClosed() const {
}
void MessagePortData::Entangle(MessagePortData* a, MessagePortData* b) {
- CHECK_EQ(a->sibling_, nullptr);
- CHECK_EQ(b->sibling_, nullptr);
+ CHECK_NULL(a->sibling_);
+ CHECK_NULL(b->sibling_);
a->sibling_ = b;
b->sibling_ = a;
a->sibling_mutex_ = b->sibling_mutex_;
diff --git a/src/node_native_module.cc b/src/node_native_module.cc
index 662aad31d5..2d3769ebf5 100644
--- a/src/node_native_module.cc
+++ b/src/node_native_module.cc
@@ -270,7 +270,7 @@ MaybeLocal<Function> NativeModuleLoader::LookupAndCompile(
// Generate new cache for next compilation
std::unique_ptr<ScriptCompiler::CachedData> new_cached_data(
ScriptCompiler::CreateCodeCacheForFunction(fun));
- CHECK_NE(new_cached_data, nullptr);
+ CHECK_NOT_NULL(new_cached_data);
// The old entry should've been erased by now so we can just emplace
code_cache_.emplace(id, std::move(new_cached_data));
diff --git a/src/node_platform.cc b/src/node_platform.cc
index 797d4d9cbb..b930edb156 100644
--- a/src/node_platform.cc
+++ b/src/node_platform.cc
@@ -241,14 +241,14 @@ void PerIsolatePlatformData::PostIdleTask(std::unique_ptr<v8::IdleTask> task) {
}
void PerIsolatePlatformData::PostTask(std::unique_ptr<Task> task) {
- CHECK_NE(flush_tasks_, nullptr);
+ CHECK_NOT_NULL(flush_tasks_);
foreground_tasks_.Push(std::move(task));
uv_async_send(flush_tasks_);
}
void PerIsolatePlatformData::PostDelayedTask(
std::unique_ptr<Task> task, double delay_in_seconds) {
- CHECK_NE(flush_tasks_, nullptr);
+ CHECK_NOT_NULL(flush_tasks_);
std::unique_ptr<DelayedTask> delayed(new DelayedTask());
delayed->task = std::move(task);
delayed->platform_data = shared_from_this();
diff --git a/src/node_union_bytes.h b/src/node_union_bytes.h
index 66d8509bea..33fada7303 100644
--- a/src/node_union_bytes.h
+++ b/src/node_union_bytes.h
@@ -64,22 +64,22 @@ class UnionBytes {
bool is_one_byte() const { return is_one_byte_; }
const uint16_t* two_bytes_data() const {
CHECK(!is_one_byte_);
- CHECK_NE(two_bytes_, nullptr);
+ CHECK_NOT_NULL(two_bytes_);
return two_bytes_;
}
const uint8_t* one_bytes_data() const {
CHECK(is_one_byte_);
- CHECK_NE(one_bytes_, nullptr);
+ CHECK_NOT_NULL(one_bytes_);
return one_bytes_;
}
v8::Local<v8::String> ToStringChecked(v8::Isolate* isolate) const {
if (is_one_byte_) {
- CHECK_NE(one_bytes_, nullptr);
+ CHECK_NOT_NULL(one_bytes_);
NonOwningExternalOneByteResource* source =
new NonOwningExternalOneByteResource(one_bytes_, length_);
return v8::String::NewExternalOneByte(isolate, source).ToLocalChecked();
} else {
- CHECK_NE(two_bytes_, nullptr);
+ CHECK_NOT_NULL(two_bytes_);
NonOwningExternalTwoByteResource* source =
new NonOwningExternalTwoByteResource(two_bytes_, length_);
return v8::String::NewExternalTwoByte(isolate, source).ToLocalChecked();
diff --git a/src/node_worker.cc b/src/node_worker.cc
index 2d960f6e4d..3fd19de97c 100644
--- a/src/node_worker.cc
+++ b/src/node_worker.cc
@@ -92,7 +92,7 @@ Worker::Worker(Environment* env,
CHECK_EQ(uv_loop_init(&loop_), 0);
isolate_ = NewIsolate(array_buffer_allocator_.get(), &loop_);
- CHECK_NE(isolate_, nullptr);
+ CHECK_NOT_NULL(isolate_);
{
// Enter an environment capable of executing code in the child Isolate
@@ -115,7 +115,7 @@ Worker::Worker(Environment* env,
// TODO(addaleax): Use CreateEnvironment(), or generally another public API.
env_.reset(new Environment(isolate_data_.get(), context));
- CHECK_NE(env_, nullptr);
+ CHECK_NOT_NULL(env_);
env_->set_abort_on_uncaught_exception(false);
env_->set_worker_context(this);
thread_id_ = env_->thread_id();
@@ -153,7 +153,7 @@ void Worker::Run() {
"__metadata", "thread_name", "name",
TRACE_STR_COPY(name.c_str()));
MultiIsolatePlatform* platform = isolate_data_->platform();
- CHECK_NE(platform, nullptr);
+ CHECK_NOT_NULL(platform);
Debug(this, "Starting worker with id %llu", thread_id_);
{
@@ -339,7 +339,7 @@ void Worker::OnThreadStopped() {
CHECK(stopped_);
}
- CHECK_EQ(child_port_, nullptr);
+ CHECK_NULL(child_port_);
parent_port_ = nullptr;
}
@@ -369,7 +369,7 @@ Worker::~Worker() {
CHECK(stopped_);
CHECK(thread_joined_);
- CHECK_EQ(child_port_, nullptr);
+ CHECK_NULL(child_port_);
// This has most likely already happened within the worker thread -- this
// is just in case Worker creation failed early.
@@ -509,7 +509,7 @@ void Worker::Exit(int code) {
Debug(this, "Worker %llu called Exit(%d)", thread_id_, code);
if (!stopped_) {
- CHECK_NE(env_, nullptr);
+ CHECK_NOT_NULL(env_);
stopped_ = true;
exit_code_ = code;
if (child_port_ != nullptr)
diff --git a/src/sharedarraybuffer_metadata.cc b/src/sharedarraybuffer_metadata.cc
index 671ad6d682..4e6f5a349d 100644
--- a/src/sharedarraybuffer_metadata.cc
+++ b/src/sharedarraybuffer_metadata.cc
@@ -75,7 +75,7 @@ SharedArrayBufferMetadata::ForSharedArrayBuffer(
CHECK(source->IsExternal());
SABLifetimePartner* partner =
Unwrap<SABLifetimePartner>(lifetime_partner.As<Object>());
- CHECK_NE(partner, nullptr);
+ CHECK_NOT_NULL(partner);
return partner->reference;
}