diff options
author | Vincent Ambo <tazjin@google.com> | 2020-05-20T21·27+0100 |
---|---|---|
committer | Vincent Ambo <tazjin@google.com> | 2020-05-20T21·27+0100 |
commit | 689ef502f5b0655c9923ed77da2ae3504630f473 (patch) | |
tree | 3e331c153646f136875f047cc3b9f0aad8c86341 /third_party/nix/src/libstore/gc.cc | |
parent | d331d3a0b5c497a46e2636f308234be66566c04c (diff) |
refactor(3p/nix): Apply clang-tidy's readability-* fixes r/788
This applies the readability fixes listed here: https://clang.llvm.org/extra/clang-tidy/checks/list.html
Diffstat (limited to 'third_party/nix/src/libstore/gc.cc')
-rw-r--r-- | third_party/nix/src/libstore/gc.cc | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/third_party/nix/src/libstore/gc.cc b/third_party/nix/src/libstore/gc.cc index a0c84dc0a518..bc3393265e48 100644 --- a/third_party/nix/src/libstore/gc.cc +++ b/third_party/nix/src/libstore/gc.cc @@ -236,7 +236,8 @@ void LocalStore::findTempRoots(FDs& fds, Roots& tempRoots, bool censor) { string contents = readFile(fd->get()); /* Extract the roots. */ - string::size_type pos = 0, end; + string::size_type pos = 0; + string::size_type end; while ((end = contents.find((char)0, pos)) != string::npos) { Path root(contents, pos, end - pos); @@ -542,7 +543,7 @@ void LocalStore::deletePathRecursive(GCState& state, const Path& path) { Path realPath = realStoreDir + "/" + baseNameOf(path); struct stat st; - if (lstat(realPath.c_str(), &st)) { + if (lstat(realPath.c_str(), &st) != 0) { if (errno == ENOENT) { return; } @@ -567,7 +568,7 @@ void LocalStore::deletePathRecursive(GCState& state, const Path& path) { throw SysError(format("making '%1%' writable") % realPath); } Path tmp = trashDir + "/" + baseNameOf(path); - if (rename(realPath.c_str(), tmp.c_str())) { + if (rename(realPath.c_str(), tmp.c_str()) != 0) { throw SysError(format("unable to rename '%1%' to '%2%'") % realPath % tmp); } @@ -593,19 +594,19 @@ void LocalStore::deletePathRecursive(GCState& state, const Path& path) { bool LocalStore::canReachRoot(GCState& state, PathSet& visited, const Path& path) { - if (visited.count(path)) { + if (visited.count(path) != 0u) { return false; } - if (state.alive.count(path)) { + if (state.alive.count(path) != 0u) { return true; } - if (state.dead.count(path)) { + if (state.dead.count(path) != 0u) { return false; } - if (state.roots.count(path)) { + if (state.roots.count(path) != 0u) { DLOG(INFO) << "cannot delete '" << path << "' because it's a root"; state.alive.insert(path); return true; @@ -713,7 +714,8 @@ void LocalStore::removeUnusedLinks(const GCState& state) { throw SysError(format("opening directory '%1%'") % linksDir); } - long long actualSize = 0, unsharedSize = 0; + long long actualSize = 0; + long long unsharedSize = 0; struct dirent* dirent; while (errno = 0, dirent = readdir(dir.get())) { @@ -930,7 +932,7 @@ void LocalStore::autoGC(bool sync) { } struct statvfs st; - if (statvfs(realStoreDir.c_str(), &st)) { + if (statvfs(realStoreDir.c_str(), &st) != 0) { throw SysError("getting filesystem info about '%s'", realStoreDir); } |