Skip to content

Commit f52c2b9

Browse files
danbevgibfahn
authored andcommitted
src: use nullptr instead of NULL
PR-URL: #17373 Backport-PR-URL: #17873 Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
1 parent 47322e6 commit f52c2b9

16 files changed

+50
-46
lines changed

src/cares_wrap.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ int ParseGeneralReply(Environment* env,
802802
status = ares_parse_ns_reply(buf, len, &host);
803803
break;
804804
case ns_t_ptr:
805-
status = ares_parse_ptr_reply(buf, len, NULL, 0, AF_INET, &host);
805+
status = ares_parse_ptr_reply(buf, len, nullptr, 0, AF_INET, &host);
806806
break;
807807
default:
808808
CHECK(0 && "Bad NS type");
@@ -834,7 +834,7 @@ int ParseGeneralReply(Environment* env,
834834
HostentToNames(env, host, ret);
835835
} else if (*type == ns_t_ptr) {
836836
uint32_t offset = ret->Length();
837-
for (uint32_t i = 0; host->h_aliases[i] != NULL; i++) {
837+
for (uint32_t i = 0; host->h_aliases[i] != nullptr; i++) {
838838
ret->Set(context,
839839
i + offset,
840840
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: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,14 @@ namespace node {
102102

103103
NODE_EXTERN v8::Local<v8::Value> ErrnoException(v8::Isolate* isolate,
104104
int errorno,
105-
const char* syscall = NULL,
106-
const char* message = NULL,
107-
const char* path = NULL);
105+
const char* syscall = nullptr,
106+
const char* message = nullptr,
107+
const char* path = nullptr);
108108
NODE_EXTERN v8::Local<v8::Value> UVException(v8::Isolate* isolate,
109109
int errorno,
110-
const char* syscall = NULL,
111-
const char* message = NULL,
112-
const char* path = NULL);
110+
const char* syscall = nullptr,
111+
const char* message = nullptr,
112+
const char* path = nullptr);
113113
NODE_EXTERN v8::Local<v8::Value> UVException(v8::Isolate* isolate,
114114
int errorno,
115115
const char* syscall,
@@ -120,9 +120,9 @@ NODE_EXTERN v8::Local<v8::Value> UVException(v8::Isolate* isolate,
120120
NODE_DEPRECATED("Use ErrnoException(isolate, ...)",
121121
inline v8::Local<v8::Value> ErrnoException(
122122
int errorno,
123-
const char* syscall = NULL,
124-
const char* message = NULL,
125-
const char* path = NULL) {
123+
const char* syscall = nullptr,
124+
const char* message = nullptr,
125+
const char* path = nullptr) {
126126
return ErrnoException(v8::Isolate::GetCurrent(),
127127
errorno,
128128
syscall,
@@ -131,9 +131,9 @@ NODE_DEPRECATED("Use ErrnoException(isolate, ...)",
131131
})
132132

133133
inline v8::Local<v8::Value> UVException(int errorno,
134-
const char* syscall = NULL,
135-
const char* message = NULL,
136-
const char* path = NULL) {
134+
const char* syscall = nullptr,
135+
const char* message = nullptr,
136+
const char* path = nullptr) {
137137
return UVException(v8::Isolate::GetCurrent(),
138138
errorno,
139139
syscall,
@@ -391,14 +391,14 @@ NODE_DEPRECATED("Use DecodeWrite(isolate, ...)",
391391
NODE_EXTERN v8::Local<v8::Value> WinapiErrnoException(
392392
v8::Isolate* isolate,
393393
int errorno,
394-
const char *syscall = NULL,
394+
const char *syscall = nullptr,
395395
const char *msg = "",
396-
const char *path = NULL);
396+
const char *path = nullptr);
397397

398398
NODE_DEPRECATED("Use WinapiErrnoException(isolate, ...)",
399399
inline v8::Local<v8::Value> WinapiErrnoException(int errorno,
400-
const char *syscall = NULL, const char *msg = "",
401-
const char *path = NULL) {
400+
const char *syscall = nullptr, const char *msg = "",
401+
const char *path = nullptr) {
402402
return WinapiErrnoException(v8::Isolate::GetCurrent(),
403403
errorno,
404404
syscall,
@@ -510,6 +510,7 @@ extern "C" NODE_EXTERN void node_module_register(void* mod);
510510
NODE_MODULE_CONTEXT_AWARE_X(modname, regfunc, NULL, 0)
511511

512512
#define NODE_MODULE_CONTEXT_AWARE_BUILTIN(modname, regfunc) \
513+
/* NOLINTNEXTLINE (readability/null_usage) */ \
513514
NODE_MODULE_CONTEXT_AWARE_X(modname, regfunc, NULL, NM_F_BUILTIN) \
514515

515516
/*

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
@@ -1528,7 +1528,7 @@ static bool SafeX509ExtPrint(BIO* out, X509_EXTENSION* ext) {
15281528
return false;
15291529

15301530
GENERAL_NAMES* names = static_cast<GENERAL_NAMES*>(X509V3_EXT_d2i(ext));
1531-
if (names == NULL)
1531+
if (names == nullptr)
15321532
return false;
15331533

15341534
for (int i = 0; i < sk_GENERAL_NAME_num(names); i++) {
@@ -1544,8 +1544,8 @@ static bool SafeX509ExtPrint(BIO* out, X509_EXTENSION* ext) {
15441544
BIO_write(out, name->data, name->length);
15451545
} else {
15461546
STACK_OF(CONF_VALUE)* nval = i2v_GENERAL_NAME(
1547-
const_cast<X509V3_EXT_METHOD*>(method), gen, NULL);
1548-
if (nval == NULL)
1547+
const_cast<X509V3_EXT_METHOD*>(method), gen, nullptr);
1548+
if (nval == nullptr)
15491549
return false;
15501550
X509V3_EXT_val_prn(out, nval, 0, 0);
15511551
sk_CONF_VALUE_pop_free(nval, X509V3_conf_free);
@@ -6018,7 +6018,7 @@ void InitCryptoOnce() {
60186018
if (0 != err) {
60196019
fprintf(stderr,
60206020
"openssl config failed: %s\n",
6021-
ERR_error_string(err, NULL));
6021+
ERR_error_string(err, nullptr));
60226022
CHECK_NE(err, 0);
60236023
}
60246024
}
@@ -6039,7 +6039,9 @@ void InitCryptoOnce() {
60396039
}
60406040
}
60416041
if (0 != err) {
6042-
fprintf(stderr, "openssl fips failed: %s\n", ERR_error_string(err, NULL));
6042+
fprintf(stderr,
6043+
"openssl fips failed: %s\n",
6044+
ERR_error_string(err, nullptr));
60436045
UNREACHABLE();
60446046
}
60456047
#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
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_internals.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ class InternalCallbackScope {
306306
};
307307

308308
#define NODE_MODULE_CONTEXT_AWARE_INTERNAL(modname, regfunc) \
309+
/* NOLINTNEXTLINE (readability/null_usage) */ \
309310
NODE_MODULE_CONTEXT_AWARE_X(modname, regfunc, NULL, NM_F_INTERNAL) \
310311

311312
} // namespace node

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);

0 commit comments

Comments
 (0)