src: use nullptr instead of NULL

PR-URL: https://github.com/nodejs/node/pull/17373
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>
This commit is contained in:
Daniel Bevenius 2017-11-27 09:19:11 +01:00
parent 85e34b0c73
commit e32bbbf4d7
15 changed files with 48 additions and 46 deletions

View File

@ -798,7 +798,7 @@ int ParseGeneralReply(Environment* env,
status = ares_parse_ns_reply(buf, len, &host);
break;
case ns_t_ptr:
status = ares_parse_ptr_reply(buf, len, NULL, 0, AF_INET, &host);
status = ares_parse_ptr_reply(buf, len, nullptr, 0, AF_INET, &host);
break;
default:
CHECK(0 && "Bad NS type");
@ -830,7 +830,7 @@ int ParseGeneralReply(Environment* env,
HostentToNames(env, host, ret);
} else if (*type == ns_t_ptr) {
uint32_t offset = ret->Length();
for (uint32_t i = 0; host->h_aliases[i] != NULL; i++) {
for (uint32_t i = 0; host->h_aliases[i] != nullptr; i++) {
ret->Set(context,
i + offset,
OneByteString(env->isolate(), host->h_aliases[i])).FromJust();

View File

@ -577,7 +577,7 @@ int inspector_accept(uv_stream_t* server, InspectorSocket* socket,
data_received_cb);
}
if (err != 0) {
uv_close(reinterpret_cast<uv_handle_t*>(tcp), NULL);
uv_close(reinterpret_cast<uv_handle_t*>(tcp), nullptr);
}
return err;
}

View File

@ -94,7 +94,7 @@ void PrintDebuggerReadyMessage(const std::string& host,
int port,
const std::vector<std::string>& ids,
FILE* out) {
if (out == NULL) {
if (out == nullptr) {
return;
}
for (const std::string& id : ids) {
@ -398,7 +398,7 @@ bool InspectorSocketServer::Start() {
int err = uv_getaddrinfo(loop_, &req, nullptr, host_.c_str(),
port_string.c_str(), &hints);
if (err < 0) {
if (out_ != NULL) {
if (out_ != nullptr) {
fprintf(out_, "Unable to resolve \"%s\": %s\n", host_.c_str(),
uv_strerror(err));
}
@ -416,7 +416,7 @@ bool InspectorSocketServer::Start() {
// We only show error if we failed to start server on all addresses. We only
// show one error, for the last address.
if (server_sockets_.empty()) {
if (out_ != NULL) {
if (out_ != nullptr) {
fprintf(out_, "Starting inspector on %s:%d failed: %s\n",
host_.c_str(), port_, uv_strerror(err));
fflush(out_);

View File

@ -108,14 +108,14 @@ namespace node {
NODE_EXTERN v8::Local<v8::Value> ErrnoException(v8::Isolate* isolate,
int errorno,
const char* syscall = NULL,
const char* message = NULL,
const char* path = NULL);
const char* syscall = nullptr,
const char* message = nullptr,
const char* path = nullptr);
NODE_EXTERN v8::Local<v8::Value> UVException(v8::Isolate* isolate,
int errorno,
const char* syscall = NULL,
const char* message = NULL,
const char* path = NULL);
const char* syscall = nullptr,
const char* message = nullptr,
const char* path = nullptr);
NODE_EXTERN v8::Local<v8::Value> UVException(v8::Isolate* isolate,
int errorno,
const char* syscall,
@ -126,9 +126,9 @@ NODE_EXTERN v8::Local<v8::Value> UVException(v8::Isolate* isolate,
NODE_DEPRECATED("Use ErrnoException(isolate, ...)",
inline v8::Local<v8::Value> ErrnoException(
int errorno,
const char* syscall = NULL,
const char* message = NULL,
const char* path = NULL) {
const char* syscall = nullptr,
const char* message = nullptr,
const char* path = nullptr) {
return ErrnoException(v8::Isolate::GetCurrent(),
errorno,
syscall,
@ -137,9 +137,9 @@ NODE_DEPRECATED("Use ErrnoException(isolate, ...)",
})
inline v8::Local<v8::Value> UVException(int errorno,
const char* syscall = NULL,
const char* message = NULL,
const char* path = NULL) {
const char* syscall = nullptr,
const char* message = nullptr,
const char* path = nullptr) {
return UVException(v8::Isolate::GetCurrent(),
errorno,
syscall,
@ -426,14 +426,14 @@ NODE_DEPRECATED("Use DecodeWrite(isolate, ...)",
NODE_EXTERN v8::Local<v8::Value> WinapiErrnoException(
v8::Isolate* isolate,
int errorno,
const char *syscall = NULL,
const char *syscall = nullptr,
const char *msg = "",
const char *path = NULL);
const char *path = nullptr);
NODE_DEPRECATED("Use WinapiErrnoException(isolate, ...)",
inline v8::Local<v8::Value> WinapiErrnoException(int errorno,
const char *syscall = NULL, const char *msg = "",
const char *path = NULL) {
const char *syscall = nullptr, const char *msg = "",
const char *path = nullptr) {
return WinapiErrnoException(v8::Isolate::GetCurrent(),
errorno,
syscall,

View File

@ -1210,7 +1210,7 @@ static void EncodeUtf8String(const FunctionCallbackInfo<Value>& args) {
char* data = node::UncheckedMalloc(length);
str->WriteUtf8(data,
-1, // We are certain that `data` is sufficiently large
NULL,
nullptr,
String::NO_NULL_TERMINATION | String::REPLACE_INVALID_UTF8);
auto array_buf = ArrayBuffer::New(env->isolate(), data, length,
ArrayBufferCreationMode::kInternalized);

View File

@ -1775,7 +1775,7 @@ static bool SafeX509ExtPrint(BIO* out, X509_EXTENSION* ext) {
return false;
GENERAL_NAMES* names = static_cast<GENERAL_NAMES*>(X509V3_EXT_d2i(ext));
if (names == NULL)
if (names == nullptr)
return false;
for (int i = 0; i < sk_GENERAL_NAME_num(names); i++) {
@ -1791,8 +1791,8 @@ static bool SafeX509ExtPrint(BIO* out, X509_EXTENSION* ext) {
BIO_write(out, name->data, name->length);
} else {
STACK_OF(CONF_VALUE)* nval = i2v_GENERAL_NAME(
const_cast<X509V3_EXT_METHOD*>(method), gen, NULL);
if (nval == NULL)
const_cast<X509V3_EXT_METHOD*>(method), gen, nullptr);
if (nval == nullptr)
return false;
X509V3_EXT_val_prn(out, nval, 0, 0);
sk_CONF_VALUE_pop_free(nval, X509V3_conf_free);
@ -6094,7 +6094,7 @@ void InitCryptoOnce() {
if (0 != err) {
fprintf(stderr,
"openssl config failed: %s\n",
ERR_error_string(err, NULL));
ERR_error_string(err, nullptr));
CHECK_NE(err, 0);
}
}
@ -6117,7 +6117,9 @@ void InitCryptoOnce() {
}
}
if (0 != err) {
fprintf(stderr, "openssl fips failed: %s\n", ERR_error_string(err, NULL));
fprintf(stderr,
"openssl fips failed: %s\n",
ERR_error_string(err, nullptr));
UNREACHABLE();
}
#endif // NODE_FIPS_MODE

View File

@ -1792,7 +1792,7 @@ void Http2Session::Goaway(const FunctionCallbackInfo<Value>& args) {
int32_t lastStreamID = args[1]->Int32Value(context).ToChecked();
Local<Value> opaqueData = args[2];
uint8_t* data = NULL;
uint8_t* data = nullptr;
size_t length = 0;
if (opaqueData->BooleanValue(context).ToChecked()) {

View File

@ -114,21 +114,21 @@ MaybeLocal<Object> ToBufferEndian(Environment* env, MaybeStackBuffer<T>* buf) {
}
struct Converter {
explicit Converter(const char* name, const char* sub = NULL)
explicit Converter(const char* name, const char* sub = nullptr)
: conv(nullptr) {
UErrorCode status = U_ZERO_ERROR;
conv = ucnv_open(name, &status);
CHECK(U_SUCCESS(status));
if (sub != NULL) {
if (sub != nullptr) {
ucnv_setSubstChars(conv, sub, strlen(sub), &status);
}
}
explicit Converter(UConverter* converter,
const char* sub = NULL) : conv(converter) {
const char* sub = nullptr) : conv(converter) {
CHECK_NE(conv, nullptr);
UErrorCode status = U_ZERO_ERROR;
if (sub != NULL) {
if (sub != nullptr) {
ucnv_setSubstChars(conv, sub, strlen(sub), &status);
}
}
@ -229,7 +229,7 @@ class ConverterObject : public BaseObject, Converter {
ucnv_toUnicode(converter->conv,
&target, target + (limit * sizeof(UChar)),
&source, source + source_length,
NULL, flush, &status);
nullptr, flush, &status);
if (U_SUCCESS(status)) {
if (limit > 0)
@ -254,7 +254,7 @@ class ConverterObject : public BaseObject, Converter {
v8::Local<v8::Object> wrap,
UConverter* converter,
bool ignoreBOM,
const char* sub = NULL) :
const char* sub = nullptr) :
BaseObject(env, wrap),
Converter(converter, sub),
ignoreBOM_(ignoreBOM) {
@ -427,7 +427,7 @@ const char* EncodingName(const enum encoding encoding) {
case LATIN1: return "iso8859-1";
case UCS2: return "utf16le";
case UTF8: return "utf-8";
default: return NULL;
default: return nullptr;
}
}

View File

@ -382,7 +382,7 @@ static void GetUserInfo(const FunctionCallbackInfo<Value>& args) {
&error);
MaybeLocal<Value> shell;
if (pwd.shell == NULL)
if (pwd.shell == nullptr)
shell = Null(env->isolate());
else
shell = StringBytes::Encode(env->isolate(), pwd.shell, encoding, &error);

View File

@ -752,7 +752,7 @@ static inline int64_t ParseNumber(const char* start, const char* end) {
}
p++;
}
return strtoll(start, NULL, R);
return strtoll(start, nullptr, R);
}
static url_host_type ParseIPv4Host(url_host* host,

View File

@ -32,7 +32,7 @@ TraceObject* InternalTraceBuffer::GetEventByHandle(uint64_t handle) {
Mutex::ScopedLock scoped_lock(mutex_);
if (handle == 0) {
// A handle value of zero never has a trace event associated with it.
return NULL;
return nullptr;
}
size_t chunk_index, event_index;
uint32_t buffer_id, chunk_seq;
@ -41,12 +41,12 @@ TraceObject* InternalTraceBuffer::GetEventByHandle(uint64_t handle) {
// Either the chunk belongs to the other buffer, or is outside the current
// range of chunks loaded in memory (the latter being true suggests that
// the chunk has already been flushed and is no longer in memory.)
return NULL;
return nullptr;
}
auto& chunk = chunks_[chunk_index];
if (chunk->seq() != chunk_seq) {
// Chunk is no longer in memory.
return NULL;
return nullptr;
}
return chunk->GetEventAt(event_index);
}

View File

@ -60,7 +60,7 @@ void NodeTraceWriter::OpenNewFileForStreaming() {
std::ostringstream log_file;
log_file << "node_trace." << file_num_ << ".log";
fd_ = uv_fs_open(tracing_loop_, &req, log_file.str().c_str(),
O_CREAT | O_WRONLY | O_TRUNC, 0644, NULL);
O_CREAT | O_WRONLY | O_TRUNC, 0644, nullptr);
CHECK_NE(fd_, -1);
uv_fs_req_cleanup(&req);
}

View File

@ -518,7 +518,7 @@ static inline uint64_t AddTraceEvent(
class ScopedTracer {
public:
// Note: members of data_ intentionally left uninitialized. See Initialize.
ScopedTracer() : p_data_(NULL) {}
ScopedTracer() : p_data_(nullptr) {}
~ScopedTracer() {
if (p_data_ && *data_.category_group_enabled)

View File

@ -35,7 +35,7 @@ void Method(const FunctionCallbackInfo<Value>& args) {
isolate->GetCurrentContext()->Global(),
args[0].As<Function>(),
0,
NULL);
nullptr);
}
void init(Local<Object> exports) {

View File

@ -313,7 +313,7 @@ class ServerHolder {
public:
template <typename Delegate>
ServerHolder(Delegate* delegate, uv_loop_t* loop, int port)
: ServerHolder(delegate, loop, HOST, port, NULL) { }
: ServerHolder(delegate, loop, HOST, port, nullptr) { }
template <typename Delegate>
ServerHolder(Delegate* delegate, uv_loop_t* loop, const std::string host,
@ -617,7 +617,7 @@ TEST_F(InspectorSocketServerTest, BindsToIpV6) {
return;
}
TestInspectorServerDelegate delegate;
ServerHolder server(&delegate, &loop, "::", 0, NULL);
ServerHolder server(&delegate, &loop, "::", 0, nullptr);
ASSERT_TRUE(server->Start());
SocketWrapper socket1(&loop);