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 e7b507a

Browse filesBrowse files
tniessenruyadorno
authored andcommitted
src: use UNREACHABLE instead of CHECK(falsy)
Also remove some dead code following such statements. PR-URL: #46317 Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
1 parent b4ac794 commit e7b507a
Copy full SHA for e7b507a

File tree

Expand file treeCollapse file tree

9 files changed

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

9 files changed

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

‎src/cares_wrap.cc‎

Copy file name to clipboardExpand all lines: src/cares_wrap.cc
+3-4Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,7 @@ int ParseGeneralReply(
233233
status = ares_parse_ptr_reply(buf, len, nullptr, 0, AF_INET, &host);
234234
break;
235235
default:
236-
CHECK(0 && "Bad NS type");
237-
break;
236+
UNREACHABLE("Bad NS type");
238237
}
239238

240239
if (status != ARES_SUCCESS)
@@ -1578,7 +1577,7 @@ void GetAddrInfo(const FunctionCallbackInfo<Value>& args) {
15781577
family = AF_INET6;
15791578
break;
15801579
default:
1581-
CHECK(0 && "bad address family");
1580+
UNREACHABLE("bad address family");
15821581
}
15831582

15841583
auto req_wrap = std::make_unique<GetAddrInfoReqWrap>(env,
@@ -1736,7 +1735,7 @@ void SetServers(const FunctionCallbackInfo<Value>& args) {
17361735
err = uv_inet_pton(AF_INET6, *ip, &cur->addr);
17371736
break;
17381737
default:
1739-
CHECK(0 && "Bad address family.");
1738+
UNREACHABLE("Bad address family");
17401739
}
17411740

17421741
if (err)
Collapse file

‎src/crypto/crypto_bio.cc‎

Copy file name to clipboardExpand all lines: src/crypto/crypto_bio.cc
+2-5Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,9 @@ long NodeBIO::Ctrl(BIO* bio, int cmd, long num, // NOLINT(runtime/int)
190190
*reinterpret_cast<void**>(ptr) = nullptr;
191191
break;
192192
case BIO_C_SET_BUF_MEM:
193-
CHECK(0 && "Can't use SET_BUF_MEM_PTR with NodeBIO");
194-
break;
193+
UNREACHABLE("Can't use SET_BUF_MEM_PTR with NodeBIO");
195194
case BIO_C_GET_BUF_MEM_PTR:
196-
CHECK(0 && "Can't use GET_BUF_MEM_PTR with NodeBIO");
197-
ret = 0;
198-
break;
195+
UNREACHABLE("Can't use GET_BUF_MEM_PTR with NodeBIO");
199196
case BIO_CTRL_GET_CLOSE:
200197
ret = BIO_get_shutdown(bio);
201198
break;
Collapse file

‎src/crypto/crypto_keys.cc‎

Copy file name to clipboardExpand all lines: src/crypto/crypto_keys.cc
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1393,7 +1393,7 @@ BaseObjectPtr<BaseObject> NativeKeyObject::KeyObjectTransferData::Deserialize(
13931393
key_ctor = env->crypto_key_object_private_constructor();
13941394
break;
13951395
default:
1396-
CHECK(false);
1396+
UNREACHABLE();
13971397
}
13981398

13991399
Local<Value> key;
Collapse file

‎src/debug_utils.cc‎

Copy file name to clipboardExpand all lines: src/debug_utils.cc
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ void CheckedUvLoopClose(uv_loop_t* loop) {
321321

322322
fflush(stderr);
323323
// Finally, abort.
324-
CHECK(0 && "uv_loop_close() while having open handles");
324+
UNREACHABLE("uv_loop_close() while having open handles");
325325
}
326326

327327
void PrintLibuvHandleInformation(uv_loop_t* loop, FILE* stream) {
Collapse file

‎src/fs_event_wrap.cc‎

Copy file name to clipboardExpand all lines: src/fs_event_wrap.cc
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ void FSEventWrap::OnEvent(uv_fs_event_t* handle, const char* filename,
204204
} else if (events & UV_CHANGE) {
205205
event_string = env->change_string();
206206
} else {
207-
CHECK(0 && "bad fs events flag");
207+
UNREACHABLE("bad fs events flag");
208208
}
209209

210210
Local<Value> argv[] = {
Collapse file

‎src/node_zlib.cc‎

Copy file name to clipboardExpand all lines: src/node_zlib.cc
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ class CompressionStream : public AsyncWrap, public ThreadPoolWork {
313313
flush != Z_FULL_FLUSH &&
314314
flush != Z_FINISH &&
315315
flush != Z_BLOCK) {
316-
CHECK(0 && "Invalid flush value");
316+
UNREACHABLE("Invalid flush value");
317317
}
318318

319319
if (args[1]->IsNull()) {
@@ -814,7 +814,7 @@ void ZlibContext::DoThreadPoolWork() {
814814

815815
break;
816816
default:
817-
CHECK(0 && "invalid number of gzip magic number bytes read");
817+
UNREACHABLE("invalid number of gzip magic number bytes read");
818818
}
819819

820820
[[fallthrough]];
Collapse file

‎src/spawn_sync.cc‎

Copy file name to clipboardExpand all lines: src/spawn_sync.cc
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -931,8 +931,7 @@ int SyncProcessRunner::ParseStdioOption(int child_fd,
931931
return AddStdioInheritFD(child_fd, inherit_fd);
932932

933933
} else {
934-
CHECK(0 && "invalid child stdio type");
935-
return UV_EINVAL;
934+
UNREACHABLE("invalid child stdio type");
936935
}
937936
}
938937

Collapse file

‎src/string_bytes.cc‎

Copy file name to clipboardExpand all lines: src/string_bytes.cc
+2-4Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,7 @@ size_t StringBytes::Write(Isolate* isolate,
368368
break;
369369

370370
default:
371-
CHECK(0 && "unknown encoding");
372-
break;
371+
UNREACHABLE("unknown encoding");
373372
}
374373

375374
return nbytes;
@@ -423,8 +422,7 @@ Maybe<size_t> StringBytes::StorageSize(Isolate* isolate,
423422
break;
424423

425424
default:
426-
CHECK(0 && "unknown encoding");
427-
break;
425+
UNREACHABLE("unknown encoding");
428426
}
429427

430428
return Just(data_size);
Collapse file

‎src/udp_wrap.cc‎

Copy file name to clipboardExpand all lines: src/udp_wrap.cc
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ int sockaddr_for_family(int address_family,
233233
case AF_INET6:
234234
return uv_ip6_addr(address, port, reinterpret_cast<sockaddr_in6*>(addr));
235235
default:
236-
CHECK(0 && "unexpected address family");
236+
UNREACHABLE("unexpected address family");
237237
}
238238
}
239239

0 commit comments

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