Skip to content

Commit ceda8c5

Browse files
danbevMylesBorins
authored andcommitted
src: use nullptr instead of NULL
PR-URL: #17373 Reviewed-By: Jon Moss <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
1 parent e41344f commit ceda8c5

15 files changed

+48
-46
lines changed

src/cares_wrap.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ int ParseGeneralReply(Environment* env,
798798
status = ares_parse_ns_reply(buf, len, &host);
799799
break;
800800
case ns_t_ptr:
801-
status = ares_parse_ptr_reply(buf, len, NULL, 0, AF_INET, &host);
801+
status = ares_parse_ptr_reply(buf, len, nullptr, 0, AF_INET, &host);
802802
break;
803803
default:
804804
CHECK(0 && "Bad NS type");
@@ -830,7 +830,7 @@ int ParseGeneralReply(Environment* env,
830830
HostentToNames(env, host, ret);
831831
} else if (*type == ns_t_ptr) {
832832
uint32_t offset = ret->Length();
833-
for (uint32_t i = 0; host->h_aliases[i] != NULL; i++) {
833+
for (uint32_t i = 0; host->h_aliases[i] != nullptr; i++) {
834834
ret->Set(context,
835835
i + offset,
836836
OneByteString(env->isolate(), host->h_aliases[i])).FromJust();

src/inspector_socket.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ int inspector_accept(uv_stream_t* server, InspectorSocket* socket,
577577
data_received_cb);
578578
}
579579
if (err != 0) {
580-
uv_close(reinterpret_cast<uv_handle_t*>(tcp), NULL);
580+
uv_close(reinterpret_cast<uv_handle_t*>(tcp), nullptr);
581581
}
582582
return err;
583583
}

src/inspector_socket_server.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ void PrintDebuggerReadyMessage(const std::string& host,
9494
int port,
9595
const std::vector<std::string>& ids,
9696
FILE* out) {
97-
if (out == NULL) {
97+
if (out == nullptr) {
9898
return;
9999
}
100100
for (const std::string& id : ids) {
@@ -398,7 +398,7 @@ bool InspectorSocketServer::Start() {
398398
int err = uv_getaddrinfo(loop_, &req, nullptr, host_.c_str(),
399399
port_string.c_str(), &hints);
400400
if (err < 0) {
401-
if (out_ != NULL) {
401+
if (out_ != nullptr) {
402402
fprintf(out_, "Unable to resolve \"%s\": %s\n", host_.c_str(),
403403
uv_strerror(err));
404404
}
@@ -416,7 +416,7 @@ bool InspectorSocketServer::Start() {
416416
// We only show error if we failed to start server on all addresses. We only
417417
// show one error, for the last address.
418418
if (server_sockets_.empty()) {
419-
if (out_ != NULL) {
419+
if (out_ != nullptr) {
420420
fprintf(out_, "Starting inspector on %s:%d failed: %s\n",
421421
host_.c_str(), port_, uv_strerror(err));
422422
fflush(out_);

src/node.h

+16-16
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,14 @@ namespace node {
108108

109109
NODE_EXTERN v8::Local<v8::Value> ErrnoException(v8::Isolate* isolate,
110110
int errorno,
111-
const char* syscall = NULL,
112-
const char* message = NULL,
113-
const char* path = NULL);
111+
const char* syscall = nullptr,
112+
const char* message = nullptr,
113+
const char* path = nullptr);
114114
NODE_EXTERN v8::Local<v8::Value> UVException(v8::Isolate* isolate,
115115
int errorno,
116-
const char* syscall = NULL,
117-
const char* message = NULL,
118-
const char* path = NULL);
116+
const char* syscall = nullptr,
117+
const char* message = nullptr,
118+
const char* path = nullptr);
119119
NODE_EXTERN v8::Local<v8::Value> UVException(v8::Isolate* isolate,
120120
int errorno,
121121
const char* syscall,
@@ -126,9 +126,9 @@ NODE_EXTERN v8::Local<v8::Value> UVException(v8::Isolate* isolate,
126126
NODE_DEPRECATED("Use ErrnoException(isolate, ...)",
127127
inline v8::Local<v8::Value> ErrnoException(
128128
int errorno,
129-
const char* syscall = NULL,
130-
const char* message = NULL,
131-
const char* path = NULL) {
129+
const char* syscall = nullptr,
130+
const char* message = nullptr,
131+
const char* path = nullptr) {
132132
return ErrnoException(v8::Isolate::GetCurrent(),
133133
errorno,
134134
syscall,
@@ -137,9 +137,9 @@ NODE_DEPRECATED("Use ErrnoException(isolate, ...)",
137137
})
138138

139139
inline v8::Local<v8::Value> UVException(int errorno,
140-
const char* syscall = NULL,
141-
const char* message = NULL,
142-
const char* path = NULL) {
140+
const char* syscall = nullptr,
141+
const char* message = nullptr,
142+
const char* path = nullptr) {
143143
return UVException(v8::Isolate::GetCurrent(),
144144
errorno,
145145
syscall,
@@ -426,14 +426,14 @@ NODE_DEPRECATED("Use DecodeWrite(isolate, ...)",
426426
NODE_EXTERN v8::Local<v8::Value> WinapiErrnoException(
427427
v8::Isolate* isolate,
428428
int errorno,
429-
const char *syscall = NULL,
429+
const char *syscall = nullptr,
430430
const char *msg = "",
431-
const char *path = NULL);
431+
const char *path = nullptr);
432432

433433
NODE_DEPRECATED("Use WinapiErrnoException(isolate, ...)",
434434
inline v8::Local<v8::Value> WinapiErrnoException(int errorno,
435-
const char *syscall = NULL, const char *msg = "",
436-
const char *path = NULL) {
435+
const char *syscall = nullptr, const char *msg = "",
436+
const char *path = nullptr) {
437437
return WinapiErrnoException(v8::Isolate::GetCurrent(),
438438
errorno,
439439
syscall,

src/node_buffer.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1214,7 +1214,7 @@ static void EncodeUtf8String(const FunctionCallbackInfo<Value>& args) {
12141214
char* data = node::UncheckedMalloc(length);
12151215
str->WriteUtf8(data,
12161216
-1, // We are certain that `data` is sufficiently large
1217-
NULL,
1217+
nullptr,
12181218
String::NO_NULL_TERMINATION | String::REPLACE_INVALID_UTF8);
12191219
auto array_buf = ArrayBuffer::New(env->isolate(), data, length,
12201220
ArrayBufferCreationMode::kInternalized);

src/node_crypto.cc

+7-5
Original file line numberDiff line numberDiff line change
@@ -1782,7 +1782,7 @@ static bool SafeX509ExtPrint(BIO* out, X509_EXTENSION* ext) {
17821782
return false;
17831783

17841784
GENERAL_NAMES* names = static_cast<GENERAL_NAMES*>(X509V3_EXT_d2i(ext));
1785-
if (names == NULL)
1785+
if (names == nullptr)
17861786
return false;
17871787

17881788
for (int i = 0; i < sk_GENERAL_NAME_num(names); i++) {
@@ -1798,8 +1798,8 @@ static bool SafeX509ExtPrint(BIO* out, X509_EXTENSION* ext) {
17981798
BIO_write(out, name->data, name->length);
17991799
} else {
18001800
STACK_OF(CONF_VALUE)* nval = i2v_GENERAL_NAME(
1801-
const_cast<X509V3_EXT_METHOD*>(method), gen, NULL);
1802-
if (nval == NULL)
1801+
const_cast<X509V3_EXT_METHOD*>(method), gen, nullptr);
1802+
if (nval == nullptr)
18031803
return false;
18041804
X509V3_EXT_val_prn(out, nval, 0, 0);
18051805
sk_CONF_VALUE_pop_free(nval, X509V3_conf_free);
@@ -6125,7 +6125,7 @@ void InitCryptoOnce() {
61256125
if (0 != err) {
61266126
fprintf(stderr,
61276127
"openssl config failed: %s\n",
6128-
ERR_error_string(err, NULL));
6128+
ERR_error_string(err, nullptr));
61296129
CHECK_NE(err, 0);
61306130
}
61316131
}
@@ -6148,7 +6148,9 @@ void InitCryptoOnce() {
61486148
}
61496149
}
61506150
if (0 != err) {
6151-
fprintf(stderr, "openssl fips failed: %s\n", ERR_error_string(err, NULL));
6151+
fprintf(stderr,
6152+
"openssl fips failed: %s\n",
6153+
ERR_error_string(err, nullptr));
61526154
UNREACHABLE();
61536155
}
61546156
#endif // NODE_FIPS_MODE

src/node_http2.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1768,7 +1768,7 @@ void Http2Session::Goaway(const FunctionCallbackInfo<Value>& args) {
17681768
int32_t lastStreamID = args[1]->Int32Value(context).ToChecked();
17691769
Local<Value> opaqueData = args[2];
17701770

1771-
uint8_t* data = NULL;
1771+
uint8_t* data = nullptr;
17721772
size_t length = 0;
17731773

17741774
if (opaqueData->BooleanValue(context).ToChecked()) {

src/node_i18n.cc

+7-7
Original file line numberDiff line numberDiff line change
@@ -114,21 +114,21 @@ MaybeLocal<Object> ToBufferEndian(Environment* env, MaybeStackBuffer<T>* buf) {
114114
}
115115

116116
struct Converter {
117-
explicit Converter(const char* name, const char* sub = NULL)
117+
explicit Converter(const char* name, const char* sub = nullptr)
118118
: conv(nullptr) {
119119
UErrorCode status = U_ZERO_ERROR;
120120
conv = ucnv_open(name, &status);
121121
CHECK(U_SUCCESS(status));
122-
if (sub != NULL) {
122+
if (sub != nullptr) {
123123
ucnv_setSubstChars(conv, sub, strlen(sub), &status);
124124
}
125125
}
126126

127127
explicit Converter(UConverter* converter,
128-
const char* sub = NULL) : conv(converter) {
128+
const char* sub = nullptr) : conv(converter) {
129129
CHECK_NE(conv, nullptr);
130130
UErrorCode status = U_ZERO_ERROR;
131-
if (sub != NULL) {
131+
if (sub != nullptr) {
132132
ucnv_setSubstChars(conv, sub, strlen(sub), &status);
133133
}
134134
}
@@ -229,7 +229,7 @@ class ConverterObject : public BaseObject, Converter {
229229
ucnv_toUnicode(converter->conv,
230230
&target, target + (limit * sizeof(UChar)),
231231
&source, source + source_length,
232-
NULL, flush, &status);
232+
nullptr, flush, &status);
233233

234234
if (U_SUCCESS(status)) {
235235
if (limit > 0)
@@ -254,7 +254,7 @@ class ConverterObject : public BaseObject, Converter {
254254
v8::Local<v8::Object> wrap,
255255
UConverter* converter,
256256
bool ignoreBOM,
257-
const char* sub = NULL) :
257+
const char* sub = nullptr) :
258258
BaseObject(env, wrap),
259259
Converter(converter, sub),
260260
ignoreBOM_(ignoreBOM) {
@@ -427,7 +427,7 @@ const char* EncodingName(const enum encoding encoding) {
427427
case LATIN1: return "iso8859-1";
428428
case UCS2: return "utf16le";
429429
case UTF8: return "utf-8";
430-
default: return NULL;
430+
default: return nullptr;
431431
}
432432
}
433433

src/node_os.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ static void GetUserInfo(const FunctionCallbackInfo<Value>& args) {
368368
&error);
369369
MaybeLocal<Value> shell;
370370

371-
if (pwd.shell == NULL)
371+
if (pwd.shell == nullptr)
372372
shell = Null(env->isolate());
373373
else
374374
shell = StringBytes::Encode(env->isolate(), pwd.shell, encoding, &error);

src/node_url.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ static inline int64_t ParseNumber(const char* start, const char* end) {
752752
}
753753
p++;
754754
}
755-
return strtoll(start, NULL, R);
755+
return strtoll(start, nullptr, R);
756756
}
757757

758758
static url_host_type ParseIPv4Host(url_host* host,

src/tracing/node_trace_buffer.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ TraceObject* InternalTraceBuffer::GetEventByHandle(uint64_t handle) {
3232
Mutex::ScopedLock scoped_lock(mutex_);
3333
if (handle == 0) {
3434
// A handle value of zero never has a trace event associated with it.
35-
return NULL;
35+
return nullptr;
3636
}
3737
size_t chunk_index, event_index;
3838
uint32_t buffer_id, chunk_seq;
@@ -41,12 +41,12 @@ TraceObject* InternalTraceBuffer::GetEventByHandle(uint64_t handle) {
4141
// Either the chunk belongs to the other buffer, or is outside the current
4242
// range of chunks loaded in memory (the latter being true suggests that
4343
// the chunk has already been flushed and is no longer in memory.)
44-
return NULL;
44+
return nullptr;
4545
}
4646
auto& chunk = chunks_[chunk_index];
4747
if (chunk->seq() != chunk_seq) {
4848
// Chunk is no longer in memory.
49-
return NULL;
49+
return nullptr;
5050
}
5151
return chunk->GetEventAt(event_index);
5252
}

src/tracing/node_trace_writer.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void NodeTraceWriter::OpenNewFileForStreaming() {
6060
std::ostringstream log_file;
6161
log_file << "node_trace." << file_num_ << ".log";
6262
fd_ = uv_fs_open(tracing_loop_, &req, log_file.str().c_str(),
63-
O_CREAT | O_WRONLY | O_TRUNC, 0644, NULL);
63+
O_CREAT | O_WRONLY | O_TRUNC, 0644, nullptr);
6464
CHECK_NE(fd_, -1);
6565
uv_fs_req_cleanup(&req);
6666
}

src/tracing/trace_event.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ static inline uint64_t AddTraceEvent(
518518
class ScopedTracer {
519519
public:
520520
// Note: members of data_ intentionally left uninitialized. See Initialize.
521-
ScopedTracer() : p_data_(NULL) {}
521+
ScopedTracer() : p_data_(nullptr) {}
522522

523523
~ScopedTracer() {
524524
if (p_data_ && *data_.category_group_enabled)

test/addons/repl-domain-abort/binding.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void Method(const FunctionCallbackInfo<Value>& args) {
3535
isolate->GetCurrentContext()->Global(),
3636
args[0].As<Function>(),
3737
0,
38-
NULL);
38+
nullptr);
3939
}
4040

4141
void init(Local<Object> exports) {

test/cctest/test_inspector_socket_server.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ class ServerHolder {
313313
public:
314314
template <typename Delegate>
315315
ServerHolder(Delegate* delegate, uv_loop_t* loop, int port)
316-
: ServerHolder(delegate, loop, HOST, port, NULL) { }
316+
: ServerHolder(delegate, loop, HOST, port, nullptr) { }
317317

318318
template <typename Delegate>
319319
ServerHolder(Delegate* delegate, uv_loop_t* loop, const std::string host,
@@ -617,7 +617,7 @@ TEST_F(InspectorSocketServerTest, BindsToIpV6) {
617617
return;
618618
}
619619
TestInspectorServerDelegate delegate;
620-
ServerHolder server(&delegate, &loop, "::", 0, NULL);
620+
ServerHolder server(&delegate, &loop, "::", 0, nullptr);
621621
ASSERT_TRUE(server->Start());
622622

623623
SocketWrapper socket1(&loop);

0 commit comments

Comments
 (0)