From 39087321811e81e26a1a47d6967df1088dcf0e95 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Tue, 19 May 2020 20:47:23 +0100 Subject: style(3p/nix): Final act in the brace-wrapping saga This last change set was generated by a full clang-tidy run (including compilation): clang-tidy -p ~/projects/nix-build/ \ -checks=-*,readability-braces-around-statements -fix src/*/*.cc Actually running clang-tidy requires some massaging to make it play nice with Nix + meson, I'll be adding a wrapper or something for that soon. --- third_party/nix/src/libstore/profiles.cc | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'third_party/nix/src/libstore/profiles.cc') diff --git a/third_party/nix/src/libstore/profiles.cc b/third_party/nix/src/libstore/profiles.cc index 38d0972e4400..38ad0c01e461 100644 --- a/third_party/nix/src/libstore/profiles.cc +++ b/third_party/nix/src/libstore/profiles.cc @@ -28,10 +28,11 @@ static int parseName(const string& profileName, const string& name) { return -1; } int n; - if (string2Int(string(s, 0, p), n) && n >= 0) + if (string2Int(string(s, 0, p), n) && n >= 0) { return n; - else + } else { return -1; + } } Generations findGenerations(Path profile, int& curGen) { @@ -47,8 +48,9 @@ Generations findGenerations(Path profile, int& curGen) { gen.path = profileDir + "/" + i.name; gen.number = n; struct stat st; - if (lstat(gen.path.c_str(), &st) != 0) + if (lstat(gen.path.c_str(), &st) != 0) { throw SysError(format("statting '%1%'") % gen.path); + } gen.creationTime = st.st_mtime; gens.push_back(gen); } @@ -105,8 +107,9 @@ Path createGeneration(ref store, Path profile, Path outPath) { } static void removeFile(const Path& path) { - if (remove(path.c_str()) == -1) + if (remove(path.c_str()) == -1) { throw SysError(format("cannot unlink '%1%'") % path); + } } void deleteGeneration(const Path& profile, unsigned int gen) { @@ -134,9 +137,10 @@ void deleteGenerations(const Path& profile, int curGen; Generations gens = findGenerations(profile, curGen); - if (gensToDelete.find(curGen) != gensToDelete.end()) + if (gensToDelete.find(curGen) != gensToDelete.end()) { throw Error(format("cannot delete current generation of profile %1%'") % profile); + } for (auto& i : gens) { if (gensToDelete.find(i.number) == gensToDelete.end()) { @@ -176,10 +180,11 @@ void deleteOldGenerations(const Path& profile, bool dryRun) { int curGen; Generations gens = findGenerations(profile, curGen); - for (auto& i : gens) + for (auto& i : gens) { if (i.number != curGen) { deleteGeneration2(profile, i.number, dryRun); } + } } void deleteGenerationsOlderThan(const Path& profile, time_t t, bool dryRun) { @@ -190,7 +195,7 @@ void deleteGenerationsOlderThan(const Path& profile, time_t t, bool dryRun) { Generations gens = findGenerations(profile, curGen); bool canDelete = false; - for (auto i = gens.rbegin(); i != gens.rend(); ++i) + for (auto i = gens.rbegin(); i != gens.rend(); ++i) { if (canDelete) { assert(i->creationTime < t); if (i->number != curGen) { @@ -203,6 +208,7 @@ void deleteGenerationsOlderThan(const Path& profile, time_t t, bool dryRun) { time. */ canDelete = true; } + } } void deleteGenerationsOlderThan(const Path& profile, const string& timeSpec, @@ -211,8 +217,9 @@ void deleteGenerationsOlderThan(const Path& profile, const string& timeSpec, string strDays = string(timeSpec, 0, timeSpec.size() - 1); int days; - if (!string2Int(strDays, days) || days < 1) + if (!string2Int(strDays, days) || days < 1) { throw Error(format("invalid number of days specifier '%1%'") % timeSpec); + } time_t oldTime = curTime - days * 24 * 3600; -- cgit 1.4.1