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-20T21·27+0100
committerVincent Ambo <tazjin@google.com>2020-05-20T21·27+0100
commit689ef502f5b0655c9923ed77da2ae3504630f473 (patch)
tree3e331c153646f136875f047cc3b9f0aad8c86341 /third_party/nix/src/libutil/serialise.cc
parentd331d3a0b5c497a46e2636f308234be66566c04c (diff)
refactor(3p/nix): Apply clang-tidy's readability-* fixes r/788
This applies the readability fixes listed here:

https://clang.llvm.org/extra/clang-tidy/checks/list.html
Diffstat (limited to 'third_party/nix/src/libutil/serialise.cc')
-rw-r--r--third_party/nix/src/libutil/serialise.cc14
1 files changed, 7 insertions, 7 deletions
diff --git a/third_party/nix/src/libutil/serialise.cc b/third_party/nix/src/libutil/serialise.cc
index 0d9b069a2887..4b12367196f1 100644
--- a/third_party/nix/src/libutil/serialise.cc
+++ b/third_party/nix/src/libutil/serialise.cc
@@ -16,7 +16,7 @@ void BufferedSink::operator()(const unsigned char* data, size_t len) {
     buffer = decltype(buffer)(new unsigned char[bufSize]);
   }
 
-  while (len) {
+  while (len != 0u) {
     /* Optimisation: bypass the buffer if the data exceeds the
        buffer size. */
     if (bufPos + len >= bufSize) {
@@ -81,7 +81,7 @@ void FdSink::write(const unsigned char* data, size_t len) {
 bool FdSink::good() { return _good; }
 
 void Source::operator()(unsigned char* data, size_t len) {
-  while (len) {
+  while (len != 0u) {
     size_t n = read(data, len);
     data += n;
     len -= n;
@@ -108,7 +108,7 @@ size_t BufferedSource::read(unsigned char* data, size_t len) {
     buffer = decltype(buffer)(new unsigned char[bufSize]);
   }
 
-  if (!bufPosIn) {
+  if (bufPosIn == 0u) {
     bufPosIn = readUnbuffered(buffer.get(), bufSize);
   }
 
@@ -177,7 +177,7 @@ std::unique_ptr<Source> sinkToSource(std::function<void(Sink&)> fun,
       if (!coro) {
         coro = coro_t::pull_type([&](coro_t::push_type& yield) {
           LambdaSink sink([&](const unsigned char* data, size_t len) {
-            if (len) {
+            if (len != 0u) {
               yield(std::string((const char*)data, len));
             }
           });
@@ -210,7 +210,7 @@ std::unique_ptr<Source> sinkToSource(std::function<void(Sink&)> fun,
 }
 
 void writePadding(size_t len, Sink& sink) {
-  if (len % 8) {
+  if ((len % 8) != 0u) {
     unsigned char zero[8];
     memset(zero, 0, sizeof(zero));
     sink(zero, 8 - (len % 8));
@@ -247,12 +247,12 @@ Sink& operator<<(Sink& sink, const StringSet& s) {
 }
 
 void readPadding(size_t len, Source& source) {
-  if (len % 8) {
+  if ((len % 8) != 0u) {
     unsigned char zero[8];
     size_t n = 8 - (len % 8);
     source(zero, n);
     for (unsigned int i = 0; i < n; i++) {
-      if (zero[i]) {
+      if (zero[i] != 0u) {
         throw SerialisationError("non-zero padding");
       }
     }