about summary refs log tree commit diff
path: root/third_party/nix/src/libstore/build.cc
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-05-19T16·38+0100
committerVincent Ambo <tazjin@google.com>2020-05-19T16·38+0100
commitb490742a511dd03afc43f5143d6d61edaeeb8091 (patch)
tree727370e8e7607a3078c2ce1cd6d717105c7d9c44 /third_party/nix/src/libstore/build.cc
parentc758de9d22506eb279c5abe61f621e5c8f61af95 (diff)
style(3p/nix): Enforce braces around loops and conditionals r/767
This change was generated with:

  fd -e cc -e hh | xargs -I{} clang-tidy {} -p ~/projects/nix-build/ \
    --checks='-*,readability-braces-around-statements' --fix \
    -fix-errors

Some manual fixes were applied because some convoluted unbraced
statements couldn't be untangled by clang-tidy.

This commit still includes invalid files, but I decided to clean them
up in a subsequent commit so that it becomes more obvious where
clang-tidy failed. Maybe this will allow for a bug-report to
clang-tidy.
Diffstat (limited to 'third_party/nix/src/libstore/build.cc')
-rw-r--r--third_party/nix/src/libstore/build.cc58
1 files changed, 42 insertions, 16 deletions
diff --git a/third_party/nix/src/libstore/build.cc b/third_party/nix/src/libstore/build.cc
index 7da262206a..8257d7aff1 100644
--- a/third_party/nix/src/libstore/build.cc
+++ b/third_party/nix/src/libstore/build.cc
@@ -350,12 +350,17 @@ void Goal::waiteeDone(GoalPtr waitee, ExitCode result) {
   trace(format("waitee '%1%' done; %2% left") % waitee->name % waitees.size());
 
   if (result == ecFailed || result == ecNoSubstituters ||
-      result == ecIncompleteClosure)
+      result == ecIncompleteClosure) {
     ++nrFailed;
+  }
 
-  if (result == ecNoSubstituters) ++nrNoSubstituters;
+  if (result == ecNoSubstituters) {
+    ++nrNoSubstituters;
+  }
 
-  if (result == ecIncompleteClosure) ++nrIncompleteClosure;
+  if (result == ecIncompleteClosure) {
+    ++nrIncompleteClosure;
+  }
 
   if (waitees.empty() || (result == ecFailed && !settings.keepGoing)) {
     /* If we failed and keepGoing is not set, we remove all
@@ -1147,7 +1152,9 @@ void DerivationGoal::outputsSubstituted() {
   /*  If the substitutes form an incomplete closure, then we should
       build the dependencies of this derivation, but after that, we
       can still use the substitutes for this derivation itself. */
-  if (nrIncompleteClosure > 0) retrySubstitution = true;
+  if (nrIncompleteClosure > 0) {
+    retrySubstitution = true;
+  }
 
   nrFailed = nrNoSubstituters = nrIncompleteClosure = 0;
 
@@ -1659,7 +1666,9 @@ MakeError(NotDeterministic, BuildError)
 }
 
 HookReply DerivationGoal::tryBuildHook() {
-  if (!worker.tryBuildHook || !useDerivation) return rpDecline;
+  if (!worker.tryBuildHook || !useDerivation) {
+    return rpDecline;
+  }
 
   if (!worker.hook) worker.hook = std::make_unique<HookInstance>();
 
@@ -2231,7 +2240,9 @@ void DerivationGoal::startBuilder() {
        us.
     */
 
-    if (!fixedOutput) privateNetwork = true;
+    if (!fixedOutput) {
+      privateNetwork = true;
+    }
 
     userNamespaceSync.create();
 
@@ -3117,7 +3128,9 @@ void DerivationGoal::registerOutputs() {
     bool allValid = true;
     for (auto& i : drv->outputs)
       if (!worker.store.isValidPath(i.second.path)) allValid = false;
-    if (allValid) return;
+    if (allValid) {
+      return;
+    }
   }
 
   std::map<std::string, ValidPathInfo> infos;
@@ -3345,7 +3358,9 @@ void DerivationGoal::registerOutputs() {
     infos[i.first] = info;
   }
 
-  if (buildMode == bmCheck) return;
+  if (buildMode == bmCheck) {
+    return;
+  }
 
   /* Apply output checks. */
   checkOutputs(infos);
@@ -4095,9 +4110,10 @@ GoalPtr Worker::makeDerivationGoal(const Path& path,
         std::make_shared<DerivationGoal>(path, wantedOutputs, *this, buildMode);
     derivationGoals[path] = goal;
     wakeUp(goal);
-  } else
+  } else {
     (dynamic_cast<DerivationGoal*>(goal.get()))
         ->addWantedOutputs(wantedOutputs);
+  }
   return goal;
 }
 
@@ -4167,7 +4183,9 @@ void Worker::childStarted(GoalPtr goal, const set<int>& fds, bool inBuildSlot,
   child.inBuildSlot = inBuildSlot;
   child.respectTimeouts = respectTimeouts;
   children.emplace_back(child);
-  if (inBuildSlot) nrLocalBuilds++;
+  if (inBuildSlot) {
+    nrLocalBuilds++;
+  }
 }
 
 void Worker::childTerminated(Goal* goal, bool wakeSleepers) {
@@ -4413,14 +4431,22 @@ unsigned int Worker::exitStatus() {
    */
   unsigned int mask = 0;
   bool buildFailure = permanentFailure || timedOut || hashMismatch;
-  if (buildFailure) mask |= 0x04;  // 100
-  if (timedOut) mask |= 0x01;      // 101
-  if (hashMismatch) mask |= 0x02;  // 102
+  if (buildFailure) {
+    mask |= 0x04;  // 100
+  }
+  if (timedOut) {
+    mask |= 0x01;  // 101
+  }
+  if (hashMismatch) {
+    mask |= 0x02;  // 102
+  }
   if (checkMismatch) {
     mask |= 0x08;  // 104
   }
 
-  if (mask) mask |= 0x60;
+  if (mask) {
+    mask |= 0x60;
+  }
   return mask ? mask : 1;
 }
 
@@ -4430,9 +4456,9 @@ bool Worker::pathContentsGood(const Path& path) {
   LOG(INFO) << "checking path '" << path << "'...";
   auto info = store.queryPathInfo(path);
   bool res;
-  if (!pathExists(path))
+  if (!pathExists(path)) {
     res = false;
-  else {
+  } else {
     HashResult current = hashPath(info->narHash.type, path);
     Hash nullHash(htSHA256);
     res = info->narHash == nullHash || info->narHash == current.first;