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/optimise-store.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/optimise-store.cc')
-rw-r--r-- | third_party/nix/src/libstore/optimise-store.cc | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/third_party/nix/src/libstore/optimise-store.cc b/third_party/nix/src/libstore/optimise-store.cc index 9eaf4cdc3c9e..d7cf2bb74449 100644 --- a/third_party/nix/src/libstore/optimise-store.cc +++ b/third_party/nix/src/libstore/optimise-store.cc @@ -18,7 +18,7 @@ namespace nix { static void makeWritable(const Path& path) { struct stat st; - if (lstat(path.c_str(), &st)) { + if (lstat(path.c_str(), &st) != 0) { throw SysError(format("getting attributes of path '%1%'") % path); } if (chmod(path.c_str(), st.st_mode | S_IWUSR) == -1) { @@ -32,7 +32,7 @@ struct MakeReadOnly { ~MakeReadOnly() { try { /* This will make the path read-only. */ - if (path != "") { + if (!path.empty()) { canonicaliseTimestampAndPermissions(path); } } catch (...) { @@ -78,7 +78,7 @@ Strings LocalStore::readDirectoryIgnoringInodes(const Path& path, while (errno = 0, dirent = readdir(dir.get())) { /* sic */ checkInterrupt(); - if (inodeHash.count(dirent->d_ino)) { + if (inodeHash.count(dirent->d_ino) != 0u) { DLOG(WARNING) << dirent->d_name << " is already linked"; continue; } @@ -101,7 +101,7 @@ void LocalStore::optimisePath_(OptimiseStats& stats, const Path& path, checkInterrupt(); struct stat st; - if (lstat(path.c_str(), &st)) { + if (lstat(path.c_str(), &st) != 0) { throw SysError(format("getting attributes of path '%1%'") % path); } @@ -137,13 +137,13 @@ void LocalStore::optimisePath_(OptimiseStats& stats, const Path& path, modified, in particular when running programs as root under NixOS (example: $fontconfig/var/cache being modified). Skip those files. FIXME: check the modification time. */ - if (S_ISREG(st.st_mode) && (st.st_mode & S_IWUSR)) { + if (S_ISREG(st.st_mode) && ((st.st_mode & S_IWUSR) != 0u)) { LOG(WARNING) << "skipping suspicious writable file '" << path << "'"; return; } /* This can still happen on top-level files. */ - if (st.st_nlink > 1 && inodeHash.count(st.st_ino)) { + if (st.st_nlink > 1 && (inodeHash.count(st.st_ino) != 0u)) { DLOG(INFO) << path << " is already linked, with " << (st.st_nlink - 2) << " other file(s)"; return; @@ -196,7 +196,7 @@ retry: /* Yes! We've seen a file with the same contents. Replace the current file with a hard link to that file. */ struct stat stLink; - if (lstat(linkPath.c_str(), &stLink)) { + if (lstat(linkPath.c_str(), &stLink) != 0) { throw SysError(format("getting attributes of path '%1%'") % linkPath); } @@ -234,7 +234,7 @@ retry: /* Too many links to the same file (>= 32000 on most file systems). This is likely to happen with empty files. Just shrug and ignore. */ - if (st.st_size) { + if (st.st_size != 0) { LOG(WARNING) << linkPath << " has maximum number of links"; } return; |