diff --git a/src/node_api.cc b/src/node_api.cc index bfc0c12aad2e77..fa68323b3c1777 100644 --- a/src/node_api.cc +++ b/src/node_api.cc @@ -7,6 +7,8 @@ #include "node_errors.h" #include "node_internals.h" +#include + struct node_napi_env__ : public napi_env__ { explicit node_napi_env__(v8::Local context): napi_env__(context) { @@ -220,9 +222,9 @@ class ThreadSafeFunction : public node::AsyncResource { if (uv_async_init(loop, &async, AsyncCb) == 0) { if (max_queue_size > 0) { - cond.reset(new node::ConditionVariable); + cond = std::make_unique(); } - if ((max_queue_size == 0 || cond.get() != nullptr) && + if ((max_queue_size == 0 || cond) && uv_idle_init(loop, &idle) == 0) { return napi_ok; } @@ -809,15 +811,15 @@ namespace uvimpl { static napi_status ConvertUVErrorCode(int code) { switch (code) { - case 0: - return napi_ok; - case UV_EINVAL: - return napi_invalid_arg; - case UV_ECANCELED: - return napi_cancelled; + case 0: + return napi_ok; + case UV_EINVAL: + return napi_invalid_arg; + case UV_ECANCELED: + return napi_cancelled; + default: + return napi_generic_failure; } - - return napi_generic_failure; } // Wrapper around uv_work_t which calls user-provided callbacks. diff --git a/src/node_crypto_bio.cc b/src/node_crypto_bio.cc index 4a71338edff571..2a3ed936f89321 100644 --- a/src/node_crypto_bio.cc +++ b/src/node_crypto_bio.cc @@ -427,9 +427,7 @@ char* NodeBIO::PeekWritable(size_t* size) { TryAllocateForWrite(*size); size_t available = write_head_->len_ - write_head_->write_pos_; - if (*size != 0 && available > *size) - available = *size; - else + if (*size == 0 || available <= *size) *size = available; return write_head_->data_ + write_head_->write_pos_; diff --git a/src/node_file.cc b/src/node_file.cc index f4106ce6477678..137cac72793338 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -1659,7 +1659,7 @@ static void WriteBuffer(const FunctionCallbackInfo& args) { const int64_t pos = GET_OFFSET(args[4]); char* buf = buffer_data + off; - uv_buf_t uvbuf = uv_buf_init(const_cast(buf), len); + uv_buf_t uvbuf = uv_buf_init(buf, len); FSReqBase* req_wrap_async = GetReqWrap(env, args[5]); if (req_wrap_async != nullptr) { // write(fd, buffer, off, len, pos, req) @@ -1858,7 +1858,7 @@ static void Read(const FunctionCallbackInfo& args) { const int64_t pos = args[4].As()->Value(); char* buf = buffer_data + off; - uv_buf_t uvbuf = uv_buf_init(const_cast(buf), len); + uv_buf_t uvbuf = uv_buf_init(buf, len); FSReqBase* req_wrap_async = GetReqWrap(env, args[5]); if (req_wrap_async != nullptr) { // read(fd, buffer, offset, len, pos, req) @@ -2113,7 +2113,7 @@ static void Mkdtemp(const FunctionCallbackInfo& args) { SyncCall(env, args[3], &req_wrap_sync, "mkdtemp", uv_fs_mkdtemp, *tmpl); FS_SYNC_TRACE_END(mkdtemp); - const char* path = static_cast(req_wrap_sync.req.path); + const char* path = req_wrap_sync.req.path; Local error; MaybeLocal rc =