about summary refs log tree commit diff
path: root/third_party/nix/src/libutil
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2020-08-21T02·29+0100
committertazjin <mail@tazj.in>2020-08-21T03·55+0000
commit1443298657156107704b5d9fcfa7356ee8fa8789 (patch)
tree3c4009acabdc90799d11084dbe5df58f39b90beb /third_party/nix/src/libutil
parent7edbe59c6c70cd085fc68c4317c3a71a40ac21e5 (diff)
style(tvix): Add missing braces in expressions r/1703
The previous clang-tidy invocation missed some header files, which has
now been rectified.

Change-Id: I31547754fbf52f439dc7aeefb08ab90bd50c4156
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1831
Reviewed-by: glittershark <grfn@gws.fyi>
Tested-by: BuildkiteCI
Diffstat (limited to 'third_party/nix/src/libutil')
-rw-r--r--third_party/nix/src/libutil/args.hh3
-rw-r--r--third_party/nix/src/libutil/hash.cc12
-rw-r--r--third_party/nix/src/libutil/pool.hh6
-rw-r--r--third_party/nix/src/libutil/serialise.hh3
-rw-r--r--third_party/nix/src/libutil/thread-pool.hh6
-rw-r--r--third_party/nix/src/libutil/util.cc8
-rw-r--r--third_party/nix/src/libutil/util.hh4
7 files changed, 30 insertions, 12 deletions
diff --git a/third_party/nix/src/libutil/args.hh b/third_party/nix/src/libutil/args.hh
index 3057f3d2ab46..57720439bd03 100644
--- a/third_party/nix/src/libutil/args.hh
+++ b/third_party/nix/src/libutil/args.hh
@@ -181,9 +181,10 @@ class Args {
         .arity(1)
         .handler([=](std::vector<std::string> ss) {
           I n;
-          if (!absl::SimpleAtoi(ss[0], &n))
+          if (!absl::SimpleAtoi(ss[0], &n)) {
             throw UsageError("flag '--%s' requires a integer argument",
                              longName);
+          }
           fun(n);
         });
   }
diff --git a/third_party/nix/src/libutil/hash.cc b/third_party/nix/src/libutil/hash.cc
index 9d14ad9dfe14..a2d6713f04ff 100644
--- a/third_party/nix/src/libutil/hash.cc
+++ b/third_party/nix/src/libutil/hash.cc
@@ -111,9 +111,15 @@ static std::string printHash16(const Hash& hash) {
 
 bool Hash::IsValidBase16(absl::string_view s) {
   for (char c : s) {
-    if ('0' <= c && c <= '9') continue;
-    if ('a' <= c && c <= 'f') continue;
-    if ('A' <= c && c <= 'F') continue;
+    if ('0' <= c && c <= '9') {
+      continue;
+    }
+    if ('a' <= c && c <= 'f') {
+      continue;
+    }
+    if ('A' <= c && c <= 'F') {
+      continue;
+    }
     return false;
   }
   return true;
diff --git a/third_party/nix/src/libutil/pool.hh b/third_party/nix/src/libutil/pool.hh
index 56a579b269cd..e3ea8cad5734 100644
--- a/third_party/nix/src/libutil/pool.hh
+++ b/third_party/nix/src/libutil/pool.hh
@@ -125,8 +125,9 @@ class Pool {
 
       /* If we're over the maximum number of instance, we need
          to wait until a slot becomes available. */
-      while (state_->idle.empty() && state_->inUse >= state_->max)
+      while (state_->idle.empty() && state_->inUse >= state_->max) {
         state_.wait(wakeup);
+      }
 
       while (!state_->idle.empty()) {
         auto p = state_->idle.back();
@@ -163,10 +164,11 @@ class Pool {
   void flushBad() {
     auto state_(state.lock());
     std::vector<ref<R>> left;
-    for (auto& p : state_->idle)
+    for (auto& p : state_->idle) {
       if (validator(p)) {
         left.push_back(p);
       }
+    }
     std::swap(state_->idle, left);
   }
 };
diff --git a/third_party/nix/src/libutil/serialise.hh b/third_party/nix/src/libutil/serialise.hh
index 04f672781015..bbfbe16a016c 100644
--- a/third_party/nix/src/libutil/serialise.hh
+++ b/third_party/nix/src/libutil/serialise.hh
@@ -248,9 +248,10 @@ T readNum(Source& source) {
       ((unsigned long long)buf[4] << 32) | ((unsigned long long)buf[5] << 40) |
       ((unsigned long long)buf[6] << 48) | ((unsigned long long)buf[7] << 56);
 
-  if (n > std::numeric_limits<T>::max())
+  if (n > std::numeric_limits<T>::max()) {
     throw SerialisationError("serialised integer %d is too large for type '%s'",
                              n, typeid(T).name());
+  }
 
   return (T)n;
 }
diff --git a/third_party/nix/src/libutil/thread-pool.hh b/third_party/nix/src/libutil/thread-pool.hh
index 71006238b363..48888c0688c9 100644
--- a/third_party/nix/src/libutil/thread-pool.hh
+++ b/third_party/nix/src/libutil/thread-pool.hh
@@ -90,11 +90,12 @@ void processGraph(ThreadPool& pool, const std::set<T>& nodes,
 
     {
       auto graph(graph_.lock());
-      for (auto& ref : refs)
+      for (auto& ref : refs) {
         if (graph->left.count(ref)) {
           graph->refs[node].insert(ref);
           graph->rrefs[ref].insert(node);
         }
+      }
       if (graph->refs[node].empty()) {
         goto doWork;
       }
@@ -131,8 +132,9 @@ void processGraph(ThreadPool& pool, const std::set<T>& nodes,
 
   pool.process();
 
-  if (!graph_.lock()->left.empty())
+  if (!graph_.lock()->left.empty()) {
     throw Error("graph processing incomplete (cyclic reference?)");
+  }
 }
 
 }  // namespace nix
diff --git a/third_party/nix/src/libutil/util.cc b/third_party/nix/src/libutil/util.cc
index c93570d7b0a4..67bde4ad4fe6 100644
--- a/third_party/nix/src/libutil/util.cc
+++ b/third_party/nix/src/libutil/util.cc
@@ -434,13 +434,17 @@ static void _deletePath(int parentfd, const Path& path,
 
 static void _deletePath(const Path& path, unsigned long long& bytesFreed) {
   Path dir = dirOf(path);
-  if (dir == "") dir = "/";
+  if (dir == "") {
+    dir = "/";
+  }
 
   AutoCloseFD dirfd(open(dir.c_str(), O_RDONLY));
   if (!dirfd) {
     // This really shouldn't fail silently, but it's left this way
     // for backwards compatibility.
-    if (errno == ENOENT) return;
+    if (errno == ENOENT) {
+      return;
+    }
 
     throw SysError(format("opening directory '%1%'") % path);
   }
diff --git a/third_party/nix/src/libutil/util.hh b/third_party/nix/src/libutil/util.hh
index 9331fca7f30b..b5383b6e71f8 100644
--- a/third_party/nix/src/libutil/util.hh
+++ b/third_party/nix/src/libutil/util.hh
@@ -301,7 +301,9 @@ void setInterruptThrown();
 void _interrupted();
 
 void inline checkInterrupt() {
-  if (_isInterrupted || (interruptCheck && interruptCheck())) _interrupted();
+  if (_isInterrupted || (interruptCheck && interruptCheck())) {
+    _interrupted();
+  }
 }
 
 MakeError(Interrupted, BaseError);