about summary refs log tree commit diff
path: root/third_party
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-05-19T17·01+0100
committerVincent Ambo <tazjin@google.com>2020-05-19T17·01+0100
commit09cbc431cca08be891e5e792ceda2a34956b2fc8 (patch)
tree3653448c7e074bdfd10dfa3bc3b5dfe952299fdf /third_party
parentb490742a511dd03afc43f5143d6d61edaeeb8091 (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')
-rw-r--r--third_party/nix/src/libexpr/eval.cc18
-rw-r--r--third_party/nix/src/libexpr/get-drvs.cc7
-rw-r--r--third_party/nix/src/libexpr/json-to-value.cc3
-rw-r--r--third_party/nix/src/libexpr/names.cc3
-rw-r--r--third_party/nix/src/libexpr/nixexpr.cc20
-rw-r--r--third_party/nix/src/libexpr/primops.cc7
-rw-r--r--third_party/nix/src/libexpr/primops/fetchGit.cc3
-rw-r--r--third_party/nix/src/libexpr/primops/fetchMercurial.cc3
-rw-r--r--third_party/nix/src/libexpr/value-to-xml.cc15
-rw-r--r--third_party/nix/src/libmain/shared.hh4
-rw-r--r--third_party/nix/src/libstore/sqlite.cc3
-rw-r--r--third_party/nix/src/nix-daemon/nix-daemon.cc3
-rw-r--r--third_party/nix/src/nix-instantiate/nix-instantiate.cc9
-rw-r--r--third_party/nix/src/nix/installables.cc5
-rw-r--r--third_party/nix/src/nix/ls.cc13
-rw-r--r--third_party/nix/src/nix/repl.cc7
16 files changed, 62 insertions, 61 deletions
diff --git a/third_party/nix/src/libexpr/eval.cc b/third_party/nix/src/libexpr/eval.cc
index 19f6a46ed6..5d6f30c07d 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 16bb03f1d1..ad7211eaea 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 e7c7794d11..8d84a5ac69 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 66a918de5d..f7752f2bf8 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 85e80361e3..9c25530efd 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 98a6f56dfd..3e11d6589f 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 af3f89fde7..7fbd4dc92c 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 5847f6021f..3de42fe770 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 5ea1e09824..6247d25b9c 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;
     }
diff --git a/third_party/nix/src/libmain/shared.hh b/third_party/nix/src/libmain/shared.hh
index 337c38413d..e5f4bec648 100644
--- a/third_party/nix/src/libmain/shared.hh
+++ b/third_party/nix/src/libmain/shared.hh
@@ -68,9 +68,9 @@ N getIntArg(const string& opt, Strings::iterator& i,
       } else if (u == 'T') {
         multiplier = 1ULL << 40;
       } else {
-        throw
+        throw UsageError(format("invalid unit specifier '%1%'") % u);
       }
-      UsageError(format("invalid unit specifier '%1%'") % u);
+
       s.resize(s.size() - 1);
     }
   }
diff --git a/third_party/nix/src/libstore/sqlite.cc b/third_party/nix/src/libstore/sqlite.cc
index 81c3ffcd9d..5aa661afe0 100644
--- a/third_party/nix/src/libstore/sqlite.cc
+++ b/third_party/nix/src/libstore/sqlite.cc
@@ -24,9 +24,8 @@ namespace nix {
             ? fmt("SQLite database '%s' is busy (SQLITE_PROTOCOL)", path)
             : fmt("SQLite database '%s' is busy", path));
   } else {
-    throw
+    throw SQLiteError("%s: %s (in '%s')", fs.s, sqlite3_errstr(exterr), path);
   }
-  SQLiteError("%s: %s (in '%s')", fs.s, sqlite3_errstr(exterr), path);
 }
 
 SQLite::SQLite(const Path& path) {
diff --git a/third_party/nix/src/nix-daemon/nix-daemon.cc b/third_party/nix/src/nix-daemon/nix-daemon.cc
index dbc49edfad..dde1c84571 100644
--- a/third_party/nix/src/nix-daemon/nix-daemon.cc
+++ b/third_party/nix/src/nix-daemon/nix-daemon.cc
@@ -305,9 +305,8 @@ static void performOp(TunnelLogger* logger, ref<Store> store, bool trusted,
         ParseSink sink; /* null sink; just parse the NAR */
         parseDump(sink, savedNAR);
       } else {
-        parseDump
+        parseDump(savedRegular, from);
       }
-      (savedRegular, from);
 
       logger->startWork();
       if (!savedRegular.regular) throw Error("regular file expected");
diff --git a/third_party/nix/src/nix-instantiate/nix-instantiate.cc b/third_party/nix/src/nix-instantiate/nix-instantiate.cc
index df97f23ef9..2630f5f9eb 100644
--- a/third_party/nix/src/nix-instantiate/nix-instantiate.cc
+++ b/third_party/nix/src/nix-instantiate/nix-instantiate.cc
@@ -163,7 +163,9 @@ static int _main(int argc, char** argv) {
     if (findFile) {
       for (auto& i : files) {
         Path p = state->findFile(i);
-        if (p == "") throw Error(format("unable to find '%1%'") % i);
+        if (p == "") {
+          throw Error(format("unable to find '%1%'") % i);
+        }
         std::cout << p << std::endl;
       }
       return 0;
@@ -173,10 +175,9 @@ static int _main(int argc, char** argv) {
       Expr* e = state->parseStdin();
       processExpr(*state, attrPaths, parseOnly, strict, autoArgs, evalOnly,
                   outputKind, xmlOutputSourceLocation, e);
-    } else {
-      if
+    } else if (files.empty() && !fromArgs) {
+      files.push_back("./default.nix");
     }
-    (files.empty() && !fromArgs) files.push_back("./default.nix");
 
     for (auto& i : files) {
       Expr* e = fromArgs
diff --git a/third_party/nix/src/nix/installables.cc b/third_party/nix/src/nix/installables.cc
index f708a5a9fa..2378a4b16a 100644
--- a/third_party/nix/src/nix/installables.cc
+++ b/third_party/nix/src/nix/installables.cc
@@ -248,10 +248,9 @@ Buildables build(ref<Store> store, RealiseMode mode,
 
   if (mode == DryRun) {
     printMissing(store, pathsToBuild);
-  } else {
-    if
+  } else if (mode == Build) {
+    store->buildPaths(pathsToBuild);
   }
-  (mode == Build) store->buildPaths(pathsToBuild);
 
   return buildables;
 }
diff --git a/third_party/nix/src/nix/ls.cc b/third_party/nix/src/nix/ls.cc
index 68a2c203de..62720b93a0 100644
--- a/third_party/nix/src/nix/ls.cc
+++ b/third_party/nix/src/nix/ls.cc
@@ -54,30 +54,33 @@ struct MixLs : virtual Args, MixJSON {
                  const std::string& relPath, bool showDirectory) {
       if (st.type == FSAccessor::Type::tDirectory && !showDirectory) {
         auto names = accessor->readDirectory(curPath);
-        for (auto& name : names)
+        for (auto& name : names) {
           showFile(curPath + "/" + name, relPath + "/" + name);
+        }
       } else
         showFile(curPath, relPath);
     };
 
     auto st = accessor->stat(path);
-    if (st.type == FSAccessor::Type::tMissing)
+    if (st.type == FSAccessor::Type::tMissing) {
       throw Error(format("path '%1%' does not exist") % path);
+    }
     doPath(st, path,
            st.type == FSAccessor::Type::tDirectory ? "." : baseNameOf(path),
            showDirectory);
   }
 
   void list(ref<FSAccessor> accessor) {
-    if (path == "/") path = "";
+    if (path == "/") {
+      path = "";
+    }
 
     if (json) {
       JSONPlaceholder jsonRoot(std::cout);
       listNar(jsonRoot, accessor, path, recursive);
     } else {
-      listText
+      listText(accessor);
     }
-    (accessor);
   }
 };
 
diff --git a/third_party/nix/src/nix/repl.cc b/third_party/nix/src/nix/repl.cc
index a24020b7ba..2d71887405 100644
--- a/third_party/nix/src/nix/repl.cc
+++ b/third_party/nix/src/nix/repl.cc
@@ -689,9 +689,8 @@ std::ostream& NixRepl::printValue(std::ostream& str, Value& v,
 
         str << "}";
       } else {
-        str
+        str << "{ ... }";
       }
-      << "{ ... }";
 
       break;
     }
@@ -715,9 +714,9 @@ std::ostream& NixRepl::printValue(std::ostream& str, Value& v,
           str << " ";
         }
       } else {
-        str
+        str << "... ";
       }
-      << "... ";
+
       str << "]";
       break;