Skip to content

Commit 5de1034

Browse files
ZYSzystargos
authored andcommitted
src: use NULL check macros to check nullptr
PR-URL: #25916 Refs: #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>
1 parent c47eb93 commit 5de1034

16 files changed

+34
-34
lines changed

src/async_wrap.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ PromiseWrap* PromiseWrap::New(Environment* env,
210210
obj->SetInternalField(PromiseWrap::kIsChainedPromiseField,
211211
parent_wrap != nullptr ? v8::True(env->isolate())
212212
: v8::False(env->isolate()));
213-
CHECK_EQ(promise->GetAlignedPointerFromInternalField(0), nullptr);
213+
CHECK_NULL(promise->GetAlignedPointerFromInternalField(0));
214214
promise->SetInternalField(0, obj);
215215
return new PromiseWrap(env, obj, silent);
216216
}

src/env-inl.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ inline worker::Worker* Environment::worker_context() const {
667667
}
668668

669669
inline void Environment::set_worker_context(worker::Worker* context) {
670-
CHECK_EQ(worker_context_, nullptr); // Should be set only once.
670+
CHECK_NULL(worker_context_); // Should be set only once.
671671
worker_context_ = context;
672672
}
673673

src/inspector/main_thread_interface.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ std::shared_ptr<MainThreadHandle> MainThreadInterface::GetHandle() {
307307

308308
void MainThreadInterface::AddObject(int id,
309309
std::unique_ptr<Deletable> object) {
310-
CHECK_NE(nullptr, object);
310+
CHECK_NOT_NULL(object);
311311
managed_objects_[id] = std::move(object);
312312
}
313313

@@ -319,7 +319,7 @@ Deletable* MainThreadInterface::GetObject(int id) {
319319
Deletable* pointer = GetObjectIfExists(id);
320320
// This would mean the object is requested after it was disposed, which is
321321
// a coding error.
322-
CHECK_NE(nullptr, pointer);
322+
CHECK_NOT_NULL(pointer);
323323
return pointer;
324324
}
325325

src/inspector_agent.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ bool Agent::Start(const std::string& path,
682682
bool is_main) {
683683
path_ = path;
684684
debug_options_ = options;
685-
CHECK_NE(host_port, nullptr);
685+
CHECK_NOT_NULL(host_port);
686686
host_port_ = host_port;
687687

688688
client_ = std::make_shared<NodeInspectorClient>(parent_env_, is_main);

src/inspector_socket_server.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ std::string InspectorSocketServer::GetFrontendURL(bool is_compat,
352352
}
353353

354354
bool InspectorSocketServer::Start() {
355-
CHECK_NE(delegate_, nullptr);
355+
CHECK_NOT_NULL(delegate_);
356356
CHECK_EQ(state_, ServerState::kNew);
357357
std::unique_ptr<SocketServerDelegate> delegate_holder;
358358
// We will return it if startup is successful

src/node.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ void MarkBootstrapComplete(const FunctionCallbackInfo<Value>& args) {
340340

341341
MaybeLocal<Value> StartExecution(Environment* env, const char* main_script_id) {
342342
EscapableHandleScope scope(env->isolate());
343-
CHECK_NE(main_script_id, nullptr);
343+
CHECK_NOT_NULL(main_script_id);
344344

345345
std::vector<Local<String>> parameters = {
346346
env->process_string(),

src/node_api.cc

+7-7
Original file line numberDiff line numberDiff line change
@@ -1043,8 +1043,8 @@ napi_create_threadsafe_function(napi_env env,
10431043
napi_status
10441044
napi_get_threadsafe_function_context(napi_threadsafe_function func,
10451045
void** result) {
1046-
CHECK(func != nullptr);
1047-
CHECK(result != nullptr);
1046+
CHECK_NOT_NULL(func);
1047+
CHECK_NOT_NULL(result);
10481048

10491049
*result = reinterpret_cast<v8impl::ThreadSafeFunction*>(func)->Context();
10501050
return napi_ok;
@@ -1054,32 +1054,32 @@ napi_status
10541054
napi_call_threadsafe_function(napi_threadsafe_function func,
10551055
void* data,
10561056
napi_threadsafe_function_call_mode is_blocking) {
1057-
CHECK(func != nullptr);
1057+
CHECK_NOT_NULL(func);
10581058
return reinterpret_cast<v8impl::ThreadSafeFunction*>(func)->Push(data,
10591059
is_blocking);
10601060
}
10611061

10621062
napi_status
10631063
napi_acquire_threadsafe_function(napi_threadsafe_function func) {
1064-
CHECK(func != nullptr);
1064+
CHECK_NOT_NULL(func);
10651065
return reinterpret_cast<v8impl::ThreadSafeFunction*>(func)->Acquire();
10661066
}
10671067

10681068
napi_status
10691069
napi_release_threadsafe_function(napi_threadsafe_function func,
10701070
napi_threadsafe_function_release_mode mode) {
1071-
CHECK(func != nullptr);
1071+
CHECK_NOT_NULL(func);
10721072
return reinterpret_cast<v8impl::ThreadSafeFunction*>(func)->Release(mode);
10731073
}
10741074

10751075
napi_status
10761076
napi_unref_threadsafe_function(napi_env env, napi_threadsafe_function func) {
1077-
CHECK(func != nullptr);
1077+
CHECK_NOT_NULL(func);
10781078
return reinterpret_cast<v8impl::ThreadSafeFunction*>(func)->Unref();
10791079
}
10801080

10811081
napi_status
10821082
napi_ref_threadsafe_function(napi_env env, napi_threadsafe_function func) {
1083-
CHECK(func != nullptr);
1083+
CHECK_NOT_NULL(func);
10841084
return reinterpret_cast<v8impl::ThreadSafeFunction*>(func)->Ref();
10851085
}

src/node_crypto.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -5383,7 +5383,7 @@ void CryptoJob::AfterThreadPoolWork(int status) {
53835383

53845384
void CryptoJob::Run(std::unique_ptr<CryptoJob> job, Local<Value> wrap) {
53855385
CHECK(wrap->IsObject());
5386-
CHECK_EQ(nullptr, job->async_wrap);
5386+
CHECK_NULL(job->async_wrap);
53875387
job->async_wrap.reset(Unwrap<AsyncWrap>(wrap.As<Object>()));
53885388
CHECK_EQ(false, job->async_wrap->persistent().IsWeak());
53895389
job->ScheduleWork();

src/node_http2.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ class Http2Session::MemoryAllocatorInfo {
521521
static void H2Free(void* ptr, void* user_data) {
522522
if (ptr == nullptr) return; // free(null); happens quite often.
523523
void* result = H2Realloc(ptr, 0, user_data);
524-
CHECK_EQ(result, nullptr);
524+
CHECK_NULL(result);
525525
}
526526

527527
static void* H2Realloc(void* ptr, size_t size, void* user_data) {

src/node_http_parser_impl.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ class Parser : public AsyncWrap, public StreamListener {
744744
Local<String> reason;
745745
if (err == HPE_USER) {
746746
const char* colon = strchr(errno_reason, ':');
747-
CHECK_NE(colon, nullptr);
747+
CHECK_NOT_NULL(colon);
748748
code = OneByteString(env()->isolate(), errno_reason,
749749
colon - errno_reason);
750750
reason = OneByteString(env()->isolate(), colon + 1);

src/node_messaging.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ void Message::MemoryInfo(MemoryTracker* tracker) const {
376376
MessagePortData::MessagePortData(MessagePort* owner) : owner_(owner) { }
377377

378378
MessagePortData::~MessagePortData() {
379-
CHECK_EQ(owner_, nullptr);
379+
CHECK_NULL(owner_);
380380
Disentangle();
381381
}
382382

@@ -402,8 +402,8 @@ bool MessagePortData::IsSiblingClosed() const {
402402
}
403403

404404
void MessagePortData::Entangle(MessagePortData* a, MessagePortData* b) {
405-
CHECK_EQ(a->sibling_, nullptr);
406-
CHECK_EQ(b->sibling_, nullptr);
405+
CHECK_NULL(a->sibling_);
406+
CHECK_NULL(b->sibling_);
407407
a->sibling_ = b;
408408
b->sibling_ = a;
409409
a->sibling_mutex_ = b->sibling_mutex_;

src/node_native_module.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ MaybeLocal<Function> NativeModuleLoader::LookupAndCompile(
270270
// Generate new cache for next compilation
271271
std::unique_ptr<ScriptCompiler::CachedData> new_cached_data(
272272
ScriptCompiler::CreateCodeCacheForFunction(fun));
273-
CHECK_NE(new_cached_data, nullptr);
273+
CHECK_NOT_NULL(new_cached_data);
274274

275275
// The old entry should've been erased by now so we can just emplace
276276
code_cache_.emplace(id, std::move(new_cached_data));

src/node_platform.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -241,14 +241,14 @@ void PerIsolatePlatformData::PostIdleTask(std::unique_ptr<v8::IdleTask> task) {
241241
}
242242

243243
void PerIsolatePlatformData::PostTask(std::unique_ptr<Task> task) {
244-
CHECK_NE(flush_tasks_, nullptr);
244+
CHECK_NOT_NULL(flush_tasks_);
245245
foreground_tasks_.Push(std::move(task));
246246
uv_async_send(flush_tasks_);
247247
}
248248

249249
void PerIsolatePlatformData::PostDelayedTask(
250250
std::unique_ptr<Task> task, double delay_in_seconds) {
251-
CHECK_NE(flush_tasks_, nullptr);
251+
CHECK_NOT_NULL(flush_tasks_);
252252
std::unique_ptr<DelayedTask> delayed(new DelayedTask());
253253
delayed->task = std::move(task);
254254
delayed->platform_data = shared_from_this();

src/node_union_bytes.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -64,22 +64,22 @@ class UnionBytes {
6464
bool is_one_byte() const { return is_one_byte_; }
6565
const uint16_t* two_bytes_data() const {
6666
CHECK(!is_one_byte_);
67-
CHECK_NE(two_bytes_, nullptr);
67+
CHECK_NOT_NULL(two_bytes_);
6868
return two_bytes_;
6969
}
7070
const uint8_t* one_bytes_data() const {
7171
CHECK(is_one_byte_);
72-
CHECK_NE(one_bytes_, nullptr);
72+
CHECK_NOT_NULL(one_bytes_);
7373
return one_bytes_;
7474
}
7575
v8::Local<v8::String> ToStringChecked(v8::Isolate* isolate) const {
7676
if (is_one_byte_) {
77-
CHECK_NE(one_bytes_, nullptr);
77+
CHECK_NOT_NULL(one_bytes_);
7878
NonOwningExternalOneByteResource* source =
7979
new NonOwningExternalOneByteResource(one_bytes_, length_);
8080
return v8::String::NewExternalOneByte(isolate, source).ToLocalChecked();
8181
} else {
82-
CHECK_NE(two_bytes_, nullptr);
82+
CHECK_NOT_NULL(two_bytes_);
8383
NonOwningExternalTwoByteResource* source =
8484
new NonOwningExternalTwoByteResource(two_bytes_, length_);
8585
return v8::String::NewExternalTwoByte(isolate, source).ToLocalChecked();

src/node_worker.cc

+6-6
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ Worker::Worker(Environment* env,
9292

9393
CHECK_EQ(uv_loop_init(&loop_), 0);
9494
isolate_ = NewIsolate(array_buffer_allocator_.get(), &loop_);
95-
CHECK_NE(isolate_, nullptr);
95+
CHECK_NOT_NULL(isolate_);
9696

9797
{
9898
// Enter an environment capable of executing code in the child Isolate
@@ -115,7 +115,7 @@ Worker::Worker(Environment* env,
115115

116116
// TODO(addaleax): Use CreateEnvironment(), or generally another public API.
117117
env_.reset(new Environment(isolate_data_.get(), context));
118-
CHECK_NE(env_, nullptr);
118+
CHECK_NOT_NULL(env_);
119119
env_->set_abort_on_uncaught_exception(false);
120120
env_->set_worker_context(this);
121121
thread_id_ = env_->thread_id();
@@ -153,7 +153,7 @@ void Worker::Run() {
153153
"__metadata", "thread_name", "name",
154154
TRACE_STR_COPY(name.c_str()));
155155
MultiIsolatePlatform* platform = isolate_data_->platform();
156-
CHECK_NE(platform, nullptr);
156+
CHECK_NOT_NULL(platform);
157157

158158
Debug(this, "Starting worker with id %llu", thread_id_);
159159
{
@@ -339,7 +339,7 @@ void Worker::OnThreadStopped() {
339339
CHECK(stopped_);
340340
}
341341

342-
CHECK_EQ(child_port_, nullptr);
342+
CHECK_NULL(child_port_);
343343
parent_port_ = nullptr;
344344
}
345345

@@ -369,7 +369,7 @@ Worker::~Worker() {
369369

370370
CHECK(stopped_);
371371
CHECK(thread_joined_);
372-
CHECK_EQ(child_port_, nullptr);
372+
CHECK_NULL(child_port_);
373373

374374
// This has most likely already happened within the worker thread -- this
375375
// is just in case Worker creation failed early.
@@ -509,7 +509,7 @@ void Worker::Exit(int code) {
509509
Debug(this, "Worker %llu called Exit(%d)", thread_id_, code);
510510

511511
if (!stopped_) {
512-
CHECK_NE(env_, nullptr);
512+
CHECK_NOT_NULL(env_);
513513
stopped_ = true;
514514
exit_code_ = code;
515515
if (child_port_ != nullptr)

src/sharedarraybuffer_metadata.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ SharedArrayBufferMetadata::ForSharedArrayBuffer(
7575
CHECK(source->IsExternal());
7676
SABLifetimePartner* partner =
7777
Unwrap<SABLifetimePartner>(lifetime_partner.As<Object>());
78-
CHECK_NE(partner, nullptr);
78+
CHECK_NOT_NULL(partner);
7979
return partner->reference;
8080
}
8181

0 commit comments

Comments
 (0)