about summary refs log tree commit diff
path: root/third_party/nix/src/libstore/builtins/buildenv.cc
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-05-19T17·55+0100
committerVincent Ambo <tazjin@google.com>2020-05-19T17·55+0100
commit867055133d3f487e52dd44149f76347c2c28bf10 (patch)
treec367803ad94f024b0052727a2c7a037af169169a /third_party/nix/src/libstore/builtins/buildenv.cc
parentc6a31838cd7e88ebcb01422b329a499d04ab4b6b (diff)
style(3p/nix): Add braces around single-line conditionals r/771
These were not caught by the previous clang-tidy invocation, but were
instead sorted out using amber[0] as such:

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

[0]: https://github.com/dalance/amber
Diffstat (limited to 'third_party/nix/src/libstore/builtins/buildenv.cc')
-rw-r--r--third_party/nix/src/libstore/builtins/buildenv.cc24
1 files changed, 18 insertions, 6 deletions
diff --git a/third_party/nix/src/libstore/builtins/buildenv.cc b/third_party/nix/src/libstore/builtins/buildenv.cc
index fd7d7e979f..e9a96a8cca 100644
--- a/third_party/nix/src/libstore/builtins/buildenv.cc
+++ b/third_party/nix/src/libstore/builtins/buildenv.cc
@@ -99,7 +99,9 @@ static void createLinks(const Path& srcDir, const Path& dstDir, int priority) {
                 "to change the priority of one of the conflicting packages"
                 " (0 being the highest priority)",
                 srcFile, readLink(dstFile), priority);
-          if (prevPriority < priority) continue;
+          if (prevPriority < priority) {
+            continue;
+          }
           if (unlink(dstFile.c_str()) == -1)
             throw SysError(format("unlinking '%1%'") % dstFile);
         } else if (S_ISDIR(dstSt.st_mode))
@@ -124,7 +126,9 @@ static FileProp postponed = FileProp{};
 static Path out;
 
 static void addPkg(const Path& pkgDir, int priority) {
-  if (done.count(pkgDir)) return;
+  if (done.count(pkgDir)) {
+    return;
+  }
   done.insert(pkgDir);
   createLinks(pkgDir, out, priority);
 
@@ -132,9 +136,13 @@ static void addPkg(const Path& pkgDir, int priority) {
     for (const auto& p : tokenizeString<std::vector<string>>(
              readFile(pkgDir + "/nix-support/propagated-user-env-packages"),
              " \n"))
-      if (!done.count(p)) postponed.insert(p);
+      if (!done.count(p)) {
+        postponed.insert(p);
+      }
   } catch (SysError& e) {
-    if (e.errNo != ENOENT && e.errNo != ENOTDIR) throw;
+    if (e.errNo != ENOENT && e.errNo != ENOTDIR) {
+      throw;
+    }
   }
 }
 
@@ -151,7 +159,9 @@ typedef std::vector<Package> Packages;
 void builtinBuildenv(const BasicDerivation& drv) {
   auto getAttr = [&](const string& name) {
     auto i = drv.env.find(name);
-    if (i == drv.env.end()) throw Error("attribute '%s' missing", name);
+    if (i == drv.env.end()) {
+      throw Error("attribute '%s' missing", name);
+    }
     return i->second;
   };
 
@@ -187,7 +197,9 @@ void builtinBuildenv(const BasicDerivation& drv) {
            (a.priority == b.priority && a.path < b.path);
   });
   for (const auto& pkg : pkgs)
-    if (pkg.active) addPkg(pkg.path, pkg.priority);
+    if (pkg.active) {
+      addPkg(pkg.path, pkg.priority);
+    }
 
   /* Symlink to the packages that have been "propagated" by packages
    * installed by the user (i.e., package X declares that it wants Y