about summary refs log tree commit diff
path: root/third_party/nix/src/libexpr/parser.cc
diff options
context:
space:
mode:
authorKane York <kanepyork@gmail.com>2020-07-25T04·09-0700
committerkanepyork <rikingcoding@gmail.com>2020-07-27T21·16+0000
commitef54f5da9fa30b5c302f2a49595ee5d041f9706a (patch)
tree8d1da709a2e2d3b135d1e84eda9c402bde467726 /third_party/nix/src/libexpr/parser.cc
parent69f402563a14d4b668980e4228d033d80e3bb05d (diff)
fix(3p/nix): apply all clang-tidy fixes r/1495
Change-Id: I265e763393422ee1881653527c91024458060825
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1432
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
Diffstat (limited to 'third_party/nix/src/libexpr/parser.cc')
-rw-r--r--third_party/nix/src/libexpr/parser.cc19
1 files changed, 11 insertions, 8 deletions
diff --git a/third_party/nix/src/libexpr/parser.cc b/third_party/nix/src/libexpr/parser.cc
index a96d345cc126..7b477f3eae0a 100644
--- a/third_party/nix/src/libexpr/parser.cc
+++ b/third_party/nix/src/libexpr/parser.cc
@@ -85,9 +85,10 @@ void addAttr(ExprAttrs* attrs, AttrPath& attrPath, Expr* e, const Pos& pos) {
 }
 
 void addFormal(const Pos& pos, Formals* formals, const Formal& formal) {
-  if (formals->argNames.find(formal.name) != formals->argNames.end())
+  if (formals->argNames.find(formal.name) != formals->argNames.end()) {
     throw ParseError(format("duplicate formal function argument '%1%' at %2%") %
                      formal.name % pos);
+  }
   formals->formals.push_front(formal);
   formals->argNames.insert(formal.name);
 }
@@ -118,9 +119,9 @@ Expr* stripIndentation(const Pos& pos, SymbolTable& symbols,
     }
     for (size_t j = 0; j < e->s.size(); ++j) {
       if (atStartOfLine) {
-        if (e->s[j] == ' ')
+        if (e->s[j] == ' ') {
           curIndent++;
-        else if (e->s[j] == '\n') {
+        } else if (e->s[j] == '\n') {
           /* Empty line, doesn't influence minimum
              indentation. */
           curIndent = 0;
@@ -196,10 +197,11 @@ Path resolveExprPath(Path path) {
 
   /* If `path' is a symlink, follow it.  This is so that relative
      path references work. */
-  struct stat st;
+  struct stat st {};
   while (true) {
-    if (lstat(path.c_str(), &st))
+    if (lstat(path.c_str(), &st)) {
       throw SysError(format("getting status of '%1%'") % path);
+    }
     if (!S_ISLNK(st.st_mode)) {
       break;
     }
@@ -260,13 +262,14 @@ Path EvalState::findFile(SearchPath& searchPath, const std::string& path,
                          const Pos& pos) {
   for (auto& i : searchPath) {
     std::string suffix;
-    if (i.first.empty())
+    if (i.first.empty()) {
       suffix = "/" + path;
-    else {
+    } else {
       auto s = i.first.size();
       if (path.compare(0, s, i.first) != 0 ||
-          (path.size() > s && path[s] != '/'))
+          (path.size() > s && path[s] != '/')) {
         continue;
+      }
       suffix = path.size() == s ? "" : "/" + std::string(path, s);
     }
     auto r = resolveSearchPathElem(i);