diff options
author | Vincent Ambo <tazjin@google.com> | 2020-05-19T17·55+0100 |
---|---|---|
committer | Vincent Ambo <tazjin@google.com> | 2020-05-19T17·55+0100 |
commit | 867055133d3f487e52dd44149f76347c2c28bf10 (patch) | |
tree | c367803ad94f024b0052727a2c7a037af169169a /third_party/nix/src/nix/run.cc | |
parent | c6a31838cd7e88ebcb01422b329a499d04ab4b6b (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/nix/run.cc')
-rw-r--r-- | third_party/nix/src/nix/run.cc | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/third_party/nix/src/nix/run.cc b/third_party/nix/src/nix/run.cc index 0b5a2648f9fb..c246767ceddd 100644 --- a/third_party/nix/src/nix/run.cc +++ b/third_party/nix/src/nix/run.cc @@ -94,7 +94,9 @@ struct CmdRun : InstallablesCommand { std::map<std::string, std::string> kept; for (auto& var : keep) { auto s = getenv(var.c_str()); - if (s) kept[var] = s; + if (s) { + kept[var] = s; + } } clearEnv(); @@ -118,9 +120,13 @@ struct CmdRun : InstallablesCommand { while (!todo.empty()) { Path path = todo.front(); todo.pop(); - if (!done.insert(path).second) continue; + if (!done.insert(path).second) { + continue; + } - if (true) unixPath.push_front(path + "/bin"); + if (true) { + unixPath.push_front(path + "/bin"); + } auto propPath = path + "/nix-support/propagated-user-env-packages"; if (accessor->stat(propPath).type == FSAccessor::tRegular) { @@ -206,9 +212,13 @@ void chrootHelper(int argc, char** argv) { for (auto entry : readDirectory("/")) { auto src = "/" + entry.name; auto st = lstat(src); - if (!S_ISDIR(st.st_mode)) continue; + if (!S_ISDIR(st.st_mode)) { + continue; + } Path dst = tmpDir + "/" + entry.name; - if (pathExists(dst)) continue; + if (pathExists(dst)) { + continue; + } if (mkdir(dst.c_str(), 0700) == -1) throw SysError("creating directory '%s'", dst); if (mount(src.c_str(), dst.c_str(), "", MS_BIND | MS_REC, 0) == -1) @@ -216,7 +226,9 @@ void chrootHelper(int argc, char** argv) { } char* cwd = getcwd(0, 0); - if (!cwd) throw SysError("getting current directory"); + if (!cwd) { + throw SysError("getting current directory"); + } Finally freeCwd([&]() { free(cwd); }); if (chroot(tmpDir.c_str()) == -1) |