diff options
author | Vincent Ambo <tazjin@google.com> | 2020-05-19T18·04+0100 |
---|---|---|
committer | Vincent Ambo <tazjin@google.com> | 2020-05-19T18·04+0100 |
commit | 1841d93ccbe5792a17f5b9a22e65ec898c7c2668 (patch) | |
tree | f31155746ad5a21a6f10172b3edaf79b74b56819 /third_party/nix/src/libutil | |
parent | 867055133d3f487e52dd44149f76347c2c28bf10 (diff) |
style(3p/nix): Add braces around single-line for-loops r/772
These were not caught by the previous clang-tidy invocation, but were instead sorted out using amber[0] as such: ambr --regex 'for (\(.+\))\s([a-z].*;)' 'for $1 { $2 }' [0]: https://github.com/dalance/amber
Diffstat (limited to 'third_party/nix/src/libutil')
-rw-r--r-- | third_party/nix/src/libutil/args.cc | 12 | ||||
-rw-r--r-- | third_party/nix/src/libutil/config.cc | 24 | ||||
-rw-r--r-- | third_party/nix/src/libutil/thread-pool.hh | 4 | ||||
-rw-r--r-- | third_party/nix/src/libutil/util.cc | 12 |
4 files changed, 39 insertions, 13 deletions
diff --git a/third_party/nix/src/libutil/args.cc b/third_party/nix/src/libutil/args.cc index cfe68ad6a055..be1d915819e3 100644 --- a/third_party/nix/src/libutil/args.cc +++ b/third_party/nix/src/libutil/args.cc @@ -153,7 +153,9 @@ bool Args::processArgs(const Strings& args, bool finish) { if ((exp.arity == 0 && finish) || (exp.arity > 0 && args.size() == exp.arity)) { std::vector<std::string> ss; - for (auto& s : args) ss.push_back(s); + for (auto& s : args) { + ss.push_back(s); + } exp.handler(std::move(ss)); expectedArgs.pop_front(); res = true; @@ -189,7 +191,9 @@ Strings argvToStrings(int argc, char** argv) { std::string renderLabels(const Strings& labels) { std::string res; for (auto label : labels) { - for (auto& c : label) c = std::toupper(c); + for (auto& c : label) { + c = std::toupper(c); + } res += " <" + label + ">"; } return res; @@ -197,7 +201,9 @@ std::string renderLabels(const Strings& labels) { void printTable(std::ostream& out, const Table2& table) { size_t max = 0; - for (auto& row : table) max = std::max(max, row.first.size()); + for (auto& row : table) { + max = std::max(max, row.first.size()); + } for (auto& row : table) { out << " " << row.first << std::string(max - row.first.size() + 2, ' ') << row.second << "\n"; diff --git a/third_party/nix/src/libutil/config.cc b/third_party/nix/src/libutil/config.cc index dbb703750f36..0b01f6ae8a83 100644 --- a/third_party/nix/src/libutil/config.cc +++ b/third_party/nix/src/libutil/config.cc @@ -61,7 +61,9 @@ void AbstractConfig::warnUnknownSettings() { void AbstractConfig::reapplyUnknownSettings() { auto unknownSettings2 = std::move(unknownSettings); - for (auto& s : unknownSettings2) set(s.first, s.second); + for (auto& s : unknownSettings2) { + set(s.first, s.second); + } } void Config::getSettings(std::map<std::string, SettingInfo>& res, @@ -138,7 +140,9 @@ void AbstractConfig::applyConfigFile(const Path& path) { } void Config::resetOverriden() { - for (auto& s : _settings) s.second.setting->overriden = false; + for (auto& s : _settings) { + s.second.setting->overriden = false; + } } void Config::toJSON(JSONObject& out) { @@ -250,7 +254,9 @@ std::string BaseSetting<Strings>::to_string() { template <> void BaseSetting<Strings>::toJSON(JSONPlaceholder& out) { JSONList list(out.list()); - for (auto& s : value) list.elem(s); + for (auto& s : value) { + list.elem(s); + } } template <> @@ -266,7 +272,9 @@ std::string BaseSetting<StringSet>::to_string() { template <> void BaseSetting<StringSet>::toJSON(JSONPlaceholder& out) { JSONList list(out.list()); - for (auto& s : value) list.elem(s); + for (auto& s : value) { + list.elem(s); + } } template class BaseSetting<int>; @@ -308,11 +316,15 @@ void GlobalConfig::getSettings(std::map<std::string, SettingInfo>& res, } void GlobalConfig::resetOverriden() { - for (auto& config : *configRegistrations) config->resetOverriden(); + for (auto& config : *configRegistrations) { + config->resetOverriden(); + } } void GlobalConfig::toJSON(JSONObject& out) { - for (auto& config : *configRegistrations) config->toJSON(out); + for (auto& config : *configRegistrations) { + config->toJSON(out); + } } void GlobalConfig::convertToArgs(Args& args, const std::string& category) { diff --git a/third_party/nix/src/libutil/thread-pool.hh b/third_party/nix/src/libutil/thread-pool.hh index 114dae40eec9..72837ca1eecc 100644 --- a/third_party/nix/src/libutil/thread-pool.hh +++ b/third_party/nix/src/libutil/thread-pool.hh @@ -125,7 +125,9 @@ void processGraph(ThreadPool& pool, const std::set<T>& nodes, } }; - for (auto& node : nodes) pool.enqueue(std::bind(worker, std::ref(node))); + for (auto& node : nodes) { + pool.enqueue(std::bind(worker, std::ref(node))); + } pool.process(); diff --git a/third_party/nix/src/libutil/util.cc b/third_party/nix/src/libutil/util.cc index 0a2887501c8e..3cc8563a8651 100644 --- a/third_party/nix/src/libutil/util.cc +++ b/third_party/nix/src/libutil/util.cc @@ -69,7 +69,9 @@ std::map<std::string, std::string> getEnv() { } void clearEnv() { - for (auto& name : getEnv()) unsetenv(name.first.c_str()); + for (auto& name : getEnv()) { + unsetenv(name.first.c_str()); + } } void replaceEnv(std::map<std::string, std::string> newEnv) { @@ -903,7 +905,9 @@ pid_t startProcess(std::function<void()> fun, const ProcessOptions& options) { std::vector<char*> stringsToCharPtrs(const Strings& ss) { std::vector<char*> res; - for (auto& s : ss) res.push_back((char*)s.c_str()); + for (auto& s : ss) { + res.push_back((char*)s.c_str()); + } res.push_back(0); return res; } @@ -1215,7 +1219,9 @@ bool hasSuffix(const string& s, const string& suffix) { std::string toLower(const std::string& s) { std::string r(s); - for (auto& c : r) c = std::tolower(c); + for (auto& c : r) { + c = std::tolower(c); + } return r; } |