diff options
author | Vincent Ambo <tazjin@google.com> | 2020-05-19T17·01+0100 |
---|---|---|
committer | Vincent Ambo <tazjin@google.com> | 2020-05-19T17·01+0100 |
commit | 09cbc431cca08be891e5e792ceda2a34956b2fc8 (patch) | |
tree | 3653448c7e074bdfd10dfa3bc3b5dfe952299fdf /third_party/nix/src/libexpr | |
parent | b490742a511dd03afc43f5143d6d61edaeeb8091 (diff) |
fix(3p/nix): Fix incorrectly braced conditionals and loops r/768
Fixes mistakes introduced by clang-tidy in the previous commit.
Diffstat (limited to 'third_party/nix/src/libexpr')
-rw-r--r-- | third_party/nix/src/libexpr/eval.cc | 18 | ||||
-rw-r--r-- | third_party/nix/src/libexpr/get-drvs.cc | 7 | ||||
-rw-r--r-- | third_party/nix/src/libexpr/json-to-value.cc | 3 | ||||
-rw-r--r-- | third_party/nix/src/libexpr/names.cc | 3 | ||||
-rw-r--r-- | third_party/nix/src/libexpr/nixexpr.cc | 20 | ||||
-rw-r--r-- | third_party/nix/src/libexpr/primops.cc | 7 | ||||
-rw-r--r-- | third_party/nix/src/libexpr/primops/fetchGit.cc | 3 | ||||
-rw-r--r-- | third_party/nix/src/libexpr/primops/fetchMercurial.cc | 3 | ||||
-rw-r--r-- | third_party/nix/src/libexpr/value-to-xml.cc | 15 |
9 files changed, 40 insertions, 39 deletions
diff --git a/third_party/nix/src/libexpr/eval.cc b/third_party/nix/src/libexpr/eval.cc index 19f6a46ed655..5d6f30c07d0c 100644 --- a/third_party/nix/src/libexpr/eval.cc +++ b/third_party/nix/src/libexpr/eval.cc @@ -820,15 +820,12 @@ void ExprAttrs::eval(EvalState& state, Env& env, Value& v) { newBnds->sort(); v.attrs = newBnds; } + } else { + for (auto& i : attrs) + v.attrs->push_back( + Attr(i.first, i.second.e->maybeThunk(state, env), &i.second.pos)); } - else { - for - } - (auto& i - : attrs) v.attrs->push_back(Attr(i.first, i.second.e->maybeThunk(state, env), - &i.second.pos)); - /* Dynamic attrs apply *after* rec and __overrides. */ for (auto& i : dynamicAttrs) { Value nameVal; @@ -1350,9 +1347,8 @@ void ExprConcatStrings::eval(EvalState& state, Env& env, Value& v) { auto path = canonPath(s.str()); mkPath(v, path.c_str()); } else { - mkString + mkString(v, s.str(), context); } - (v, s.str(), context); } void ExprPos::eval(EvalState& state, Env& env, Value& v) { @@ -1378,9 +1374,7 @@ void EvalState::forceValueDeep(Value& v) { i.name, *i.pos); throw; } - } - - else if (v.isList()) { + } else if (v.isList()) { for (size_t n = 0; n < v.listSize(); ++n) recurse(*v.listElems()[n]); } }; diff --git a/third_party/nix/src/libexpr/get-drvs.cc b/third_party/nix/src/libexpr/get-drvs.cc index 16bb03f1d16f..ad7211eaea5b 100644 --- a/third_party/nix/src/libexpr/get-drvs.cc +++ b/third_party/nix/src/libexpr/get-drvs.cc @@ -387,11 +387,10 @@ static void getDerivations(EvalState& state, Value& vIn, } else { - throw + throw TypeError( + "expression does not evaluate to a derivation (or a set or list of " + "those)"); } - TypeError( - "expression does not evaluate to a derivation (or a set or list of " - "those)"); } void getDerivations(EvalState& state, Value& v, const string& pathPrefix, diff --git a/third_party/nix/src/libexpr/json-to-value.cc b/third_party/nix/src/libexpr/json-to-value.cc index e7c7794d1181..8d84a5ac6901 100644 --- a/third_party/nix/src/libexpr/json-to-value.cc +++ b/third_party/nix/src/libexpr/json-to-value.cc @@ -42,9 +42,8 @@ static string parseJSONString(const char*& s) { throw JSONParseError("invalid escaped character in JSON string"); s++; } else { - res + res += *s++; } - += *s++; } s++; return res; diff --git a/third_party/nix/src/libexpr/names.cc b/third_party/nix/src/libexpr/names.cc index 66a918de5dc2..f7752f2bf804 100644 --- a/third_party/nix/src/libexpr/names.cc +++ b/third_party/nix/src/libexpr/names.cc @@ -71,9 +71,8 @@ static bool componentsLT(const string& c1, const string& c2) { } else if (c1Num) { return false; } else { - return + return c1 < c2; } - c1 < c2; } int compareVersions(const string& v1, const string& v2) { diff --git a/third_party/nix/src/libexpr/nixexpr.cc b/third_party/nix/src/libexpr/nixexpr.cc index 85e80361e3ab..9c25530efdba 100644 --- a/third_party/nix/src/libexpr/nixexpr.cc +++ b/third_party/nix/src/libexpr/nixexpr.cc @@ -256,16 +256,20 @@ void ExprAttrs::bindVars(const StaticEnv& env) { dynamicEnv = &newEnv; unsigned int displ = 0; - for (auto& i : attrs) newEnv.vars[i.first] = i.second.displ = displ++; + for (auto& i : attrs) { + newEnv.vars[i.first] = i.second.displ = displ++; + } - for (auto& i : attrs) + for (auto& i : attrs) { i.second.e->bindVars(i.second.inherited ? env : newEnv); + } } else { - for + for (auto& i : attrs) { + i.second.e->bindVars(env); + } } - (auto& i : attrs) i.second.e->bindVars(env); for (auto& i : dynamicAttrs) { i.nameExpr->bindVars(*dynamicEnv); @@ -282,10 +286,14 @@ void ExprLambda::bindVars(const StaticEnv& env) { unsigned int displ = 0; - if (!arg.empty()) newEnv.vars[arg] = displ++; + if (!arg.empty()) { + newEnv.vars[arg] = displ++; + } if (matchAttrs) { - for (auto& i : formals->formals) newEnv.vars[i.name] = displ++; + for (auto& i : formals->formals) { + newEnv.vars[i.name] = displ++; + } for (auto& i : formals->formals) if (i.def) i.def->bindVars(newEnv); diff --git a/third_party/nix/src/libexpr/primops.cc b/third_party/nix/src/libexpr/primops.cc index 98a6f56dfdf3..3e11d6589f6a 100644 --- a/third_party/nix/src/libexpr/primops.cc +++ b/third_party/nix/src/libexpr/primops.cc @@ -1966,9 +1966,9 @@ static void prim_concatStringSep(EvalState& state, const Pos& pos, Value** args, if (first) { first = false; } else { - res + res += sep; } - += sep; + res += state.coerceToString(pos, *args[1]->listElems()[n], context); } @@ -2103,9 +2103,8 @@ void fetch(EvalState& state, const Pos& pos, Value** args, Value& v, throw EvalError(format("'url' argument required, at %1%") % pos); } else { - request + request.uri = state.forceStringNoCtx(*args[0], pos); } - .uri = state.forceStringNoCtx(*args[0], pos); state.checkURI(request.uri); diff --git a/third_party/nix/src/libexpr/primops/fetchGit.cc b/third_party/nix/src/libexpr/primops/fetchGit.cc index af3f89fde77a..7fbd4dc92cf0 100644 --- a/third_party/nix/src/libexpr/primops/fetchGit.cc +++ b/third_party/nix/src/libexpr/primops/fetchGit.cc @@ -228,9 +228,8 @@ static void prim_fetchGit(EvalState& state, const Pos& pos, Value** args, throw EvalError(format("'url' argument required, at %1%") % pos); } else { - url + url = state.coerceToString(pos, *args[0], context, false, false); } - = state.coerceToString(pos, *args[0], context, false, false); // FIXME: git externals probably can be used to bypass the URI // whitelist. Ah well. diff --git a/third_party/nix/src/libexpr/primops/fetchMercurial.cc b/third_party/nix/src/libexpr/primops/fetchMercurial.cc index 5847f6021f43..3de42fe770dc 100644 --- a/third_party/nix/src/libexpr/primops/fetchMercurial.cc +++ b/third_party/nix/src/libexpr/primops/fetchMercurial.cc @@ -204,9 +204,8 @@ static void prim_fetchMercurial(EvalState& state, const Pos& pos, Value** args, throw EvalError(format("'url' argument required, at %1%") % pos); } else { - url + url = state.coerceToString(pos, *args[0], context, false, false); } - = state.coerceToString(pos, *args[0], context, false, false); // FIXME: git externals probably can be used to bypass the URI // whitelist. Ah well. diff --git a/third_party/nix/src/libexpr/value-to-xml.cc b/third_party/nix/src/libexpr/value-to-xml.cc index 5ea1e09824c7..6247d25b9c34 100644 --- a/third_party/nix/src/libexpr/value-to-xml.cc +++ b/third_party/nix/src/libexpr/value-to-xml.cc @@ -137,15 +137,20 @@ static void printValueAsXML(EvalState& state, bool strict, bool location, if (v.lambda.fun->matchAttrs) { XMLAttrs attrs; - if (!v.lambda.fun->arg.empty()) attrs["name"] = v.lambda.fun->arg; - if (v.lambda.fun->formals->ellipsis) attrs["ellipsis"] = "1"; + if (!v.lambda.fun->arg.empty()) { + attrs["name"] = v.lambda.fun->arg; + } + if (v.lambda.fun->formals->ellipsis) { + attrs["ellipsis"] = "1"; + } XMLOpenElement _(doc, "attrspat", attrs); - for (auto& i : v.lambda.fun->formals->formals) + for (auto& i : v.lambda.fun->formals->formals) { doc.writeEmptyElement("attr", singletonAttrs("name", i.name)); + } } else { - doc + doc.writeEmptyElement("varpat", + singletonAttrs("name", v.lambda.fun->arg)); } - .writeEmptyElement("varpat", singletonAttrs("name", v.lambda.fun->arg)); break; } |