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

File tree

15 files changed

+48
-46
lines changed

15 files changed

+48
-46
lines changed

‎src/cares_wrap.cc‎

Lines changed: 2 additions & 2 deletions
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
} elseif (*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‎

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

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

Lines changed: 16 additions & 16 deletions
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-
constchar* syscall = NULL,
112-
constchar* message = NULL,
113-
constchar* path = NULL);
111+
constchar* syscall = nullptr,
112+
constchar* message = nullptr,
113+
constchar* path = nullptr);
114114
NODE_EXTERN v8::Local<v8::Value> UVException(v8::Isolate* isolate,
115115
int errorno,
116-
constchar* syscall = NULL,
117-
constchar* message = NULL,
118-
constchar* path = NULL);
116+
constchar* syscall = nullptr,
117+
constchar* message = nullptr,
118+
constchar* path = nullptr);
119119
NODE_EXTERN v8::Local<v8::Value> UVException(v8::Isolate* isolate,
120120
int errorno,
121121
constchar* 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-
constchar* syscall = NULL,
130-
constchar* message = NULL,
131-
constchar* path = NULL){
129+
constchar* syscall = nullptr,
130+
constchar* message = nullptr,
131+
constchar* path = nullptr){
132132
returnErrnoException(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-
constchar* syscall = NULL,
141-
constchar* message = NULL,
142-
constchar* path = NULL){
140+
constchar* syscall = nullptr,
141+
constchar* message = nullptr,
142+
constchar* path = nullptr){
143143
returnUVException(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-
constchar *syscall = NULL,
429+
constchar *syscall = nullptr,
430430
constchar *msg = "",
431-
constchar *path = NULL);
431+
constchar *path = nullptr);
432432

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

‎src/node_buffer.cc‎

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1782,7 +1782,7 @@ static bool SafeX509ExtPrint(BIO* out, X509_EXTENSION* ext){
17821782
returnfalse;
17831783

17841784
GENERAL_NAMES* names = static_cast<GENERAL_NAMES*>(X509V3_EXT_d2i(ext));
1785-
if (names == NULL)
1785+
if (names == nullptr)
17861786
returnfalse;
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
returnfalse;
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‎

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

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

116116
structConverter{
117-
explicitConverter(constchar* name, constchar* sub = NULL)
117+
explicitConverter(constchar* name, constchar* 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
explicitConverter(UConverter* converter,
128-
constchar* sub = NULL) : conv(converter){
128+
constchar* 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-
constchar* sub = NULL) :
257+
constchar* 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: returnNULL;
430+
default: returnnullptr;
431431
}
432432
}
433433

‎src/node_os.cc‎

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

Lines changed: 1 addition & 1 deletion
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-
returnstrtoll(start, NULL, R);
755+
returnstrtoll(start, nullptr, R);
756756
}
757757

758758
static url_host_type ParseIPv4Host(url_host* host,

0 commit comments

Comments
(0)