mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
src: use UNREACHABLE instead of CHECK(falsy)
Also remove some dead code following such statements. PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
@@ -233,8 +233,7 @@ int ParseGeneralReply(
|
||||
status = ares_parse_ptr_reply(buf, len, nullptr, 0, AF_INET, &host);
|
||||
break;
|
||||
default:
|
||||
CHECK(0 && "Bad NS type");
|
||||
break;
|
||||
UNREACHABLE("Bad NS type");
|
||||
}
|
||||
|
||||
if (status != ARES_SUCCESS)
|
||||
@@ -1578,7 +1577,7 @@ void GetAddrInfo(const FunctionCallbackInfo<Value>& args) {
|
||||
family = AF_INET6;
|
||||
break;
|
||||
default:
|
||||
CHECK(0 && "bad address family");
|
||||
UNREACHABLE("bad address family");
|
||||
}
|
||||
|
||||
auto req_wrap = std::make_unique<GetAddrInfoReqWrap>(env,
|
||||
@@ -1736,7 +1735,7 @@ void SetServers(const FunctionCallbackInfo<Value>& args) {
|
||||
err = uv_inet_pton(AF_INET6, *ip, &cur->addr);
|
||||
break;
|
||||
default:
|
||||
CHECK(0 && "Bad address family.");
|
||||
UNREACHABLE("Bad address family");
|
||||
}
|
||||
|
||||
if (err)
|
||||
|
||||
@@ -190,12 +190,9 @@ long NodeBIO::Ctrl(BIO* bio, int cmd, long num, // NOLINT(runtime/int)
|
||||
*reinterpret_cast<void**>(ptr) = nullptr;
|
||||
break;
|
||||
case BIO_C_SET_BUF_MEM:
|
||||
CHECK(0 && "Can't use SET_BUF_MEM_PTR with NodeBIO");
|
||||
break;
|
||||
UNREACHABLE("Can't use SET_BUF_MEM_PTR with NodeBIO");
|
||||
case BIO_C_GET_BUF_MEM_PTR:
|
||||
CHECK(0 && "Can't use GET_BUF_MEM_PTR with NodeBIO");
|
||||
ret = 0;
|
||||
break;
|
||||
UNREACHABLE("Can't use GET_BUF_MEM_PTR with NodeBIO");
|
||||
case BIO_CTRL_GET_CLOSE:
|
||||
ret = BIO_get_shutdown(bio);
|
||||
break;
|
||||
|
||||
@@ -1393,7 +1393,7 @@ BaseObjectPtr<BaseObject> NativeKeyObject::KeyObjectTransferData::Deserialize(
|
||||
key_ctor = env->crypto_key_object_private_constructor();
|
||||
break;
|
||||
default:
|
||||
CHECK(false);
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
Local<Value> key;
|
||||
|
||||
@@ -321,7 +321,7 @@ void CheckedUvLoopClose(uv_loop_t* loop) {
|
||||
|
||||
fflush(stderr);
|
||||
// Finally, abort.
|
||||
CHECK(0 && "uv_loop_close() while having open handles");
|
||||
UNREACHABLE("uv_loop_close() while having open handles");
|
||||
}
|
||||
|
||||
void PrintLibuvHandleInformation(uv_loop_t* loop, FILE* stream) {
|
||||
|
||||
@@ -204,7 +204,7 @@ void FSEventWrap::OnEvent(uv_fs_event_t* handle, const char* filename,
|
||||
} else if (events & UV_CHANGE) {
|
||||
event_string = env->change_string();
|
||||
} else {
|
||||
CHECK(0 && "bad fs events flag");
|
||||
UNREACHABLE("bad fs events flag");
|
||||
}
|
||||
|
||||
Local<Value> argv[] = {
|
||||
|
||||
@@ -313,7 +313,7 @@ class CompressionStream : public AsyncWrap, public ThreadPoolWork {
|
||||
flush != Z_FULL_FLUSH &&
|
||||
flush != Z_FINISH &&
|
||||
flush != Z_BLOCK) {
|
||||
CHECK(0 && "Invalid flush value");
|
||||
UNREACHABLE("Invalid flush value");
|
||||
}
|
||||
|
||||
if (args[1]->IsNull()) {
|
||||
@@ -814,7 +814,7 @@ void ZlibContext::DoThreadPoolWork() {
|
||||
|
||||
break;
|
||||
default:
|
||||
CHECK(0 && "invalid number of gzip magic number bytes read");
|
||||
UNREACHABLE("invalid number of gzip magic number bytes read");
|
||||
}
|
||||
|
||||
[[fallthrough]];
|
||||
|
||||
@@ -931,8 +931,7 @@ int SyncProcessRunner::ParseStdioOption(int child_fd,
|
||||
return AddStdioInheritFD(child_fd, inherit_fd);
|
||||
|
||||
} else {
|
||||
CHECK(0 && "invalid child stdio type");
|
||||
return UV_EINVAL;
|
||||
UNREACHABLE("invalid child stdio type");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -368,8 +368,7 @@ size_t StringBytes::Write(Isolate* isolate,
|
||||
break;
|
||||
|
||||
default:
|
||||
CHECK(0 && "unknown encoding");
|
||||
break;
|
||||
UNREACHABLE("unknown encoding");
|
||||
}
|
||||
|
||||
return nbytes;
|
||||
@@ -423,8 +422,7 @@ Maybe<size_t> StringBytes::StorageSize(Isolate* isolate,
|
||||
break;
|
||||
|
||||
default:
|
||||
CHECK(0 && "unknown encoding");
|
||||
break;
|
||||
UNREACHABLE("unknown encoding");
|
||||
}
|
||||
|
||||
return Just(data_size);
|
||||
|
||||
@@ -233,7 +233,7 @@ int sockaddr_for_family(int address_family,
|
||||
case AF_INET6:
|
||||
return uv_ip6_addr(address, port, reinterpret_cast<sockaddr_in6*>(addr));
|
||||
default:
|
||||
CHECK(0 && "unexpected address family");
|
||||
UNREACHABLE("unexpected address family");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user