Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichaƫl Zasso <targos@protonmail.com>2021-01-30 18:59:54 +0300
committerRich Trott <rtrott@gmail.com>2021-02-08 04:51:41 +0300
commitb346cd1760dfad560d89cb797be2cf6f9f77bb77 (patch)
treed5a8ab6889d72e8090cd5198905db8635fe37008 /src/node_file.cc
parent907d6b6b40a62c5ae831bbd7551e7c57c3a27b6b (diff)
src: avoid implicit type conversions
This fixes a bunch of C4244 ('conversion' conversion from 'type1' to 'type2', possible loss of data) MSVC warnings in the code base. PR-URL: https://github.com/nodejs/node/pull/37149 Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/node_file.cc')
-rw-r--r--src/node_file.cc34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/node_file.cc b/src/node_file.cc
index edf55e8766b..babd5e319b4 100644
--- a/src/node_file.cc
+++ b/src/node_file.cc
@@ -367,7 +367,8 @@ MaybeLocal<Promise> FileHandle::ClosePromise() {
Isolate* isolate = close->env()->isolate();
if (req->result < 0) {
HandleScope handle_scope(isolate);
- close->Reject(UVException(isolate, req->result, "close"));
+ close->Reject(
+ UVException(isolate, static_cast<int>(req->result), "close"));
} else {
close->Resolve();
}
@@ -491,7 +492,7 @@ int FileHandle::ReadStart() {
BaseObjectPtr<FileHandleReadWrap> read_wrap =
std::move(handle->current_read_);
- int result = req->result;
+ ssize_t result = req->result;
uv_buf_t buffer = read_wrap->buffer_;
uv_fs_req_cleanup(req);
@@ -555,7 +556,7 @@ int FileHandle::DoShutdown(ShutdownWrap* req_wrap) {
FileHandle* handle = static_cast<FileHandle*>(wrap->stream());
handle->AfterClose();
- int result = req->result;
+ int result = static_cast<int>(req->result);
uv_fs_req_cleanup(req);
wrap->Done(result);
}});
@@ -623,13 +624,12 @@ void FSReqAfterScope::Clear() {
// in JS for more flexibility.
void FSReqAfterScope::Reject(uv_fs_t* req) {
BaseObjectPtr<FSReqBase> wrap { wrap_ };
- Local<Value> exception =
- UVException(wrap_->env()->isolate(),
- req->result,
- wrap_->syscall(),
- nullptr,
- req->path,
- wrap_->data());
+ Local<Value> exception = UVException(wrap_->env()->isolate(),
+ static_cast<int>(req->result),
+ wrap_->syscall(),
+ nullptr,
+ req->path,
+ wrap_->data());
Clear();
wrap->Reject(exception);
}
@@ -663,11 +663,12 @@ void AfterInteger(uv_fs_t* req) {
FSReqBase* req_wrap = FSReqBase::from_req(req);
FSReqAfterScope after(req_wrap, req);
- if (req->result >= 0 && req_wrap->is_plain_open())
- req_wrap->env()->AddUnmanagedFd(req->result);
+ int result = static_cast<int>(req->result);
+ if (result >= 0 && req_wrap->is_plain_open())
+ req_wrap->env()->AddUnmanagedFd(result);
if (after.Proceed())
- req_wrap->Resolve(Integer::New(req_wrap->env()->isolate(), req->result));
+ req_wrap->Resolve(Integer::New(req_wrap->env()->isolate(), result));
}
void AfterOpenFileHandle(uv_fs_t* req) {
@@ -675,7 +676,8 @@ void AfterOpenFileHandle(uv_fs_t* req) {
FSReqAfterScope after(req_wrap, req);
if (after.Proceed()) {
- FileHandle* fd = FileHandle::New(req_wrap->binding_data(), req->result);
+ FileHandle* fd = FileHandle::New(req_wrap->binding_data(),
+ static_cast<int>(req->result));
if (fd == nullptr) return;
req_wrap->Resolve(fd->object());
}
@@ -1430,7 +1432,7 @@ int MKDirpAsync(uv_loop_t* loop,
Environment* env = req_wrap->env();
uv_loop_t* loop = env->event_loop();
std::string path = req->path;
- int err = req->result;
+ int err = static_cast<int>(req->result);
while (true) {
switch (err) {
@@ -1476,7 +1478,7 @@ int MKDirpAsync(uv_loop_t* loop,
int err = uv_fs_stat(loop, req, path.c_str(),
uv_fs_callback_t{[](uv_fs_t* req) {
FSReqBase* req_wrap = FSReqBase::from_req(req);
- int err = req->result;
+ int err = static_cast<int>(req->result);
if (reinterpret_cast<intptr_t>(req->data) == UV_EEXIST &&
req_wrap->continuation_data()->paths().size() > 0) {
if (err == 0 && S_ISDIR(req->statbuf.st_mode)) {