about summary refs log tree commit diff
path: root/third_party/nix/src/libstore
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-05-19T18·04+0100
committerVincent Ambo <tazjin@google.com>2020-05-19T18·04+0100
commit1841d93ccbe5792a17f5b9a22e65ec898c7c2668 (patch)
treef31155746ad5a21a6f10172b3edaf79b74b56819 /third_party/nix/src/libstore
parent867055133d3f487e52dd44149f76347c2c28bf10 (diff)
style(3p/nix): Add braces around single-line for-loops r/772
These were not caught by the previous clang-tidy invocation, but were
instead sorted out using amber[0] as such:

    ambr --regex 'for (\(.+\))\s([a-z].*;)' 'for $1 { $2 }'

[0]: https://github.com/dalance/amber
Diffstat (limited to 'third_party/nix/src/libstore')
-rw-r--r--third_party/nix/src/libstore/build.cc68
-rw-r--r--third_party/nix/src/libstore/builtins/buildenv.cc4
-rw-r--r--third_party/nix/src/libstore/derivations.cc12
-rw-r--r--third_party/nix/src/libstore/gc.cc12
-rw-r--r--third_party/nix/src/libstore/globals.cc4
-rw-r--r--third_party/nix/src/libstore/local-fs-store.cc4
-rw-r--r--third_party/nix/src/libstore/local-store.cc8
-rw-r--r--third_party/nix/src/libstore/misc.cc16
-rw-r--r--third_party/nix/src/libstore/nar-accessor.cc4
-rw-r--r--third_party/nix/src/libstore/nar-info.cc4
-rw-r--r--third_party/nix/src/libstore/optimise-store.cc4
-rw-r--r--third_party/nix/src/libstore/remote-store.cc8
-rw-r--r--third_party/nix/src/libstore/store-api.cc28
13 files changed, 132 insertions, 44 deletions
diff --git a/third_party/nix/src/libstore/build.cc b/third_party/nix/src/libstore/build.cc
index ff13271e66..7aa44b4755 100644
--- a/third_party/nix/src/libstore/build.cc
+++ b/third_party/nix/src/libstore/build.cc
@@ -1122,7 +1122,9 @@ void DerivationGoal::haveDerivation() {
 
   retrySubstitution = false;
 
-  for (auto& i : drv->outputs) worker.store.addTempRoot(i.second.path);
+  for (auto& i : drv->outputs) {
+    worker.store.addTempRoot(i.second.path);
+  }
 
   /* Check what outputs paths are not already valid. */
   PathSet invalidOutputs = checkPathValidity(false, buildMode == bmRepair);
@@ -1238,7 +1240,9 @@ void DerivationGoal::repairClosure() {
   }
 
   /* Filter out our own outputs (which we have already checked). */
-  for (auto& i : drv->outputs) outputClosure.erase(i.second.path);
+  for (auto& i : drv->outputs) {
+    outputClosure.erase(i.second.path);
+  }
 
   /* Get all dependencies of this derivation so that we know which
      derivation is responsible for which path in the output
@@ -1251,7 +1255,9 @@ void DerivationGoal::repairClosure() {
   for (auto& i : inputClosure)
     if (isDerivation(i)) {
       Derivation drv = worker.store.derivationFromPath(i);
-      for (auto& j : drv.outputs) outputsToDrv[j.second.path] = i;
+      for (auto& j : drv.outputs) {
+        outputsToDrv[j.second.path] = i;
+      }
     }
 
   /* Check each path (slow!). */
@@ -1389,7 +1395,9 @@ void DerivationGoal::tryToBuild() {
 
   missingPaths = drv->outputPaths();
   if (buildMode != bmCheck)
-    for (auto& i : validPaths) missingPaths.erase(i);
+    for (auto& i : validPaths) {
+      missingPaths.erase(i);
+    }
 
   /* If any of the outputs already exist but are not valid, delete
      them. */
@@ -1571,7 +1579,9 @@ MakeError(NotDeterministic, BuildError)
 
       if (!settings.verboseBuild && !logTail.empty()) {
         msg += (format("; last %d log lines:") % logTail.size()).str();
-        for (auto& line : logTail) msg += "\n  " + line;
+        for (auto& line : logTail) {
+          msg += "\n  " + line;
+        }
       }
 
       if (diskFull) {
@@ -1642,7 +1652,9 @@ MakeError(NotDeterministic, BuildError)
     }
 
     /* Delete unused redirected outputs (when doing hash rewriting). */
-    for (auto& i : redirectedOutputs) deletePath(i.second);
+    for (auto& i : redirectedOutputs) {
+      deletePath(i.second);
+    }
 
     /* Delete the chroot (if we were using one). */
     autoDelChroot.reset(); /* this runs the destructor */
@@ -1990,7 +2002,9 @@ void DerivationGoal::startBuilder() {
       } catch (Error& e) {
         throw Error(format("while processing 'sandbox-paths': %s") % e.what());
       }
-    for (auto& i : closure) dirsInChroot[i] = i;
+    for (auto& i : closure) {
+      dirsInChroot[i] = i;
+    }
 
     PathSet allowedPaths = settings.allowedImpureHostPrefixes;
 
@@ -2118,7 +2132,9 @@ void DerivationGoal::startBuilder() {
        rebuilding a path that is in settings.dirsInChroot
        (typically the dependencies of /bin/sh).  Throw them
        out. */
-    for (auto& i : drv->outputs) dirsInChroot.erase(i.second.path);
+    for (auto& i : drv->outputs) {
+      dirsInChroot.erase(i.second.path);
+    }
 
 #elif __APPLE__
     /* We don't really have any parent prep work to do (yet?)
@@ -2142,7 +2158,9 @@ void DerivationGoal::startBuilder() {
        contents of the new outputs to replace the dummy strings
        with the actual hashes. */
     if (validPaths.size() > 0)
-      for (auto& i : validPaths) addHashRewrite(i);
+      for (auto& i : validPaths) {
+        addHashRewrite(i);
+      }
 
     /* If we're repairing, then we don't want to delete the
        corrupt outputs in advance.  So rewrite them as well. */
@@ -2537,7 +2555,9 @@ void DerivationGoal::writeStructuredAttrs() {
       {
         JSONPlaceholder jsonRoot(str, true);
         PathSet storePaths;
-        for (auto& p : *i) storePaths.insert(p.get<std::string>());
+        for (auto& p : *i) {
+          storePaths.insert(p.get<std::string>());
+        }
         worker.store.pathInfoToJSON(jsonRoot, exportReferences(storePaths),
                                     false, true);
       }
@@ -2828,7 +2848,9 @@ void DerivationGoal::runChild() {
           ss.push_back("/var/run/nscd/socket");
       }
 
-      for (auto& i : ss) dirsInChroot.emplace(i, i);
+      for (auto& i : ss) {
+        dirsInChroot.emplace(i, i);
+      }
 
       /* Bind-mount all the directories from the "host"
          filesystem that we want in the chroot
@@ -3046,7 +3068,9 @@ void DerivationGoal::runChild() {
         }
 
         /* Add all our input paths to the chroot */
-        for (auto& i : inputPaths) dirsInChroot[i] = i;
+        for (auto& i : inputPaths) {
+          dirsInChroot[i] = i;
+        }
 
         /* Violations will go to the syslog if you set this. Unfortunately the
          * destination does not appear to be configurable */
@@ -3155,7 +3179,9 @@ void DerivationGoal::runChild() {
       args.push_back(builderBasename);
     }
 
-    for (auto& i : drv->args) args.push_back(rewriteStrings(i, inputRewrites));
+    for (auto& i : drv->args) {
+      args.push_back(rewriteStrings(i, inputRewrites));
+    }
 
     /* Indicate that we managed to set up the build environment. */
     writeFull(STDERR_FILENO, string("\1\n"));
@@ -3532,7 +3558,9 @@ void DerivationGoal::registerOutputs() {
      outputs, this will fail. */
   {
     ValidPathInfos infos2;
-    for (auto& i : infos) infos2.push_back(i.second);
+    for (auto& i : infos) {
+      infos2.push_back(i.second);
+    }
     worker.store.registerValidPaths(infos2);
   }
 
@@ -3579,11 +3607,15 @@ void DerivationGoal::checkOutputs(
         auto i = outputsByPath.find(path);
         if (i != outputsByPath.end()) {
           closureSize += i->second.narSize;
-          for (auto& ref : i->second.references) pathsLeft.push(ref);
+          for (auto& ref : i->second.references) {
+            pathsLeft.push(ref);
+          }
         } else {
           auto info = worker.store.queryPathInfo(path);
           closureSize += info->narSize;
-          for (auto& ref : info->references) pathsLeft.push(ref);
+          for (auto& ref : info->references) {
+            pathsLeft.push(ref);
+          }
         }
       }
 
@@ -4373,7 +4405,9 @@ void Worker::waitForAWhile(GoalPtr goal) {
 }
 
 void Worker::run(const Goals& _topGoals) {
-  for (auto& i : _topGoals) topGoals.insert(i);
+  for (auto& i : _topGoals) {
+    topGoals.insert(i);
+  }
 
   DLOG(INFO) << "entered goal loop";
 
diff --git a/third_party/nix/src/libstore/builtins/buildenv.cc b/third_party/nix/src/libstore/builtins/buildenv.cc
index e9a96a8cca..77ad722fab 100644
--- a/third_party/nix/src/libstore/builtins/buildenv.cc
+++ b/third_party/nix/src/libstore/builtins/buildenv.cc
@@ -210,7 +210,9 @@ void builtinBuildenv(const BasicDerivation& drv) {
   while (!postponed.empty()) {
     auto pkgDirs = postponed;
     postponed = FileProp{};
-    for (const auto& pkgDir : pkgDirs) addPkg(pkgDir, priorityCounter++);
+    for (const auto& pkgDir : pkgDirs) {
+      addPkg(pkgDir, priorityCounter++);
+    }
   }
 
   LOG(INFO) << "created " << symlinks << " symlinks in user environment";
diff --git a/third_party/nix/src/libstore/derivations.cc b/third_party/nix/src/libstore/derivations.cc
index 454f483d16..7a0de8f066 100644
--- a/third_party/nix/src/libstore/derivations.cc
+++ b/third_party/nix/src/libstore/derivations.cc
@@ -40,7 +40,9 @@ Path writeDerivation(ref<Store> store, const Derivation& drv,
                      const string& name, RepairFlag repair) {
   PathSet references;
   references.insert(drv.inputSrcs.begin(), drv.inputSrcs.end());
-  for (auto& i : drv.inputDrvs) references.insert(i.first);
+  for (auto& i : drv.inputDrvs) {
+    references.insert(i.first);
+  }
   /* Note that the outputs of a derivation are *not* references
      (that can be missing (of course) and should not necessarily be
      held during a garbage collection). */
@@ -359,7 +361,9 @@ bool wantOutput(const string& output, const std::set<string>& wanted) {
 
 PathSet BasicDerivation::outputPaths() const {
   PathSet paths;
-  for (auto& i : outputs) paths.insert(i.second.path);
+  for (auto& i : outputs) {
+    paths.insert(i.second.path);
+  }
   return paths;
 }
 
@@ -394,7 +398,9 @@ Sink& operator<<(Sink& out, const BasicDerivation& drv) {
     out << i.first << i.second.path << i.second.hashAlgo << i.second.hash;
   out << drv.inputSrcs << drv.platform << drv.builder << drv.args;
   out << drv.env.size();
-  for (auto& i : drv.env) out << i.first << i.second;
+  for (auto& i : drv.env) {
+    out << i.first << i.second;
+  }
   return out;
 }
 
diff --git a/third_party/nix/src/libstore/gc.cc b/third_party/nix/src/libstore/gc.cc
index 8e092f4814..c7f2a507d3 100644
--- a/third_party/nix/src/libstore/gc.cc
+++ b/third_party/nix/src/libstore/gc.cc
@@ -615,7 +615,9 @@ bool LocalStore::canReachRoot(GCState& state, PathSet& visited,
      are derivers of this path that are not garbage. */
   if (state.gcKeepOutputs) {
     PathSet derivers = queryValidDerivers(path);
-    for (auto& i : derivers) incoming.insert(i);
+    for (auto& i : derivers) {
+      incoming.insert(i);
+    }
   }
 
   for (auto& i : incoming)
@@ -775,7 +777,9 @@ void LocalStore::collectGarbage(const GCOptions& options, GCResults& results) {
   FDs fds;
   Roots tempRoots;
   findTempRoots(fds, tempRoots, true);
-  for (auto& root : tempRoots) state.tempRoots.insert(root.first);
+  for (auto& root : tempRoots) {
+    state.tempRoots.insert(root.first);
+  }
   state.roots.insert(state.tempRoots.begin(), state.tempRoots.end());
 
   /* After this point the set of roots or temporary roots cannot
@@ -852,7 +856,9 @@ void LocalStore::collectGarbage(const GCOptions& options, GCResults& results) {
       std::mt19937 gen(1);
       std::shuffle(entries_.begin(), entries_.end(), gen);
 
-      for (auto& i : entries_) tryToDelete(state, i);
+      for (auto& i : entries_) {
+        tryToDelete(state, i);
+      }
 
     } catch (GCLimitReached& e) {
     }
diff --git a/third_party/nix/src/libstore/globals.cc b/third_party/nix/src/libstore/globals.cc
index 4d502c0ade..19a0cde1ed 100644
--- a/third_party/nix/src/libstore/globals.cc
+++ b/third_party/nix/src/libstore/globals.cc
@@ -60,7 +60,9 @@ Settings::Settings()
   auto s = getEnv("NIX_REMOTE_SYSTEMS");
   if (s != "") {
     Strings ss;
-    for (auto& p : tokenizeString<Strings>(s, ":")) ss.push_back("@" + p);
+    for (auto& p : tokenizeString<Strings>(s, ":")) {
+      ss.push_back("@" + p);
+    }
     builders = concatStringsSep(" ", ss);
   }
 
diff --git a/third_party/nix/src/libstore/local-fs-store.cc b/third_party/nix/src/libstore/local-fs-store.cc
index c1efbb76d8..d9eaea2e93 100644
--- a/third_party/nix/src/libstore/local-fs-store.cc
+++ b/third_party/nix/src/libstore/local-fs-store.cc
@@ -48,7 +48,9 @@ struct LocalStoreAccessor : public FSAccessor {
     auto entries = nix::readDirectory(realPath);
 
     StringSet res;
-    for (auto& entry : entries) res.insert(entry.name);
+    for (auto& entry : entries) {
+      res.insert(entry.name);
+    }
 
     return res;
   }
diff --git a/third_party/nix/src/libstore/local-store.cc b/third_party/nix/src/libstore/local-store.cc
index 057bafd6f6..4c431b6b38 100644
--- a/third_party/nix/src/libstore/local-store.cc
+++ b/third_party/nix/src/libstore/local-store.cc
@@ -1227,7 +1227,9 @@ bool LocalStore::verifyStore(bool checkContents, RepairFlag repair) {
   AutoCloseFD fdGCLock = openGCLock(ltWrite);
 
   PathSet store;
-  for (auto& i : readDirectory(realStoreDir)) store.insert(i.name);
+  for (auto& i : readDirectory(realStoreDir)) {
+    store.insert(i.name);
+  }
 
   /* Check whether all valid paths actually exist. */
   LOG(INFO) << "checking path existence...";
@@ -1375,7 +1377,9 @@ static void makeMutable(const Path& path) {
   }
 
   if (S_ISDIR(st.st_mode)) {
-    for (auto& i : readDirectory(path)) makeMutable(path + "/" + i.name);
+    for (auto& i : readDirectory(path)) {
+      makeMutable(path + "/" + i.name);
+    }
   }
 
   /* The O_NOFOLLOW is important to prevent us from changing the
diff --git a/third_party/nix/src/libstore/misc.cc b/third_party/nix/src/libstore/misc.cc
index a907bcac97..daed88cdc9 100644
--- a/third_party/nix/src/libstore/misc.cc
+++ b/third_party/nix/src/libstore/misc.cc
@@ -53,7 +53,9 @@ void Store::computeFSClosure(const PathSet& startPaths, PathSet& paths_,
                 }
 
               if (includeOutputs)
-                for (auto& i : queryValidDerivers(path)) enqueue(i);
+                for (auto& i : queryValidDerivers(path)) {
+                  enqueue(i);
+                }
 
               if (includeDerivers && isDerivation(path))
                 for (auto& i : queryDerivationOutputs(path))
@@ -97,7 +99,9 @@ void Store::computeFSClosure(const PathSet& startPaths, PathSet& paths_,
         }});
   };
 
-  for (auto& startPath : startPaths) enqueue(startPath);
+  for (auto& startPath : startPaths) {
+    enqueue(startPath);
+  }
 
   {
     auto state(state_.lock());
@@ -251,7 +255,9 @@ void Store::queryMissing(const PathSet& targets, PathSet& willBuild_,
     }
   };
 
-  for (auto& path : targets) pool.enqueue(std::bind(doPath, path));
+  for (auto& path : targets) {
+    pool.enqueue(std::bind(doPath, path));
+  }
 
   pool.process();
 }
@@ -291,7 +297,9 @@ Paths Store::topoSortPaths(const PathSet& paths) {
     parents.erase(path);
   };
 
-  for (auto& i : paths) dfsVisit(i, nullptr);
+  for (auto& i : paths) {
+    dfsVisit(i, nullptr);
+  }
 
   return sorted;
 }
diff --git a/third_party/nix/src/libstore/nar-accessor.cc b/third_party/nix/src/libstore/nar-accessor.cc
index 0214561da4..8a57179ab3 100644
--- a/third_party/nix/src/libstore/nar-accessor.cc
+++ b/third_party/nix/src/libstore/nar-accessor.cc
@@ -178,7 +178,9 @@ struct NarAccessor : public FSAccessor {
                   path);
 
     StringSet res;
-    for (auto& child : i.children) res.insert(child.first);
+    for (auto& child : i.children) {
+      res.insert(child.first);
+    }
 
     return res;
   }
diff --git a/third_party/nix/src/libstore/nar-info.cc b/third_party/nix/src/libstore/nar-info.cc
index cbc922a7da..fa7d72c8ae 100644
--- a/third_party/nix/src/libstore/nar-info.cc
+++ b/third_party/nix/src/libstore/nar-info.cc
@@ -122,7 +122,9 @@ std::string NarInfo::to_string() const {
     res += "System: " + system + "\n";
   }
 
-  for (auto sig : sigs) res += "Sig: " + sig + "\n";
+  for (auto sig : sigs) {
+    res += "Sig: " + sig + "\n";
+  }
 
   if (!ca.empty()) {
     res += "CA: " + ca + "\n";
diff --git a/third_party/nix/src/libstore/optimise-store.cc b/third_party/nix/src/libstore/optimise-store.cc
index 450f31c59f..ad37190236 100644
--- a/third_party/nix/src/libstore/optimise-store.cc
+++ b/third_party/nix/src/libstore/optimise-store.cc
@@ -115,7 +115,9 @@ void LocalStore::optimisePath_(OptimiseStats& stats, const Path& path,
 
   if (S_ISDIR(st.st_mode)) {
     Strings names = readDirectoryIgnoringInodes(path, inodeHash);
-    for (auto& i : names) optimisePath_(stats, path + "/" + i, inodeHash);
+    for (auto& i : names) {
+      optimisePath_(stats, path + "/" + i, inodeHash);
+    }
     return;
   }
 
diff --git a/third_party/nix/src/libstore/remote-store.cc b/third_party/nix/src/libstore/remote-store.cc
index e53720b37d..e6849cb160 100644
--- a/third_party/nix/src/libstore/remote-store.cc
+++ b/third_party/nix/src/libstore/remote-store.cc
@@ -189,7 +189,9 @@ void RemoteStore::setOptions(Connection& conn) {
     overrides.erase(settings.useSubstitutes.name);
     overrides.erase(settings.showTrace.name);
     conn.to << overrides.size();
-    for (auto& i : overrides) conn.to << i.first << i.second.value;
+    for (auto& i : overrides) {
+      conn.to << i.first << i.second.value;
+    }
   }
 
   auto ex = conn.processStderr();
@@ -522,7 +524,9 @@ void RemoteStore::buildPaths(const PathSet& drvPaths, BuildMode buildMode) {
     /* For backwards compatibility with old daemons, strip output
        identifiers. */
     PathSet drvPaths2;
-    for (auto& i : drvPaths) drvPaths2.insert(string(i, 0, i.find('!')));
+    for (auto& i : drvPaths) {
+      drvPaths2.insert(string(i, 0, i.find('!')));
+    }
     conn->to << drvPaths2;
   }
   conn.processStderr();
diff --git a/third_party/nix/src/libstore/store-api.cc b/third_party/nix/src/libstore/store-api.cc
index 41eb84a812..2a7b6a1ac4 100644
--- a/third_party/nix/src/libstore/store-api.cc
+++ b/third_party/nix/src/libstore/store-api.cc
@@ -396,7 +396,9 @@ PathSet Store::queryValidPaths(const PathSet& paths,
         }});
   };
 
-  for (auto& path : paths) pool.enqueue(std::bind(doQuery, path));
+  for (auto& path : paths) {
+    pool.enqueue(std::bind(doQuery, path));
+  }
 
   pool.process();
 
@@ -434,7 +436,9 @@ string Store::makeValidityRegistration(const PathSet& paths, bool showDerivers,
 
     s += (format("%1%\n") % info->references.size()).str();
 
-    for (auto& j : info->references) s += j + "\n";
+    for (auto& j : info->references) {
+      s += j + "\n";
+    }
   }
 
   return s;
@@ -458,7 +462,9 @@ void Store::pathInfoToJSON(JSONPlaceholder& jsonOut, const PathSet& storePaths,
 
       {
         auto jsonRefs = jsonPath.list("references");
-        for (auto& ref : info->references) jsonRefs.elem(ref);
+        for (auto& ref : info->references) {
+          jsonRefs.elem(ref);
+        }
       }
 
       if (info->ca != "") {
@@ -486,7 +492,9 @@ void Store::pathInfoToJSON(JSONPlaceholder& jsonOut, const PathSet& storePaths,
 
         if (!info->sigs.empty()) {
           auto jsonSigs = jsonPath.list("signatures");
-          for (auto& sig : info->sigs) jsonSigs.elem(sig);
+          for (auto& sig : info->sigs) {
+            jsonSigs.elem(sig);
+          }
         }
 
         auto narInfo = std::dynamic_pointer_cast<const NarInfo>(
@@ -782,7 +790,9 @@ bool ValidPathInfo::checkSignature(const PublicKeys& publicKeys,
 
 Strings ValidPathInfo::shortRefs() const {
   Strings refs;
-  for (auto& r : references) refs.push_back(baseNameOf(r));
+  for (auto& r : references) {
+    refs.push_back(baseNameOf(r));
+  }
   return refs;
 }
 
@@ -918,9 +928,13 @@ std::list<ref<Store>> getDefaultSubstituters() {
       }
     };
 
-    for (auto uri : settings.substituters.get()) addStore(uri);
+    for (auto uri : settings.substituters.get()) {
+      addStore(uri);
+    }
 
-    for (auto uri : settings.extraSubstituters.get()) addStore(uri);
+    for (auto uri : settings.extraSubstituters.get()) {
+      addStore(uri);
+    }
 
     stores.sort([](ref<Store>& a, ref<Store>& b) {
       return a->getPriority() < b->getPriority();