about summary refs log tree commit diff
path: root/third_party/nix/src/libstore/gc.cc
diff options
context:
space:
mode:
authorKane York <kanepyork@gmail.com>2020-08-01T22·32-0700
committerkanepyork <rikingcoding@gmail.com>2020-08-01T22·45+0000
commit72fc2fd27e8ca9ddd6dad7f1c8f508e115aa2b60 (patch)
treeeacd58ae5e0de9ffaadc265b8fd417f2f62d0433 /third_party/nix/src/libstore/gc.cc
parentcc3c45f739133162c840d500c0d633f46a524e06 (diff)
fix(3p/nix): revert "apply all clang-tidy fixes" r/1534
This reverts commit ef54f5da9fa30b5c302f2a49595ee5d041f9706a.

Resolved conflicts:
	third_party/nix/src/libexpr/eval.cc
	third_party/nix/src/libstore/builtins/fetchurl.cc
	third_party/nix/src/libstore/references.cc
	third_party/nix/src/libutil/hash.cc
	third_party/nix/src/nix-daemon/nix-daemon.cc

Change-Id: Ib9cf6e96a79a23bde3983579ced3f92e530cb011
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1547
Reviewed-by: glittershark <grfn@gws.fyi>
Tested-by: BuildkiteCI
Diffstat (limited to 'third_party/nix/src/libstore/gc.cc')
-rw-r--r--third_party/nix/src/libstore/gc.cc33
1 files changed, 16 insertions, 17 deletions
diff --git a/third_party/nix/src/libstore/gc.cc b/third_party/nix/src/libstore/gc.cc
index 85f7f1dba95d..9a6d97eb73c9 100644
--- a/third_party/nix/src/libstore/gc.cc
+++ b/third_party/nix/src/libstore/gc.cc
@@ -167,7 +167,7 @@ void LocalStore::addTempRoot(const Path& path) {
 
       /* Check whether the garbage collector didn't get in our
          way. */
-      struct stat st {};
+      struct stat st;
       if (fstat(state->fdTempRoots.get(), &st) == -1) {
         throw SysError(format("statting '%1%'") % fnTempRoots);
       }
@@ -239,10 +239,9 @@ void LocalStore::findTempRoots(FDs& fds, Roots& tempRoots, bool censor) {
 
     /* Extract the roots. */
     std::string::size_type pos = 0;
-    std::string::size_type end = 0;
+    std::string::size_type end;
 
-    while ((end = contents.find(static_cast<char>(0), pos)) !=
-           std::string::npos) {
+    while ((end = contents.find((char)0, pos)) != std::string::npos) {
       Path root(contents, pos, end - pos);
       DLOG(INFO) << "got temporary root " << root;
       assertStorePath(root);
@@ -388,7 +387,7 @@ void LocalStore::findRuntimeRoots(Roots& roots, bool censor) {
 
   auto procDir = AutoCloseDir{opendir("/proc")};
   if (procDir) {
-    struct dirent* ent = nullptr;
+    struct dirent* ent;
     auto digitsRegex = std::regex(R"(^\d+$)");
     auto mapRegex =
         std::regex(R"(^\s*\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+(/\S+)\s*$)");
@@ -408,7 +407,7 @@ void LocalStore::findRuntimeRoots(Roots& roots, bool censor) {
           }
           throw SysError(format("opening %1%") % fdStr);
         }
-        struct dirent* fd_ent = nullptr;
+        struct dirent* fd_ent;
         while (errno = 0, fd_ent = readdir(fdDir.get())) {
           if (fd_ent->d_name[0] != '.') {
             readProcLink(fmt("%s/%s", fdStr, fd_ent->d_name), unchecked);
@@ -482,11 +481,11 @@ struct LocalStore::GCState {
   PathSet tempRoots;
   PathSet dead;
   PathSet alive;
-  bool gcKeepOutputs{};
-  bool gcKeepDerivations{};
+  bool gcKeepOutputs;
+  bool gcKeepDerivations;
   unsigned long long bytesInvalidated;
   bool moveToTrash = true;
-  bool shouldDelete{};
+  bool shouldDelete;
   explicit GCState(GCResults& results_)
       : results(results_), bytesInvalidated(0) {}
 };
@@ -499,7 +498,7 @@ bool LocalStore::isActiveTempFile(const GCState& state, const Path& path,
 }
 
 void LocalStore::deleteGarbage(GCState& state, const Path& path) {
-  unsigned long long bytesFreed = 0;
+  unsigned long long bytesFreed;
   deletePath(path, bytesFreed);
   state.results.bytesFreed += bytesFreed;
 }
@@ -523,7 +522,7 @@ void LocalStore::deletePathRecursive(GCState& state, const Path& path) {
 
   Path realPath = realStoreDir + "/" + baseNameOf(path);
 
-  struct stat st {};
+  struct stat st;
   if (lstat(realPath.c_str(), &st) != 0) {
     if (errno == ENOENT) {
       return;
@@ -698,7 +697,7 @@ void LocalStore::removeUnusedLinks(const GCState& state) {
   long long actualSize = 0;
   long long unsharedSize = 0;
 
-  struct dirent* dirent = nullptr;
+  struct dirent* dirent;
   while (errno = 0, dirent = readdir(dir.get())) {
     checkInterrupt();
     std::string name = dirent->d_name;
@@ -707,7 +706,7 @@ void LocalStore::removeUnusedLinks(const GCState& state) {
     }
     Path path = linksDir + "/" + name;
 
-    struct stat st {};
+    struct stat st;
     if (lstat(path.c_str(), &st) == -1) {
       throw SysError(format("statting '%1%'") % path);
     }
@@ -727,7 +726,7 @@ void LocalStore::removeUnusedLinks(const GCState& state) {
     state.results.bytesFreed += st.st_size;
   }
 
-  struct stat st {};
+  struct stat st;
   if (stat(linksDir.c_str(), &st) == -1) {
     throw SysError(format("statting '%1%'") % linksDir);
   }
@@ -841,7 +840,7 @@ void LocalStore::collectGarbage(const GCOptions& options, GCResults& results) {
          again.  We don't use readDirectory() here so that GCing
          can start faster. */
       Paths entries;
-      struct dirent* dirent = nullptr;
+      struct dirent* dirent;
       while (errno = 0, dirent = readdir(dir.get())) {
         checkInterrupt();
         std::string name = dirent->d_name;
@@ -912,12 +911,12 @@ void LocalStore::autoGC(bool sync) {
       return std::stoll(readFile(fakeFreeSpaceFile));
     }
 
-    struct statvfs st {};
+    struct statvfs st;
     if (statvfs(realStoreDir.c_str(), &st) != 0) {
       throw SysError("getting filesystem info about '%s'", realStoreDir);
     }
 
-    return static_cast<uint64_t>(st.f_bavail) * st.f_bsize;
+    return (uint64_t)st.f_bavail * st.f_bsize;
   };
 
   std::shared_future<void> future;