diff options
author | Vincent Ambo <mail@tazj.in> | 2020-08-21T02·29+0100 |
---|---|---|
committer | tazjin <mail@tazj.in> | 2020-08-21T03·55+0000 |
commit | 1443298657156107704b5d9fcfa7356ee8fa8789 (patch) | |
tree | 3c4009acabdc90799d11084dbe5df58f39b90beb /third_party/nix/src/libstore/builtins/buildenv.cc | |
parent | 7edbe59c6c70cd085fc68c4317c3a71a40ac21e5 (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/libstore/builtins/buildenv.cc')
-rw-r--r-- | third_party/nix/src/libstore/builtins/buildenv.cc | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/third_party/nix/src/libstore/builtins/buildenv.cc b/third_party/nix/src/libstore/builtins/buildenv.cc index 0d1c59e6b5b7..433082a0f9de 100644 --- a/third_party/nix/src/libstore/builtins/buildenv.cc +++ b/third_party/nix/src/libstore/builtins/buildenv.cc @@ -35,15 +35,17 @@ static void createLinks(const Path& srcDir, const Path& dstDir, int priority) { } for (const auto& ent : srcFiles) { - if (ent.name[0] == '.') /* not matched by glob */ + if (ent.name[0] == '.') { /* not matched by glob */ continue; + } auto srcFile = srcDir + "/" + ent.name; auto dstFile = dstDir + "/" + ent.name; struct stat srcSt; try { - if (stat(srcFile.c_str(), &srcSt) == -1) + if (stat(srcFile.c_str(), &srcSt) == -1) { throw SysError("getting status of '%1%'", srcFile); + } } catch (SysError& e) { if (e.errNo == ENOENT || e.errNo == ENOTDIR) { LOG(ERROR) << "warning: skipping dangling symlink '" << dstFile << "'"; @@ -61,10 +63,11 @@ static void createLinks(const Path& srcDir, const Path& dstDir, int priority) { if (absl::EndsWith(srcFile, "/propagated-build-inputs") || absl::EndsWith(srcFile, "/nix-support") || absl::EndsWith(srcFile, "/perllocal.pod") || - absl::EndsWith(srcFile, "/info/dir") || absl::EndsWith(srcFile, "/log")) + absl::EndsWith(srcFile, "/info/dir") || + absl::EndsWith(srcFile, "/log")) { continue; - else if (S_ISDIR(srcSt.st_mode)) { + } else if (S_ISDIR(srcSt.st_mode)) { struct stat dstSt; auto res = lstat(dstFile.c_str(), &dstSt); if (res == 0) { @@ -73,19 +76,23 @@ static void createLinks(const Path& srcDir, const Path& dstDir, int priority) { continue; } else if (S_ISLNK(dstSt.st_mode)) { auto target = canonPath(dstFile, true); - if (!S_ISDIR(lstat(target).st_mode)) + if (!S_ISDIR(lstat(target).st_mode)) { throw Error("collision between '%1%' and non-directory '%2%'", srcFile, target); - if (unlink(dstFile.c_str()) == -1) + } + if (unlink(dstFile.c_str()) == -1) { throw SysError(format("unlinking '%1%'") % dstFile); - if (mkdir(dstFile.c_str(), 0755) == -1) + } + if (mkdir(dstFile.c_str(), 0755) == -1) { throw SysError(format("creating directory '%1%'")); + } createLinks(target, dstFile, priorities[dstFile]); createLinks(srcFile, dstFile, priority); continue; } - } else if (errno != ENOENT) + } else if (errno != ENOENT) { throw SysError(format("getting status of '%1%'") % dstFile); + } } else { @@ -94,24 +101,28 @@ static void createLinks(const Path& srcDir, const Path& dstDir, int priority) { if (res == 0) { if (S_ISLNK(dstSt.st_mode)) { auto prevPriority = priorities[dstFile]; - if (prevPriority == priority) + if (prevPriority == priority) { throw Error( "packages '%1%' and '%2%' have the same priority %3%; " "use 'nix-env --set-flag priority NUMBER INSTALLED_PKGNAME' " "to change the priority of one of the conflicting packages" " (0 being the highest priority)", srcFile, readLink(dstFile), priority); + } if (prevPriority < priority) { continue; } - if (unlink(dstFile.c_str()) == -1) + if (unlink(dstFile.c_str()) == -1) { throw SysError(format("unlinking '%1%'") % dstFile); - } else if (S_ISDIR(dstSt.st_mode)) + } + } else if (S_ISDIR(dstSt.st_mode)) { throw Error( "collision between non-directory '%1%' and directory '%2%'", srcFile, dstFile); - } else if (errno != ENOENT) + } + } else if (errno != ENOENT) { throw SysError(format("getting status of '%1%'") % dstFile); + } } createSymlink(srcFile, dstFile); @@ -201,10 +212,11 @@ void builtinBuildenv(const BasicDerivation& drv) { return a.priority < b.priority || (a.priority == b.priority && a.path < b.path); }); - for (const auto& pkg : pkgs) + for (const auto& pkg : pkgs) { 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 |