refactor(3p/nix): Apply clang-tidy's modernize-* fixes

This applies the modernization fixes listed here:

https://clang.llvm.org/extra/clang-tidy/checks/list.html

The 'modernize-use-trailing-return-type' fix was excluded due to my
personal preference (more specifically, I think the 'auto' keyword is
misleading in that position).
This commit is contained in:
Vincent Ambo 2020-05-20 04:33:07 +01:00
parent fed31b2c9b
commit d331d3a0b5
59 changed files with 349 additions and 321 deletions

View file

@ -28,7 +28,7 @@ using namespace nix;
using std::cin;
using std::cout;
typedef void (*Operation)(Strings opFlags, Strings opArgs);
using Operation = void (*)(Strings, Strings);
static Path gcRoot;
static int rootNr = 0;
@ -77,7 +77,7 @@ static PathSet realisePath(Path path, bool build = true) {
PathSet outputs;
for (auto& j : p.second) {
DerivationOutputs::iterator i = drv.outputs.find(j);
auto i = drv.outputs.find(j);
if (i == drv.outputs.end()) {
throw Error(
format("derivation '%1%' does not have an output named '%2%'") %
@ -246,7 +246,7 @@ static void opPrintFixedPath(Strings opFlags, Strings opArgs) {
throw UsageError(format("'--print-fixed-path' requires three arguments"));
}
Strings::iterator i = opArgs.begin();
auto i = opArgs.begin();
HashType hashAlgo = parseHashType(*i++);
string hash = *i++;
string name = *i++;
@ -427,8 +427,7 @@ static void opQuery(Strings opFlags, Strings opArgs) {
}
}
Paths sorted = store->topoSortPaths(paths);
for (Paths::reverse_iterator i = sorted.rbegin(); i != sorted.rend();
++i) {
for (auto i = sorted.rbegin(); i != sorted.rend(); ++i) {
cout << format("%s\n") % *i;
}
break;
@ -446,7 +445,7 @@ static void opQuery(Strings opFlags, Strings opArgs) {
for (auto& i : opArgs) {
Path path = useDeriver(store->followLinksToStorePath(i));
Derivation drv = store->derivationFromPath(path);
StringPairs::iterator j = drv.env.find(bindingName);
auto j = drv.env.find(bindingName);
if (j == drv.env.end()) {
throw Error(
format(
@ -607,7 +606,7 @@ static void registerValidity(bool reregister, bool hashGiven,
bool canonicalise) {
ValidPathInfos infos;
while (1) {
while (true) {
ValidPathInfo info = decodeValidPathInfo(cin, hashGiven);
if (info.path == "") {
break;
@ -701,7 +700,7 @@ static void opGC(Strings opFlags, Strings opArgs) {
} else if (*i == "--delete") {
options.action = GCOptions::gcDeleteDead;
} else if (*i == "--max-freed") {
long long maxFreed = getIntArg<long long>(*i, i, opFlags.end(), true);
auto maxFreed = getIntArg<long long>(*i, i, opFlags.end(), true);
options.maxFreed = maxFreed >= 0 ? maxFreed : 0;
} else {
throw UsageError(format("bad sub-operation '%1%' in GC") % *i);
@ -966,7 +965,7 @@ static void opServe(Strings opFlags, Strings opArgs) {
case cmdQueryValidPaths: {
bool lock = readInt(in);
bool substitute = readInt(in);
PathSet paths = readStorePaths<PathSet>(*store, in);
auto paths = readStorePaths<PathSet>(*store, in);
if (lock && writeAllowed) {
for (auto& path : paths) {
store->addTempRoot(path);
@ -1004,7 +1003,7 @@ static void opServe(Strings opFlags, Strings opArgs) {
}
case cmdQueryPathInfos: {
PathSet paths = readStorePaths<PathSet>(*store, in);
auto paths = readStorePaths<PathSet>(*store, in);
// !!! Maybe we want a queryPathInfos?
for (auto& i : paths) {
try {
@ -1048,7 +1047,7 @@ static void opServe(Strings opFlags, Strings opArgs) {
if (!writeAllowed) {
throw Error("building paths is not allowed");
}
PathSet paths = readStorePaths<PathSet>(*store, in);
auto paths = readStorePaths<PathSet>(*store, in);
getBuildSettings();
@ -1186,7 +1185,7 @@ static void opVersion(Strings opFlags, Strings opArgs) {
static int _main(int argc, char** argv) {
{
Strings opFlags, opArgs;
Operation op = 0;
Operation op = nullptr;
parseCmdLine(argc, argv,
[&](Strings::iterator& arg, const Strings::iterator& end) {