Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: fix modernize-return-braced-init-list #26023

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/api/callback.cc
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ MaybeLocal<Value> InternalMakeCallback(Environment* env,
CHECK(!recv.IsEmpty());
InternalCallbackScope scope(env, recv, asyncContext);
if (scope.Failed()) {
return MaybeLocal<Value>();
return {};
}

Local<Function> domain_cb = env->domain_callback();
Expand Down
2 changes: 1 addition & 1 deletion src/api/environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ Local<Context> NewContext(Isolate* isolate,
per_process::native_module_loader.LookupAndCompile(
context, "internal/per_context", &parameters, nullptr);
if (maybe_fn.IsEmpty()) {
return Local<Context>();
return {};
}
Local<Function> fn = maybe_fn.ToLocalChecked();
MaybeLocal<Value> result =
Expand Down
2 changes: 1 addition & 1 deletion src/async_wrap-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ inline v8::MaybeLocal<v8::Value> AsyncWrap::MakeCallback(
v8::Local<v8::Value>* argv) {
v8::Local<v8::Value> cb_v;
if (!object()->Get(env()->context(), symbol).ToLocal(&cb_v))
return v8::MaybeLocal<v8::Value>();
return {};
if (!cb_v->IsFunction()) {
// TODO(addaleax): We should throw an error here to fulfill the
// `MaybeLocal<>` API contract.
Expand Down
2 changes: 1 addition & 1 deletion src/heap_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class JSGraph : public EmbedderGraph {
Number::New(isolate_, n->SizeInBytes()))
.IsNothing() ||
obj->Set(context, edges_string, Array::New(isolate_)).IsNothing()) {
return MaybeLocal<Array>();
return {};
}
if (nodes->Set(context, i++, obj).IsNothing())
return MaybeLocal<Array>();
Expand Down
2 changes: 1 addition & 1 deletion src/js_native_api_v8.cc
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ class Reference : private Finalizer {

v8::Local<v8::Value> Get() {
if (_persistent.IsEmpty()) {
return v8::Local<v8::Value>();
return {};
} else {
return v8::Local<v8::Value>::New(_env->isolate, _persistent);
}
Expand Down
2 changes: 1 addition & 1 deletion src/memory_tracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class MemoryRetainer {
virtual size_t SelfSize() const = 0;

virtual v8::Local<v8::Object> WrappedObject() const {
return v8::Local<v8::Object>();
return {};
}

virtual bool IsRootNode() const { return false; }
Expand Down
4 changes: 2 additions & 2 deletions src/module_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ MaybeLocal<Module> ModuleWrap::ResolveCallback(Local<Context> context,
ModuleWrap* dependent = GetFromModule(env, referrer);
if (dependent == nullptr) {
env->ThrowError("linking error, null dep");
return MaybeLocal<Module>();
return {};
}

Utf8Value specifier_utf8(isolate, specifier);
Expand Down Expand Up @@ -771,7 +771,7 @@ static MaybeLocal<Promise> ImportModuleDynamically(
return handle_scope.Escape(result.As<Promise>());
}

return MaybeLocal<Promise>();
return {};
}

void ModuleWrap::SetImportModuleDynamicallyCallback(
Expand Down
4 changes: 2 additions & 2 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ static MaybeLocal<Value> ExecuteBootstrapper(
env->context(), id, parameters, env);

if (maybe_fn.IsEmpty()) {
return MaybeLocal<Value>();
return {};
}

Local<Function> fn = maybe_fn.ToLocalChecked();
Expand Down Expand Up @@ -263,7 +263,7 @@ MaybeLocal<Value> RunBootstrapping(Environment* env) {
&primordials_params,
&primordials_args);
if (primordials_ret.IsEmpty()) {
return MaybeLocal<Value>();
return {};
}

// Create binding loaders
Expand Down
10 changes: 5 additions & 5 deletions src/node_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ MaybeLocal<Object> New(Isolate* isolate, size_t length) {
Environment* env = Environment::GetCurrent(isolate);
if (env == nullptr) {
THROW_ERR_BUFFER_CONTEXT_NOT_AVAILABLE(isolate);
return MaybeLocal<Object>();
return {};
}
if (Buffer::New(env, length).ToLocal(&obj))
return handle_scope.Escape(obj);
Expand Down Expand Up @@ -325,7 +325,7 @@ MaybeLocal<Object> Copy(Isolate* isolate, const char* data, size_t length) {
Environment* env = Environment::GetCurrent(isolate);
if (env == nullptr) {
THROW_ERR_BUFFER_CONTEXT_NOT_AVAILABLE(isolate);
return MaybeLocal<Object>();
return {};
}
Local<Object> obj;
if (Buffer::Copy(env, data, length).ToLocal(&obj))
Expand Down Expand Up @@ -378,7 +378,7 @@ MaybeLocal<Object> New(Isolate* isolate,
if (env == nullptr) {
callback(data, hint);
THROW_ERR_BUFFER_CONTEXT_NOT_AVAILABLE(isolate);
return MaybeLocal<Object>();
return {};
}
Local<Object> obj;
if (Buffer::New(env, data, length, callback, hint).ToLocal(&obj))
Expand Down Expand Up @@ -406,7 +406,7 @@ MaybeLocal<Object> New(Environment* env,
CallbackInfo::New(env->isolate(), ab, callback, data, hint);

if (ui.IsEmpty())
return MaybeLocal<Object>();
return {};

return scope.Escape(ui.ToLocalChecked());
}
Expand All @@ -418,7 +418,7 @@ MaybeLocal<Object> New(Isolate* isolate, char* data, size_t length) {
if (env == nullptr) {
free(data);
THROW_ERR_BUFFER_CONTEXT_NOT_AVAILABLE(isolate);
return MaybeLocal<Object>();
return {};
}
Local<Object> obj;
if (Buffer::New(env, data, length).ToLocal(&obj))
Expand Down
4 changes: 2 additions & 2 deletions src/node_contextify.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ MaybeLocal<Object> ContextifyContext::CreateDataWrapper(Environment* env) {
if (!env->script_data_constructor_function()
->NewInstance(env->context())
.ToLocal(&wrapper)) {
return MaybeLocal<Object>();
return {};
}

wrapper->SetAlignedPointerInInternalField(0, this);
Expand All @@ -146,7 +146,7 @@ MaybeLocal<Context> ContextifyContext::CreateV8Context(

Local<Object> data_wrapper;
if (!CreateDataWrapper(env).ToLocal(&data_wrapper))
return MaybeLocal<Context>();
return {};

NamedPropertyHandlerConfiguration config(PropertyGetterCallback,
PropertySetterCallback,
Expand Down
8 changes: 4 additions & 4 deletions src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1649,7 +1649,7 @@ static MaybeLocal<Object> ECPointToBuffer(Environment* env,
size_t len = EC_POINT_point2oct(group, point, form, nullptr, 0, nullptr);
if (len == 0) {
if (error != nullptr) *error = "Failed to get public key length";
return MaybeLocal<Object>();
return {};
}
MallocedBuffer<unsigned char> buf(len);
len = EC_POINT_point2oct(group, point, form, buf.data, buf.size, nullptr);
Expand Down Expand Up @@ -2843,7 +2843,7 @@ static MaybeLocal<Value> WritePublicKey(Environment* env,

if (!WritePublicKeyInner(pkey, bio, config)) {
ThrowCryptoError(env, ERR_get_error(), "Failed to encode public key");
return MaybeLocal<Value>();
return {};
}
return BIOToStringOrBuffer(env, bio.get(), config.format_);
}
Expand Down Expand Up @@ -3261,7 +3261,7 @@ static MaybeLocal<Value> WritePrivateKey(

if (err) {
ThrowCryptoError(env, ERR_get_error(), "Failed to encode private key");
return MaybeLocal<Value>();
return {};
}
return BIOToStringOrBuffer(env, bio.get(), config.format_);
}
Expand Down Expand Up @@ -3332,7 +3332,7 @@ MaybeLocal<Object> KeyObject::Create(Environment* env,
if (!env->crypto_key_object_constructor()
->NewInstance(env->context(), 1, &type)
.ToLocal(&obj)) {
return MaybeLocal<Object>();
return {};
}

KeyObject* key = Unwrap<KeyObject>(obj);
Expand Down
2 changes: 1 addition & 1 deletion src/node_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ inline MaybeLocal<Promise> FileHandle::ClosePromise() {
->fdclose_constructor_template()
->NewInstance(env()->context())
.ToLocal(&close_req_obj)) {
return MaybeLocal<Promise>();
return {};
}
CloseReq* req = new CloseReq(env(), close_req_obj, promise, object());
auto AfterClose = uv_fs_callback_t{[](uv_fs_t* req) {
Expand Down
2 changes: 1 addition & 1 deletion src/node_internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ v8::MaybeLocal<v8::Uint8Array> New(Environment* env,
v8::Maybe<bool> mb =
ui->SetPrototype(env->context(), env->buffer_prototype_object());
if (mb.IsNothing())
return v8::MaybeLocal<v8::Uint8Array>();
return {};
return ui;
}

Expand Down
4 changes: 2 additions & 2 deletions src/node_messaging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class DeserializerDelegate : public ValueDeserializer::Delegate {
// by the index in the message's MessagePort array is sufficient.
uint32_t id;
if (!deserializer->ReadUint32(&id))
return MaybeLocal<Object>();
return {};
CHECK_LE(id, message_ports_.size());
return message_ports_[id]->object(isolate);
};
Expand Down Expand Up @@ -104,7 +104,7 @@ MaybeLocal<Value> Message::Deserialize(Environment* env,
if (port != nullptr)
port->Close();
}
return MaybeLocal<Value>();
return {};
}
}
message_ports_.clear();
Expand Down
4 changes: 2 additions & 2 deletions src/node_native_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ MaybeLocal<Uint8Array> NativeModuleLoader::GetCodeCache(Isolate* isolate,
const auto it = code_cache_.find(id);
if (it == code_cache_.end()) {
// The module has not been compiled before.
return MaybeLocal<Uint8Array>();
return {};
}

cached_data = it->second.get();
Expand Down Expand Up @@ -243,7 +243,7 @@ MaybeLocal<Function> NativeModuleLoader::LookupAndCompile(
// In the case of early errors, v8 is already capable of
// decorating the stack for us - note that we use CompileFunctionInContext
// so there is no need to worry about wrappers.
return MaybeLocal<Function>();
return {};
}

Local<Function> fun = maybe_fun.ToLocalChecked();
Expand Down
2 changes: 1 addition & 1 deletion src/node_perf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ MaybeLocal<Object> PerformanceEntry::ToObject() const {
if (!env_->performance_entry_template()
->NewInstance(env_->context())
.ToLocal(&obj)) {
return MaybeLocal<Object>();
return {};
}
InitObject(*this, obj);
return obj;
Expand Down
2 changes: 1 addition & 1 deletion src/node_process_object.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ MaybeLocal<Object> CreateProcessObject(
Local<Object> process;
if (!process_template->GetFunction(context).ToLocal(&process_ctor) ||
!process_ctor->NewInstance(context).ToLocal(&process)) {
return MaybeLocal<Object>();
return {};
}

// process.title
Expand Down
2 changes: 1 addition & 1 deletion src/node_serdes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ MaybeLocal<Object> DeserializerContext::ReadHostObject(Isolate* isolate) {
nullptr);

if (ret.IsEmpty())
return MaybeLocal<Object>();
return {};

Local<Value> return_value = ret.ToLocalChecked();
if (!return_value->IsObject()) {
Expand Down
40 changes: 20 additions & 20 deletions src/node_zlib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1097,9 +1097,9 @@ CompressionError BrotliEncoderContext::Init(brotli_alloc_func alloc,
alloc_opaque_ = opaque;
state_.reset(BrotliEncoderCreateInstance(alloc, free, opaque));
if (!state_) {
return CompressionError("Could not initialize Brotli instance",
"ERR_ZLIB_INITIALIZATION_FAILED",
-1);
return {"Could not initialize Brotli instance",
"ERR_ZLIB_INITIALIZATION_FAILED",
-1};
} else {
return CompressionError {};
}
Expand All @@ -1113,19 +1113,19 @@ CompressionError BrotliEncoderContext::SetParams(int key, uint32_t value) {
if (!BrotliEncoderSetParameter(state_.get(),
static_cast<BrotliEncoderParameter>(key),
value)) {
return CompressionError("Setting parameter failed",
"ERR_BROTLI_PARAM_SET_FAILED",
-1);
return {"Setting parameter failed",
"ERR_BROTLI_PARAM_SET_FAILED",
-1};
} else {
return CompressionError {};
}
}

CompressionError BrotliEncoderContext::GetErrorInfo() const {
if (!last_result_) {
return CompressionError("Compression failed",
"ERR_BROTLI_COMPRESSION_FAILED",
-1);
return {"Compression failed",
"ERR_BROTLI_COMPRESSION_FAILED",
-1};
} else {
return CompressionError {};
}
Expand Down Expand Up @@ -1162,9 +1162,9 @@ CompressionError BrotliDecoderContext::Init(brotli_alloc_func alloc,
alloc_opaque_ = opaque;
state_.reset(BrotliDecoderCreateInstance(alloc, free, opaque));
if (!state_) {
return CompressionError("Could not initialize Brotli instance",
"ERR_ZLIB_INITIALIZATION_FAILED",
-1);
return {"Could not initialize Brotli instance",
"ERR_ZLIB_INITIALIZATION_FAILED",
-1};
} else {
return CompressionError {};
}
Expand All @@ -1178,25 +1178,25 @@ CompressionError BrotliDecoderContext::SetParams(int key, uint32_t value) {
if (!BrotliDecoderSetParameter(state_.get(),
static_cast<BrotliDecoderParameter>(key),
value)) {
return CompressionError("Setting parameter failed",
"ERR_BROTLI_PARAM_SET_FAILED",
-1);
return {"Setting parameter failed",
"ERR_BROTLI_PARAM_SET_FAILED",
-1};
} else {
return CompressionError {};
}
}

CompressionError BrotliDecoderContext::GetErrorInfo() const {
if (error_ != BROTLI_DECODER_NO_ERROR) {
return CompressionError("Decompression failed",
return {"Decompression failed",
error_string_.c_str(),
static_cast<int>(error_));
static_cast<int>(error_)};
} else if (flush_ == BROTLI_OPERATION_FINISH &&
last_result_ == BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT) {
// Match zlib's behaviour, as brotli doesn't have its own code for this.
return CompressionError("unexpected end of file",
"Z_BUF_ERROR",
Z_BUF_ERROR);
return {"unexpected end of file",
"Z_BUF_ERROR",
Z_BUF_ERROR};
} else {
return CompressionError {};
}
Expand Down
2 changes: 1 addition & 1 deletion src/sharedarraybuffer_metadata.cc
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ MaybeLocal<SharedArrayBuffer> SharedArrayBufferMetadata::GetSharedArrayBuffer(
contents_.ByteLength());

if (AssignToSharedArrayBuffer(env, context, obj).IsNothing())
return MaybeLocal<SharedArrayBuffer>();
return {};

return obj;
}
Expand Down
2 changes: 1 addition & 1 deletion src/spawn_sync.cc
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ MaybeLocal<Object> SyncProcessRunner::Run(Local<Value> options) {

Maybe<bool> r = TryInitializeAndRunLoop(options);
CloseHandlesAndDeleteLoop();
if (r.IsNothing()) return MaybeLocal<Object>();
if (r.IsNothing()) return {};

Local<Object> result = BuildResultObject();

Expand Down
4 changes: 2 additions & 2 deletions src/string_bytes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ MaybeLocal<Value> ExternOneByteString::NewSimpleFromCopy(Isolate* isolate,
length);
if (str.IsEmpty()) {
*error = node::ERR_STRING_TOO_LONG(isolate);
return MaybeLocal<Value>();
return {};
}
return str.ToLocalChecked();
}
Expand All @@ -193,7 +193,7 @@ MaybeLocal<Value> ExternTwoByteString::NewSimpleFromCopy(Isolate* isolate,
length);
if (str.IsEmpty()) {
*error = node::ERR_STRING_TOO_LONG(isolate);
return MaybeLocal<Value>();
return {};
}
return str.ToLocalChecked();
}
Expand Down
Loading