Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit aa3fd2f

Browse filesBrowse files
jasnelladuh95
authored andcommitted
src: make some minor ToLocalChecked cleanups
PR-URL: #56483 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent 7dd8165 commit aa3fd2f
Copy full SHA for aa3fd2f

File tree

Expand file treeCollapse file tree

1 file changed

+27
-21
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+27
-21
lines changed
Open diff view settings
Collapse file

‎src/cares_wrap.cc‎

Copy file name to clipboardExpand all lines: src/cares_wrap.cc
+27-21Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1580,15 +1580,16 @@ void ConvertIpv6StringToBuffer(const FunctionCallbackInfo<Value>& args) {
15801580

15811581
if (uv_inet_pton(AF_INET6, *ip, dst) != 0) {
15821582
isolate->ThrowException(Exception::Error(
1583-
String::NewFromUtf8(isolate, "Invalid IPv6 address").ToLocalChecked()));
1583+
FIXED_ONE_BYTE_STRING(isolate, "Invalid IPv6 address")));
15841584
return;
15851585
}
15861586

1587-
Local<Object> buffer =
1588-
node::Buffer::Copy(
1587+
Local<Object> buffer;
1588+
if (node::Buffer::Copy(
15891589
isolate, reinterpret_cast<const char*>(dst), sizeof(dst))
1590-
.ToLocalChecked();
1591-
args.GetReturnValue().Set(buffer);
1590+
.ToLocal(&buffer)) {
1591+
args.GetReturnValue().Set(buffer);
1592+
}
15921593
}
15931594

15941595
void GetAddrInfo(const FunctionCallbackInfo<Value>& args) {
@@ -1750,22 +1751,27 @@ void SetServers(const FunctionCallbackInfo<Value>& args) {
17501751
int err;
17511752

17521753
for (uint32_t i = 0; i < len; i++) {
1753-
CHECK(arr->Get(env->context(), i).ToLocalChecked()->IsArray());
1754-
1755-
Local<Array> elm = arr->Get(env->context(), i).ToLocalChecked().As<Array>();
1756-
1757-
CHECK(elm->Get(env->context(),
1758-
0).ToLocalChecked()->Int32Value(env->context()).FromJust());
1759-
CHECK(elm->Get(env->context(), 1).ToLocalChecked()->IsString());
1760-
CHECK(elm->Get(env->context(),
1761-
2).ToLocalChecked()->Int32Value(env->context()).FromJust());
1762-
1763-
int fam = elm->Get(env->context(), 0)
1764-
.ToLocalChecked()->Int32Value(env->context()).FromJust();
1765-
node::Utf8Value ip(env->isolate(),
1766-
elm->Get(env->context(), 1).ToLocalChecked());
1767-
int port = elm->Get(env->context(), 2)
1768-
.ToLocalChecked()->Int32Value(env->context()).FromJust();
1754+
Local<Value> val;
1755+
if (!arr->Get(env->context(), i).ToLocal(&val)) return;
1756+
CHECK(val->IsArray());
1757+
1758+
Local<Array> elm = val.As<Array>();
1759+
1760+
Local<Value> familyValue;
1761+
Local<Value> ipValue;
1762+
Local<Value> portValue;
1763+
1764+
if (!elm->Get(env->context(), 0).ToLocal(&familyValue)) return;
1765+
if (!elm->Get(env->context(), 1).ToLocal(&ipValue)) return;
1766+
if (!elm->Get(env->context(), 2).ToLocal(&portValue)) return;
1767+
1768+
CHECK(familyValue->Int32Value(env->context()).FromJust());
1769+
CHECK(ipValue->IsString());
1770+
CHECK(portValue->Int32Value(env->context()).FromJust());
1771+
1772+
int fam = familyValue->Int32Value(env->context()).FromJust();
1773+
node::Utf8Value ip(env->isolate(), ipValue);
1774+
int port = portValue->Int32Value(env->context()).FromJust();
17691775

17701776
ares_addr_port_node* cur = &servers[i];
17711777

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.