Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions src/node_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include "node_errors.h"
#include "node_internals.h"

#include <memory>

struct node_napi_env__ : public napi_env__ {
explicit node_napi_env__(v8::Local<v8::Context> context):
napi_env__(context) {
Expand Down Expand Up @@ -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<node::ConditionVariable>();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am thinking apply this rule https://clang.llvm.org/extra/clang-tidy/checks/modernize-make-unique.html to whole repo, thoughts ?

cc @addaleax @refack

}
if ((max_queue_size == 0 || cond.get() != nullptr) &&
if ((max_queue_size == 0 || cond) &&
uv_idle_init(loop, &idle) == 0) {
return napi_ok;
}
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 1 addition & 3 deletions src/node_crypto_bio.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand Down
6 changes: 3 additions & 3 deletions src/node_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1659,7 +1659,7 @@ static void WriteBuffer(const FunctionCallbackInfo<Value>& args) {
const int64_t pos = GET_OFFSET(args[4]);

char* buf = buffer_data + off;
uv_buf_t uvbuf = uv_buf_init(const_cast<char*>(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)
Expand Down Expand Up @@ -1858,7 +1858,7 @@ static void Read(const FunctionCallbackInfo<Value>& args) {
const int64_t pos = args[4].As<Integer>()->Value();

char* buf = buffer_data + off;
uv_buf_t uvbuf = uv_buf_init(const_cast<char*>(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)
Expand Down Expand Up @@ -2113,7 +2113,7 @@ static void Mkdtemp(const FunctionCallbackInfo<Value>& args) {
SyncCall(env, args[3], &req_wrap_sync, "mkdtemp",
uv_fs_mkdtemp, *tmpl);
FS_SYNC_TRACE_END(mkdtemp);
const char* path = static_cast<const char*>(req_wrap_sync.req.path);
const char* path = req_wrap_sync.req.path;

Local<Value> error;
MaybeLocal<Value> rc =
Expand Down