Skip to content

Commit

Permalink
src: clean clang-tidy errors in node_file.h
Browse files Browse the repository at this point in the history
* explicitly delete move overloads
* default initialize all members
* explicitly discard unused return values
* const some possibles

PR-URL: #23793
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
  • Loading branch information
refack authored and rvagg committed Nov 28, 2018
1 parent 260d777 commit 74c0a97
Showing 1 changed file with 29 additions and 12 deletions.
41 changes: 29 additions & 12 deletions src/node_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class FSContinuationData : public MemoryRetainer {

uv_fs_t* req;
int mode;
std::vector<std::string> paths;
std::vector<std::string> paths{};

void PushPath(std::string&& path) {
paths.emplace_back(std::move(path));
Expand Down Expand Up @@ -244,9 +244,10 @@ class FSReqPromise : public FSReqBase {
AsyncWrap::PROVIDER_FSREQPROMISE,
use_bigint),
stats_field_array_(env->isolate(), kFsStatsFieldsNumber) {
auto resolver = Promise::Resolver::New(env->context()).ToLocalChecked();
object()->Set(env->context(), env->promise_string(),
resolver).FromJust();
const auto resolver =
Promise::Resolver::New(env->context()).ToLocalChecked();
USE(object()->Set(env->context(), env->promise_string(),
resolver).FromJust());
}

~FSReqPromise() override {
Expand All @@ -262,7 +263,7 @@ class FSReqPromise : public FSReqBase {
object()->Get(env()->context(),
env()->promise_string()).ToLocalChecked();
Local<Promise::Resolver> resolver = value.As<Promise::Resolver>();
resolver->Reject(env()->context(), reject).FromJust();
USE(resolver->Reject(env()->context(), reject).FromJust());
}

void Resolve(Local<Value> value) override {
Expand All @@ -273,7 +274,7 @@ class FSReqPromise : public FSReqBase {
object()->Get(env()->context(),
env()->promise_string()).ToLocalChecked();
Local<Promise::Resolver> resolver = val.As<Promise::Resolver>();
resolver->Resolve(env()->context(), value).FromJust();
USE(resolver->Resolve(env()->context(), value).FromJust());
}

void ResolveStat(const uv_stat_t* stat) override {
Expand All @@ -297,10 +298,14 @@ class FSReqPromise : public FSReqBase {
SET_MEMORY_INFO_NAME(FSReqPromise)
SET_SELF_SIZE(FSReqPromise)

FSReqPromise(const FSReqPromise&) = delete;
FSReqPromise& operator=(const FSReqPromise&) = delete;
FSReqPromise(const FSReqPromise&&) = delete;
FSReqPromise& operator=(const FSReqPromise&&) = delete;

private:
bool finished_ = false;
AliasedBuffer<NativeT, V8T> stats_field_array_;
DISALLOW_COPY_AND_ASSIGN(FSReqPromise);
};

class FSReqAfterScope {
Expand All @@ -312,6 +317,11 @@ class FSReqAfterScope {

void Reject(uv_fs_t* req);

FSReqAfterScope(const FSReqAfterScope&) = delete;
FSReqAfterScope& operator=(const FSReqAfterScope&) = delete;
FSReqAfterScope(const FSReqAfterScope&&) = delete;
FSReqAfterScope& operator=(const FSReqAfterScope&&) = delete;

private:
FSReqBase* wrap_ = nullptr;
uv_fs_t* req_ = nullptr;
Expand Down Expand Up @@ -388,6 +398,11 @@ class FileHandle : public AsyncWrap, public StreamBase {
SET_MEMORY_INFO_NAME(FileHandle)
SET_SELF_SIZE(FileHandle)

FileHandle(const FileHandle&) = delete;
FileHandle& operator=(const FileHandle&) = delete;
FileHandle(const FileHandle&&) = delete;
FileHandle& operator=(const FileHandle&&) = delete;

private:
// Synchronous close that emits a warning
void Close();
Expand Down Expand Up @@ -430,9 +445,14 @@ class FileHandle : public AsyncWrap, public StreamBase {
return static_cast<CloseReq*>(ReqWrap::from_req(req));
}

CloseReq(const CloseReq&) = delete;
CloseReq& operator=(const CloseReq&) = delete;
CloseReq(const CloseReq&&) = delete;
CloseReq& operator=(const CloseReq&&) = delete;

private:
Persistent<Promise> promise_;
Persistent<Value> ref_;
Persistent<Promise> promise_{};
Persistent<Value> ref_{};
};

// Asynchronous close
Expand All @@ -446,9 +466,6 @@ class FileHandle : public AsyncWrap, public StreamBase {

bool reading_ = false;
std::unique_ptr<FileHandleReadWrap> current_read_ = nullptr;


DISALLOW_COPY_AND_ASSIGN(FileHandle);
};

} // namespace fs
Expand Down

0 comments on commit 74c0a97

Please sign in to comment.