about summary refs log tree commit diff
path: root/third_party/nix/src/libstore/nar-accessor.cc
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-05-19T17·55+0100
committerVincent Ambo <tazjin@google.com>2020-05-19T17·55+0100
commit867055133d3f487e52dd44149f76347c2c28bf10 (patch)
treec367803ad94f024b0052727a2c7a037af169169a /third_party/nix/src/libstore/nar-accessor.cc
parentc6a31838cd7e88ebcb01422b329a499d04ab4b6b (diff)
style(3p/nix): Add braces around single-line conditionals r/771
These were not caught by the previous clang-tidy invocation, but were
instead sorted out using amber[0] as such:

    ambr --regex 'if (\(.+\))\s([a-z].*;)' 'if $1 { $2 }'

[0]: https://github.com/dalance/amber
Diffstat (limited to 'third_party/nix/src/libstore/nar-accessor.cc')
-rw-r--r--third_party/nix/src/libstore/nar-accessor.cc24
1 files changed, 18 insertions, 6 deletions
diff --git a/third_party/nix/src/libstore/nar-accessor.cc b/third_party/nix/src/libstore/nar-accessor.cc
index b36f75401b..0214561da4 100644
--- a/third_party/nix/src/libstore/nar-accessor.cc
+++ b/third_party/nix/src/libstore/nar-accessor.cc
@@ -133,7 +133,9 @@ struct NarAccessor : public FSAccessor {
     for (auto it = path.begin(); it != end;) {
       // because it != end, the remaining component is non-empty so we need
       // a directory
-      if (current->type != FSAccessor::Type::tDirectory) return nullptr;
+      if (current->type != FSAccessor::Type::tDirectory) {
+        return nullptr;
+      }
 
       // skip slash (canonPath above ensures that this is always a slash)
       assert(*it == '/');
@@ -142,7 +144,9 @@ struct NarAccessor : public FSAccessor {
       // lookup current component
       auto next = std::find(it, end, '/');
       auto child = current->children.find(std::string(it, next));
-      if (child == current->children.end()) return nullptr;
+      if (child == current->children.end()) {
+        return nullptr;
+      }
       current = &child->second;
 
       it = next;
@@ -160,7 +164,9 @@ struct NarAccessor : public FSAccessor {
 
   Stat stat(const Path& path) override {
     auto i = find(path);
-    if (i == nullptr) return {FSAccessor::Type::tMissing, 0, false};
+    if (i == nullptr) {
+      return {FSAccessor::Type::tMissing, 0, false};
+    }
     return {i->type, i->size, i->isExecutable, i->start};
   }
 
@@ -183,7 +189,9 @@ struct NarAccessor : public FSAccessor {
       throw Error(format("path '%1%' inside NAR file is not a regular file") %
                   path);
 
-    if (getNarBytes) return getNarBytes(i.start, i.size);
+    if (getNarBytes) {
+      return getNarBytes(i.start, i.size);
+    }
 
     assert(nar);
     return std::string(*nar, i.start, i.size);
@@ -216,8 +224,12 @@ void listNar(JSONPlaceholder& res, ref<FSAccessor> accessor, const Path& path,
     case FSAccessor::Type::tRegular:
       obj.attr("type", "regular");
       obj.attr("size", st.fileSize);
-      if (st.isExecutable) obj.attr("executable", true);
-      if (st.narOffset) obj.attr("narOffset", st.narOffset);
+      if (st.isExecutable) {
+        obj.attr("executable", true);
+      }
+      if (st.narOffset) {
+        obj.attr("narOffset", st.narOffset);
+      }
       break;
     case FSAccessor::Type::tDirectory:
       obj.attr("type", "directory");