about summary refs log tree commit diff
path: root/third_party/nix/src/libexpr/json-to-value.cc
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-05-19T16·38+0100
committerVincent Ambo <tazjin@google.com>2020-05-19T16·38+0100
commitb490742a511dd03afc43f5143d6d61edaeeb8091 (patch)
tree727370e8e7607a3078c2ce1cd6d717105c7d9c44 /third_party/nix/src/libexpr/json-to-value.cc
parentc758de9d22506eb279c5abe61f621e5c8f61af95 (diff)
style(3p/nix): Enforce braces around loops and conditionals r/767
This change was generated with:

  fd -e cc -e hh | xargs -I{} clang-tidy {} -p ~/projects/nix-build/ \
    --checks='-*,readability-braces-around-statements' --fix \
    -fix-errors

Some manual fixes were applied because some convoluted unbraced
statements couldn't be untangled by clang-tidy.

This commit still includes invalid files, but I decided to clean them
up in a subsequent commit so that it becomes more obvious where
clang-tidy failed. Maybe this will allow for a bug-report to
clang-tidy.
Diffstat (limited to 'third_party/nix/src/libexpr/json-to-value.cc')
-rw-r--r--third_party/nix/src/libexpr/json-to-value.cc18
1 files changed, 13 insertions, 5 deletions
diff --git a/third_party/nix/src/libexpr/json-to-value.cc b/third_party/nix/src/libexpr/json-to-value.cc
index a6c12fd8244c..e7c7794d1181 100644
--- a/third_party/nix/src/libexpr/json-to-value.cc
+++ b/third_party/nix/src/libexpr/json-to-value.cc
@@ -5,7 +5,9 @@
 namespace nix {
 
 static void skipWhitespace(const char*& s) {
-  while (*s == ' ' || *s == '\t' || *s == '\n' || *s == '\r') s++;
+  while (*s == ' ' || *s == '\t' || *s == '\n' || *s == '\r') {
+    s++;
+  }
 }
 
 static string parseJSONString(const char*& s) {
@@ -39,8 +41,10 @@ static string parseJSONString(const char*& s) {
       else
         throw JSONParseError("invalid escaped character in JSON string");
       s++;
-    } else
-      res += *s++;
+    } else {
+      res
+    }
+    += *s++;
   }
   s++;
   return res;
@@ -62,7 +66,9 @@ static void parseJSON(EvalState& state, const char*& s, Value& v) {
       parseJSON(state, s, *v2);
       values.push_back(v2);
       skipWhitespace(s);
-      if (*s == ']') break;
+      if (*s == ']') {
+        break;
+      }
       if (*s != ',')
         throw JSONParseError("expected ',' or ']' after JSON array element");
       s++;
@@ -86,7 +92,9 @@ static void parseJSON(EvalState& state, const char*& s, Value& v) {
       parseJSON(state, s, *v2);
       attrs[state.symbols.create(name)] = v2;
       skipWhitespace(s);
-      if (*s == '}') break;
+      if (*s == '}') {
+        break;
+      }
       if (*s != ',')
         throw JSONParseError("expected ',' or '}' after JSON member");
       s++;