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 <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Richard Lau <[email protected]>
1 parent c47eb93 commit 5de1034

16 files changed

+34
-34
lines changed

src/async_wrap.cc

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 7 additions & 7 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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);

0 commit comments

Comments
 (0)