Skip to content

Commit 8cedfb8

Browse files
gengjiawenaddaleax
authored andcommitted
src: refactor to nullptr in cpp code
Signed-off-by: gengjiawen <technicalcute@gmail.com> PR-URL: #25888 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
1 parent 1b9a608 commit 8cedfb8

File tree

6 files changed

+18
-12
lines changed

6 files changed

+18
-12
lines changed

src/cares_wrap.cc

+4-3
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ void safe_free_hostent(struct hostent* host) {
395395
free(host->h_addr_list[idx++]);
396396
}
397397
free(host->h_addr_list);
398-
host->h_addr_list = 0;
398+
host->h_addr_list = nullptr;
399399
}
400400

401401
if (host->h_aliases != nullptr) {
@@ -404,7 +404,7 @@ void safe_free_hostent(struct hostent* host) {
404404
free(host->h_aliases[idx++]);
405405
}
406406
free(host->h_aliases);
407-
host->h_aliases = 0;
407+
host->h_aliases = nullptr;
408408
}
409409

410410
if (host->h_name != nullptr) {
@@ -1914,7 +1914,8 @@ void AfterGetNameInfo(uv_getnameinfo_t* req,
19141914
req_wrap->MakeCallback(env->oncomplete_string(), arraysize(argv), argv);
19151915
}
19161916

1917-
using ParseIPResult = decltype(static_cast<ares_addr_port_node*>(0)->addr);
1917+
using ParseIPResult =
1918+
decltype(static_cast<ares_addr_port_node*>(nullptr)->addr);
19181919

19191920
int ParseIP(const char* ip, ParseIPResult* result = nullptr) {
19201921
ParseIPResult tmp;

src/debug_utils.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ class PosixSymbolDebuggingContext final : public NativeSymbolDebuggingContext {
6666
return ret;
6767

6868
if (info.dli_sname != nullptr) {
69-
if (char* demangled = abi::__cxa_demangle(info.dli_sname, 0, 0, 0)) {
69+
if (char* demangled =
70+
abi::__cxa_demangle(info.dli_sname, nullptr, nullptr, nullptr)) {
7071
ret.name = demangled;
7172
free(demangled);
7273
} else {

src/node.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -562,13 +562,15 @@ extern "C" NODE_EXTERN void node_module_register(void* mod);
562562
/* Called after the event loop exits but before the VM is disposed.
563563
* Callbacks are run in reverse order of registration, i.e. newest first.
564564
*/
565-
NODE_EXTERN void AtExit(void (*cb)(void* arg), void* arg = 0);
565+
NODE_EXTERN void AtExit(void (*cb)(void* arg), void* arg = nullptr);
566566

567567
/* Registers a callback with the passed-in Environment instance. The callback
568568
* is called after the event loop exits, but before the VM is disposed.
569569
* Callbacks are run in reverse order of registration, i.e. newest first.
570570
*/
571-
NODE_EXTERN void AtExit(Environment* env, void (*cb)(void* arg), void* arg = 0);
571+
NODE_EXTERN void AtExit(Environment* env,
572+
void (*cb)(void* arg),
573+
void* arg = nullptr);
572574

573575
typedef void (*promise_hook_func) (v8::PromiseHookType type,
574576
v8::Local<v8::Promise> promise,

src/node_crypto.cc

+6-4
Original file line numberDiff line numberDiff line change
@@ -4818,7 +4818,7 @@ void DiffieHellman::Initialize(Environment* env, Local<Object> target) {
48184818

48194819
bool DiffieHellman::Init(int primeLength, int g) {
48204820
dh_.reset(DH_new());
4821-
if (!DH_generate_parameters_ex(dh_.get(), primeLength, g, 0))
4821+
if (!DH_generate_parameters_ex(dh_.get(), primeLength, g, nullptr))
48224822
return false;
48234823
return VerifyContext();
48244824
}
@@ -4841,8 +4841,10 @@ bool DiffieHellman::Init(const char* p, int p_len, int g) {
48414841

48424842
bool DiffieHellman::Init(const char* p, int p_len, const char* g, int g_len) {
48434843
dh_.reset(DH_new());
4844-
BIGNUM* bn_p = BN_bin2bn(reinterpret_cast<const unsigned char*>(p), p_len, 0);
4845-
BIGNUM* bn_g = BN_bin2bn(reinterpret_cast<const unsigned char*>(g), g_len, 0);
4844+
BIGNUM* bn_p =
4845+
BN_bin2bn(reinterpret_cast<const unsigned char*>(p), p_len, nullptr);
4846+
BIGNUM* bn_g =
4847+
BN_bin2bn(reinterpret_cast<const unsigned char*>(g), g_len, nullptr);
48464848
if (!DH_set0_pqg(dh_.get(), bn_p, nullptr, bn_g)) {
48474849
BN_free(bn_p);
48484850
BN_free(bn_g);
@@ -5010,7 +5012,7 @@ void DiffieHellman::ComputeSecret(const FunctionCallbackInfo<Value>& args) {
50105012
BignumPointer key(BN_bin2bn(
50115013
reinterpret_cast<unsigned char*>(Buffer::Data(args[0])),
50125014
Buffer::Length(args[0]),
5013-
0));
5015+
nullptr));
50145016

50155017
MallocedBuffer<char> data(DH_size(diffieHellman->dh_.get()));
50165018

src/util-inl.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ typename ListHead<T, M>::Iterator ListHead<T, M>::end() const {
143143

144144
template <typename Inner, typename Outer>
145145
constexpr uintptr_t OffsetOf(Inner Outer::*field) {
146-
return reinterpret_cast<uintptr_t>(&(static_cast<Outer*>(0)->*field));
146+
return reinterpret_cast<uintptr_t>(&(static_cast<Outer*>(nullptr)->*field));
147147
}
148148

149149
template <typename Inner, typename Outer>

src/util.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static void MakeUtf8String(Isolate* isolate,
4848
const int flags =
4949
String::NO_NULL_TERMINATION | String::REPLACE_INVALID_UTF8;
5050
const int length =
51-
string->WriteUtf8(isolate, target->out(), storage, 0, flags);
51+
string->WriteUtf8(isolate, target->out(), storage, nullptr, flags);
5252
target->SetLengthAndZeroTerminate(length);
5353
}
5454

0 commit comments

Comments
 (0)