about summary refs log tree commit diff
path: root/third_party/nix/src/libutil/serialise.cc
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-05-19T19·47+0100
committerVincent Ambo <tazjin@google.com>2020-05-19T19·51+0100
commit39087321811e81e26a1a47d6967df1088dcf0e95 (patch)
tree57110be423eeb7869e9960466f4b17c0ea7cd961 /third_party/nix/src/libutil/serialise.cc
parentcf40d08908ede4061eb15513b770c98877844b8b (diff)
style(3p/nix): Final act in the brace-wrapping saga r/777
This last change set was generated by a full clang-tidy run (including
compilation):

    clang-tidy -p ~/projects/nix-build/ \
      -checks=-*,readability-braces-around-statements -fix src/*/*.cc

Actually running clang-tidy requires some massaging to make it play
nice with Nix + meson, I'll be adding a wrapper or something for that soon.
Diffstat (limited to 'third_party/nix/src/libutil/serialise.cc')
-rw-r--r--third_party/nix/src/libutil/serialise.cc14
1 files changed, 10 insertions, 4 deletions
diff --git a/third_party/nix/src/libutil/serialise.cc b/third_party/nix/src/libutil/serialise.cc
index 760d19ed4cf3..b51ed2105b4d 100644
--- a/third_party/nix/src/libutil/serialise.cc
+++ b/third_party/nix/src/libutil/serialise.cc
@@ -173,7 +173,7 @@ std::unique_ptr<Source> sinkToSource(std::function<void(Sink&)> fun,
     size_t pos = 0;
 
     size_t read(unsigned char* data, size_t len) override {
-      if (!coro)
+      if (!coro) {
         coro = coro_t::pull_type([&](coro_t::push_type& yield) {
           LambdaSink sink([&](const unsigned char* data, size_t len) {
             if (len) {
@@ -182,6 +182,7 @@ std::unique_ptr<Source> sinkToSource(std::function<void(Sink&)> fun,
           });
           fun(sink);
         });
+      }
 
       if (!*coro) {
         eof();
@@ -189,7 +190,9 @@ std::unique_ptr<Source> sinkToSource(std::function<void(Sink&)> fun,
       }
 
       if (pos == cur.size()) {
-        if (!cur.empty()) (*coro)();
+        if (!cur.empty()) {
+          (*coro)();
+        }
         cur = coro->get();
         pos = 0;
       }
@@ -247,10 +250,11 @@ void readPadding(size_t len, Source& source) {
     unsigned char zero[8];
     size_t n = 8 - (len % 8);
     source(zero, n);
-    for (unsigned int i = 0; i < n; i++)
+    for (unsigned int i = 0; i < n; i++) {
       if (zero[i]) {
         throw SerialisationError("non-zero padding");
       }
+    }
   }
 }
 
@@ -284,7 +288,9 @@ template <class T>
 T readStrings(Source& source) {
   auto count = readNum<size_t>(source);
   T ss;
-  while (count--) ss.insert(ss.end(), readString(source));
+  while (count--) {
+    ss.insert(ss.end(), readString(source));
+  }
   return ss;
 }