update_engine: Run clang-format on payload_consumer

We just did a AOSP merge, so it is a good time to clean things up.

BUG=none
TEST=unittest

Change-Id: I4fe9cef5eb8709344d6b78bc298c0f1c03308ffc
Reviewed-on: https://chromium-review.googlesource.com/1407540
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Amin Hassani <ahassani@chromium.org>
Reviewed-by: Sen Jiang <senj@chromium.org>
Reviewed-by: Xiaochu Liu <xiaochu@chromium.org>
diff --git a/payload_consumer/bzip_extent_writer.cc b/payload_consumer/bzip_extent_writer.cc
index 8926047..0c25c71 100644
--- a/payload_consumer/bzip_extent_writer.cc
+++ b/payload_consumer/bzip_extent_writer.cc
@@ -68,9 +68,8 @@
     if (stream_.avail_out == output_buffer.size())
       break;  // got no new bytes
 
-    TEST_AND_RETURN_FALSE(
-        next_->Write(output_buffer.data(),
-                     output_buffer.size() - stream_.avail_out));
+    TEST_AND_RETURN_FALSE(next_->Write(
+        output_buffer.data(), output_buffer.size() - stream_.avail_out));
 
     if (rc == BZ_STREAM_END)
       CHECK_EQ(stream_.avail_in, 0u);
diff --git a/payload_consumer/bzip_extent_writer.h b/payload_consumer/bzip_extent_writer.h
index 023db75..ec181a7 100644
--- a/payload_consumer/bzip_extent_writer.h
+++ b/payload_consumer/bzip_extent_writer.h
@@ -47,7 +47,7 @@
 
  private:
   std::unique_ptr<ExtentWriter> next_;  // The underlying ExtentWriter.
-  bz_stream stream_;  // the libbz2 stream
+  bz_stream stream_;                    // the libbz2 stream
   brillo::Blob input_buffer_;
 };
 
diff --git a/payload_consumer/bzip_extent_writer_unittest.cc b/payload_consumer/bzip_extent_writer_unittest.cc
index c121e11..125e1e5 100644
--- a/payload_consumer/bzip_extent_writer_unittest.cc
+++ b/payload_consumer/bzip_extent_writer_unittest.cc
@@ -46,9 +46,7 @@
     fd_.reset(new EintrSafeFileDescriptor);
     ASSERT_TRUE(fd_->Open(temp_file_.path().c_str(), O_RDWR, 0600));
   }
-  void TearDown() override {
-    fd_->Close();
-  }
+  void TearDown() override { fd_->Close(); }
 
   FileDescriptorPtr fd_;
   test_utils::ScopedTempFile temp_file_{"BzipExtentWriterTest-file.XXXXXX"};
@@ -60,10 +58,10 @@
   // 'echo test | bzip2 | hexdump' yields:
   static const char test_uncompressed[] = "test\n";
   static const uint8_t test[] = {
-    0x42, 0x5a, 0x68, 0x39, 0x31, 0x41, 0x59, 0x26, 0x53, 0x59, 0xcc, 0xc3,
-    0x71, 0xd4, 0x00, 0x00, 0x02, 0x41, 0x80, 0x00, 0x10, 0x02, 0x00, 0x0c,
-    0x00, 0x20, 0x00, 0x21, 0x9a, 0x68, 0x33, 0x4d, 0x19, 0x97, 0x8b, 0xb9,
-    0x22, 0x9c, 0x28, 0x48, 0x66, 0x61, 0xb8, 0xea, 0x00,
+      0x42, 0x5a, 0x68, 0x39, 0x31, 0x41, 0x59, 0x26, 0x53, 0x59, 0xcc, 0xc3,
+      0x71, 0xd4, 0x00, 0x00, 0x02, 0x41, 0x80, 0x00, 0x10, 0x02, 0x00, 0x0c,
+      0x00, 0x20, 0x00, 0x21, 0x9a, 0x68, 0x33, 0x4d, 0x19, 0x97, 0x8b, 0xb9,
+      0x22, 0x9c, 0x28, 0x48, 0x66, 0x61, 0xb8, 0xea, 0x00,
   };
 
   BzipExtentWriter bzip_writer(std::make_unique<DirectExtentWriter>());
diff --git a/payload_consumer/delta_performer.cc b/payload_consumer/delta_performer.cc
index 2834e61..f405bd9 100644
--- a/payload_consumer/delta_performer.cc
+++ b/payload_consumer/delta_performer.cc
@@ -176,7 +176,6 @@
 
 }  // namespace
 
-
 // Computes the ratio of |part| and |total|, scaled to |norm|, using integer
 // arithmetic.
 static uint64_t IntRatio(uint64_t part, uint64_t total, uint64_t norm) {
@@ -190,10 +189,9 @@
   if (num_total_operations_) {
     total_operations_str = std::to_string(num_total_operations_);
     // Upcasting to 64-bit to avoid overflow, back to size_t for formatting.
-    completed_percentage_str =
-        base::StringPrintf(" (%" PRIu64 "%%)",
-                           IntRatio(next_operation_num_, num_total_operations_,
-                                    100));
+    completed_percentage_str = base::StringPrintf(
+        " (%" PRIu64 "%%)",
+        IntRatio(next_operation_num_, num_total_operations_, 100));
   }
 
   // Format download total count and percentage.
@@ -203,15 +201,14 @@
   if (payload_size) {
     payload_size_str = std::to_string(payload_size);
     // Upcasting to 64-bit to avoid overflow, back to size_t for formatting.
-    downloaded_percentage_str =
-        base::StringPrintf(" (%" PRIu64 "%%)",
-                           IntRatio(total_bytes_received_, payload_size, 100));
+    downloaded_percentage_str = base::StringPrintf(
+        " (%" PRIu64 "%%)", IntRatio(total_bytes_received_, payload_size, 100));
   }
 
   LOG(INFO) << (message_prefix ? message_prefix : "") << next_operation_num_
             << "/" << total_operations_str << " operations"
-            << completed_percentage_str << ", " << total_bytes_received_
-            << "/" << payload_size_str << " bytes downloaded"
+            << completed_percentage_str << ", " << total_bytes_received_ << "/"
+            << payload_size_str << " bytes downloaded"
             << downloaded_percentage_str << ", overall progress "
             << overall_progress_ << "%";
 }
@@ -235,10 +232,10 @@
   size_t payload_size = payload_->size;
   unsigned actual_operations_weight = kProgressOperationsWeight;
   if (payload_size)
-    new_overall_progress += min(
-        static_cast<unsigned>(IntRatio(total_bytes_received_, payload_size,
-                                       kProgressDownloadWeight)),
-        kProgressDownloadWeight);
+    new_overall_progress +=
+        min(static_cast<unsigned>(IntRatio(
+                total_bytes_received_, payload_size, kProgressDownloadWeight)),
+            kProgressDownloadWeight);
   else
     actual_operations_weight += kProgressDownloadWeight;
 
@@ -246,8 +243,8 @@
   // expect an update to have at least one operation, so the expectation is that
   // this will eventually reach |actual_operations_weight|.
   if (num_total_operations_)
-    new_overall_progress += IntRatio(next_operation_num_, num_total_operations_,
-                                     actual_operations_weight);
+    new_overall_progress += IntRatio(
+        next_operation_num_, num_total_operations_, actual_operations_weight);
 
   // Progress ratio cannot recede, unless our assumptions about the total
   // payload size, total number of operations, or the monotonicity of progress
@@ -272,8 +269,8 @@
   last_progress_chunk_ = curr_progress_chunk;
 }
 
-
-size_t DeltaPerformer::CopyDataToBuffer(const char** bytes_p, size_t* count_p,
+size_t DeltaPerformer::CopyDataToBuffer(const char** bytes_p,
+                                        size_t* count_p,
                                         size_t max) {
   const size_t count = *count_p;
   if (!count)
@@ -288,8 +285,8 @@
   return read_len;
 }
 
-
-bool DeltaPerformer::HandleOpResult(bool op_result, const char* op_type_name,
+bool DeltaPerformer::HandleOpResult(bool op_result,
+                                    const char* op_type_name,
                                     ErrorCode* error) {
   if (op_result)
     return true;
@@ -308,8 +305,9 @@
 
 int DeltaPerformer::Close() {
   int err = -CloseCurrentPartition();
-  LOG_IF(ERROR, !payload_hash_calculator_.Finalize() ||
-                !signed_hash_calculator_.Finalize())
+  LOG_IF(ERROR,
+         !payload_hash_calculator_.Finalize() ||
+             !signed_hash_calculator_.Finalize())
       << "Unable to finalize the hash.";
   if (!buffer_.empty()) {
     LOG(INFO) << "Discarding " << buffer_.size() << " unused downloaded bytes";
@@ -560,19 +558,18 @@
   return MetadataParseResult::kSuccess;
 }
 
-#define OP_DURATION_HISTOGRAM(_op_name, _start_time)      \
-    LOCAL_HISTOGRAM_CUSTOM_TIMES(                         \
-        "UpdateEngine.DownloadAction.InstallOperation::"  \
-        _op_name ".Duration",                             \
-        base::TimeTicks::Now() - _start_time,             \
-        base::TimeDelta::FromMilliseconds(10),            \
-        base::TimeDelta::FromMinutes(5),                  \
-        20);
+#define OP_DURATION_HISTOGRAM(_op_name, _start_time)                         \
+  LOCAL_HISTOGRAM_CUSTOM_TIMES(                                              \
+      "UpdateEngine.DownloadAction.InstallOperation::" _op_name ".Duration", \
+      base::TimeTicks::Now() - _start_time,                                  \
+      base::TimeDelta::FromMilliseconds(10),                                 \
+      base::TimeDelta::FromMinutes(5),                                       \
+      20);
 
 // Wrapper around write. Returns true if all requested bytes
 // were written, or false on any error, regardless of progress
 // and stores an action exit code in |error|.
-bool DeltaPerformer::Write(const void* bytes, size_t count, ErrorCode *error) {
+bool DeltaPerformer::Write(const void* bytes, size_t count, ErrorCode* error) {
   *error = ErrorCode::kSuccess;
   const char* c_bytes = reinterpret_cast<const char*>(bytes);
 
@@ -584,9 +581,11 @@
     // Read data up to the needed limit; this is either maximium payload header
     // size, or the full metadata size (once it becomes known).
     const bool do_read_header = !IsHeaderParsed();
-    CopyDataToBuffer(&c_bytes, &count,
-                     (do_read_header ? kMaxPayloadHeaderSize :
-                      metadata_size_ + metadata_signature_size_));
+    CopyDataToBuffer(
+        &c_bytes,
+        &count,
+        (do_read_header ? kMaxPayloadHeaderSize
+                        : metadata_size_ + metadata_signature_size_));
 
     MetadataParseResult result = ParsePayloadMetadata(buffer_, error);
     if (result == MetadataParseResult::kError)
@@ -626,11 +625,12 @@
       acc_num_operations_.push_back(num_total_operations_);
     }
 
-    LOG_IF(WARNING, !prefs_->SetInt64(kPrefsManifestMetadataSize,
-                                      metadata_size_))
+    LOG_IF(WARNING,
+           !prefs_->SetInt64(kPrefsManifestMetadataSize, metadata_size_))
         << "Unable to save the manifest metadata size.";
-    LOG_IF(WARNING, !prefs_->SetInt64(kPrefsManifestSignatureSize,
-                                      metadata_signature_size_))
+    LOG_IF(WARNING,
+           !prefs_->SetInt64(kPrefsManifestSignatureSize,
+                             metadata_signature_size_))
         << "Unable to save the manifest signature size.";
 
     if (!PrimeUpdateState()) {
@@ -671,8 +671,9 @@
         return false;
       }
     }
-    const size_t partition_operation_num = next_operation_num_ - (
-        current_partition_ ? acc_num_operations_[current_partition_ - 1] : 0);
+    const size_t partition_operation_num =
+        next_operation_num_ -
+        (current_partition_ ? acc_num_operations_[current_partition_ - 1] : 0);
 
     const InstallOperation& op =
         partitions_[current_partition_].operations(partition_operation_num);
@@ -769,8 +770,7 @@
     if (manifest_.signatures_offset() != buffer_offset_) {
       LOG(ERROR) << "Payload signatures offset points to blob offset "
                  << manifest_.signatures_offset()
-                 << " but signatures are expected at offset "
-                 << buffer_offset_;
+                 << " but signatures are expected at offset " << buffer_offset_;
       *error = ErrorCode::kDownloadPayloadVerificationError;
       return false;
     }
@@ -1044,7 +1044,7 @@
   bool attempt_ioctl = true;
   int request =
       (operation.type() == InstallOperation::ZERO ? BLKZEROOUT : BLKDISCARD);
-#else  // !defined(BLKZEROOUT)
+#else   // !defined(BLKZEROOUT)
   bool attempt_ioctl = false;
   int request = 0;
 #endif  // !defined(BLKZEROOUT)
@@ -1062,8 +1062,8 @@
     // In case of failure, we fall back to writing 0 to the selected region.
     zeros.resize(16 * block_size_);
     for (uint64_t offset = 0; offset < length; offset += zeros.size()) {
-      uint64_t chunk_length = min(length - offset,
-                                  static_cast<uint64_t>(zeros.size()));
+      uint64_t chunk_length =
+          min(length - offset, static_cast<uint64_t>(zeros.size()));
       TEST_AND_RETURN_FALSE(utils::PWriteAll(
           target_fd_, zeros.data(), chunk_length, start + offset));
     }
@@ -1100,8 +1100,8 @@
                                           bytes,
                                           extent.start_block() * block_size_,
                                           &bytes_read_this_iteration));
-    TEST_AND_RETURN_FALSE(
-        bytes_read_this_iteration == static_cast<ssize_t>(bytes));
+    TEST_AND_RETURN_FALSE(bytes_read_this_iteration ==
+                          static_cast<ssize_t>(bytes));
     bytes_read += bytes_read_this_iteration;
   }
 
@@ -1573,8 +1573,7 @@
   TEST_AND_RETURN_FALSE(buffer_offset_ == manifest_.signatures_offset());
   TEST_AND_RETURN_FALSE(buffer_.size() >= manifest_.signatures_size());
   signatures_message_data_.assign(
-      buffer_.begin(),
-      buffer_.begin() + manifest_.signatures_size());
+      buffer_.begin(), buffer_.begin() + manifest_.signatures_size());
 
   // Save the signature blob because if the update is interrupted after the
   // download phase we don't go through this path anymore. Some alternatives to
@@ -1585,9 +1584,10 @@
   //
   // 2. Verify the signature as soon as it's received and don't checkpoint the
   // blob and the signed sha-256 context.
-  LOG_IF(WARNING, !prefs_->SetString(kPrefsUpdateStateSignatureBlob,
-                                     string(signatures_message_data_.begin(),
-                                            signatures_message_data_.end())))
+  LOG_IF(WARNING,
+         !prefs_->SetString(kPrefsUpdateStateSignatureBlob,
+                            string(signatures_message_data_.begin(),
+                                   signatures_message_data_.end())))
       << "Unable to store the signature blob.";
 
   LOG(INFO) << "Extracted signature data of size "
@@ -1666,10 +1666,8 @@
   }
 
   if (major_payload_version_ != kChromeOSMajorPayloadVersion) {
-    if (manifest_.has_old_rootfs_info() ||
-        manifest_.has_new_rootfs_info() ||
-        manifest_.has_old_kernel_info() ||
-        manifest_.has_new_kernel_info() ||
+    if (manifest_.has_old_rootfs_info() || manifest_.has_new_rootfs_info() ||
+        manifest_.has_old_kernel_info() || manifest_.has_new_kernel_info() ||
         manifest_.install_operations_size() != 0 ||
         manifest_.kernel_install_operations_size() != 0) {
       LOG(ERROR) << "Manifest contains deprecated field only supported in "
@@ -1766,12 +1764,12 @@
   return ErrorCode::kSuccess;
 }
 
-#define TEST_AND_RETURN_VAL(_retval, _condition)                \
-  do {                                                          \
-    if (!(_condition)) {                                        \
-      LOG(ERROR) << "VerifyPayload failure: " << #_condition;   \
-      return _retval;                                           \
-    }                                                           \
+#define TEST_AND_RETURN_VAL(_retval, _condition)              \
+  do {                                                        \
+    if (!(_condition)) {                                      \
+      LOG(ERROR) << "VerifyPayload failure: " << #_condition; \
+      return _retval;                                         \
+    }                                                         \
   } while (0);
 
 ErrorCode DeltaPerformer::VerifyPayload(
@@ -1843,8 +1841,7 @@
                                      const string& update_check_response_hash) {
   int64_t next_operation = kUpdateStateOperationInvalid;
   if (!(prefs->GetInt64(kPrefsUpdateStateNextOperation, &next_operation) &&
-        next_operation != kUpdateStateOperationInvalid &&
-        next_operation > 0))
+        next_operation != kUpdateStateOperationInvalid && next_operation > 0))
     return false;
 
   string interrupted_hash;
@@ -1916,33 +1913,33 @@
   if (last_updated_buffer_offset_ != buffer_offset_) {
     // Resets the progress in case we die in the middle of the state update.
     ResetUpdateProgress(prefs_, true);
-    TEST_AND_RETURN_FALSE(
-        prefs_->SetString(kPrefsUpdateStateSHA256Context,
-                          payload_hash_calculator_.GetContext()));
+    TEST_AND_RETURN_FALSE(prefs_->SetString(
+        kPrefsUpdateStateSHA256Context, payload_hash_calculator_.GetContext()));
     TEST_AND_RETURN_FALSE(
         prefs_->SetString(kPrefsUpdateStateSignedSHA256Context,
                           signed_hash_calculator_.GetContext()));
-    TEST_AND_RETURN_FALSE(prefs_->SetInt64(kPrefsUpdateStateNextDataOffset,
-                                           buffer_offset_));
+    TEST_AND_RETURN_FALSE(
+        prefs_->SetInt64(kPrefsUpdateStateNextDataOffset, buffer_offset_));
     last_updated_buffer_offset_ = buffer_offset_;
 
     if (next_operation_num_ < num_total_operations_) {
       size_t partition_index = current_partition_;
       while (next_operation_num_ >= acc_num_operations_[partition_index])
         partition_index++;
-      const size_t partition_operation_num = next_operation_num_ - (
-          partition_index ? acc_num_operations_[partition_index - 1] : 0);
+      const size_t partition_operation_num =
+          next_operation_num_ -
+          (partition_index ? acc_num_operations_[partition_index - 1] : 0);
       const InstallOperation& op =
           partitions_[partition_index].operations(partition_operation_num);
-      TEST_AND_RETURN_FALSE(prefs_->SetInt64(kPrefsUpdateStateNextDataLength,
-                                             op.data_length()));
+      TEST_AND_RETURN_FALSE(
+          prefs_->SetInt64(kPrefsUpdateStateNextDataLength, op.data_length()));
     } else {
-      TEST_AND_RETURN_FALSE(prefs_->SetInt64(kPrefsUpdateStateNextDataLength,
-                                             0));
+      TEST_AND_RETURN_FALSE(
+          prefs_->SetInt64(kPrefsUpdateStateNextDataLength, 0));
     }
   }
-  TEST_AND_RETURN_FALSE(prefs_->SetInt64(kPrefsUpdateStateNextOperation,
-                                         next_operation_num_));
+  TEST_AND_RETURN_FALSE(
+      prefs_->SetInt64(kPrefsUpdateStateNextOperation, next_operation_num_));
   return true;
 }
 
@@ -1951,8 +1948,7 @@
 
   int64_t next_operation = kUpdateStateOperationInvalid;
   if (!prefs_->GetInt64(kPrefsUpdateStateNextOperation, &next_operation) ||
-      next_operation == kUpdateStateOperationInvalid ||
-      next_operation <= 0) {
+      next_operation == kUpdateStateOperationInvalid || next_operation <= 0) {
     // Initiating a new update, no more state needs to be initialized.
     return true;
   }
@@ -1960,9 +1956,9 @@
 
   // Resuming an update -- load the rest of the update state.
   int64_t next_data_offset = -1;
-  TEST_AND_RETURN_FALSE(prefs_->GetInt64(kPrefsUpdateStateNextDataOffset,
-                                         &next_data_offset) &&
-                        next_data_offset >= 0);
+  TEST_AND_RETURN_FALSE(
+      prefs_->GetInt64(kPrefsUpdateStateNextDataOffset, &next_data_offset) &&
+      next_data_offset >= 0);
   buffer_offset_ = next_data_offset;
 
   // The signed hash context and the signature blob may be empty if the
@@ -1981,14 +1977,14 @@
   }
 
   string hash_context;
-  TEST_AND_RETURN_FALSE(prefs_->GetString(kPrefsUpdateStateSHA256Context,
-                                          &hash_context) &&
-                        payload_hash_calculator_.SetContext(hash_context));
+  TEST_AND_RETURN_FALSE(
+      prefs_->GetString(kPrefsUpdateStateSHA256Context, &hash_context) &&
+      payload_hash_calculator_.SetContext(hash_context));
 
   int64_t manifest_metadata_size = 0;
-  TEST_AND_RETURN_FALSE(prefs_->GetInt64(kPrefsManifestMetadataSize,
-                                         &manifest_metadata_size) &&
-                        manifest_metadata_size > 0);
+  TEST_AND_RETURN_FALSE(
+      prefs_->GetInt64(kPrefsManifestMetadataSize, &manifest_metadata_size) &&
+      manifest_metadata_size > 0);
   metadata_size_ = manifest_metadata_size;
 
   int64_t manifest_signature_size = 0;
diff --git a/payload_consumer/delta_performer.h b/payload_consumer/delta_performer.h
index 402e4be..55cb2a4 100644
--- a/payload_consumer/delta_performer.h
+++ b/payload_consumer/delta_performer.h
@@ -86,7 +86,7 @@
 
   // FileWriter's Write implementation that returns a more specific |error| code
   // in case of failures in Write operation.
-  bool Write(const void* bytes, size_t count, ErrorCode *error) override;
+  bool Write(const void* bytes, size_t count, ErrorCode* error) override;
 
   // Wrapper around close. Returns 0 on success or -errno on error.
   // Closes both 'path' given to Open() and the kernel path.
@@ -192,7 +192,8 @@
 
   // If |op_result| is false, emits an error message using |op_type_name| and
   // sets |*error| accordingly. Otherwise does nothing. Returns |op_result|.
-  bool HandleOpResult(bool op_result, const char* op_type_name,
+  bool HandleOpResult(bool op_result,
+                      const char* op_type_name,
                       ErrorCode* error);
 
   // Logs the progress of downloading/applying an update.
diff --git a/payload_consumer/delta_performer_integration_test.cc b/payload_consumer/delta_performer_integration_test.cc
index 0912764..e064077 100644
--- a/payload_consumer/delta_performer_integration_test.cc
+++ b/payload_consumer/delta_performer_integration_test.cc
@@ -50,11 +50,11 @@
 using std::string;
 using std::vector;
 using test_utils::GetBuildArtifactsPath;
+using test_utils::kRandomString;
 using test_utils::ScopedLoopMounter;
 using test_utils::System;
-using test_utils::kRandomString;
-using testing::Return;
 using testing::_;
+using testing::Return;
 
 extern const char* kUnittestPrivateKeyPath;
 extern const char* kUnittestPublicKeyPath;
@@ -62,8 +62,10 @@
 extern const char* kUnittestPublicKey2Path;
 
 static const uint32_t kDefaultKernelSize = 4096;  // Something small for a test
+// clang-format off
 static const uint8_t kNewData[] = {'T', 'h', 'i', 's', ' ', 'i', 's', ' ',
                                    'n', 'e', 'w', ' ', 'd', 'a', 't', 'a', '.'};
+// clang-format on
 
 namespace {
 struct DeltaState {
@@ -99,13 +101,13 @@
 };
 
 enum SignatureTest {
-  kSignatureNone,  // No payload signing.
-  kSignatureGenerator,  // Sign the payload at generation time.
-  kSignatureGenerated,  // Sign the payload after it's generated.
+  kSignatureNone,                  // No payload signing.
+  kSignatureGenerator,             // Sign the payload at generation time.
+  kSignatureGenerated,             // Sign the payload after it's generated.
   kSignatureGeneratedPlaceholder,  // Insert placeholder signatures, then real.
   kSignatureGeneratedPlaceholderMismatch,  // Insert a wrong sized placeholder.
   kSignatureGeneratedShell,  // Sign the generated payload through shell cmds.
-  kSignatureGeneratedShellBadKey,  // Sign with a bad key through shell cmds.
+  kSignatureGeneratedShellBadKey,     // Sign with a bad key through shell cmds.
   kSignatureGeneratedShellRotateCl1,  // Rotate key, test client v1
   kSignatureGeneratedShellRotateCl2,  // Rotate key, test client v2
 };
@@ -119,7 +121,8 @@
 
 class DeltaPerformerIntegrationTest : public ::testing::Test {};
 
-static void CompareFilesByBlock(const string& a_file, const string& b_file,
+static void CompareFilesByBlock(const string& a_file,
+                                const string& b_file,
                                 size_t image_size) {
   EXPECT_EQ(0U, image_size % kBlockSize);
 
@@ -133,7 +136,7 @@
     EXPECT_EQ(0U, i % kBlockSize);
     brillo::Blob a_sub(&a_data[i], &a_data[i + kBlockSize]);
     brillo::Blob b_sub(&b_data[i], &b_data[i + kBlockSize]);
-    EXPECT_TRUE(a_sub == b_sub) << "Block " << (i/kBlockSize) << " differs";
+    EXPECT_TRUE(a_sub == b_sub) << "Block " << (i / kBlockSize) << " differs";
   }
   if (::testing::Test::HasNonfatalFailure()) {
     LOG(INFO) << "Compared filesystems with size " << image_size
@@ -166,9 +169,7 @@
   brillo::Blob hash;
   EXPECT_TRUE(HashCalculator::RawHashOfData(data, &hash));
   brillo::Blob signature;
-  EXPECT_TRUE(PayloadSigner::SignHash(hash,
-                                      private_key_path,
-                                      &signature));
+  EXPECT_TRUE(PayloadSigner::SignHash(hash, private_key_path, &signature));
   return signature.size();
 }
 
@@ -179,11 +180,7 @@
   signatures.push_back(brillo::Blob(signature_size, 0));
 
   return PayloadSigner::AddSignatureToPayload(
-      payload_path,
-      signatures,
-      {},
-      payload_path,
-      out_metadata_size);
+      payload_path, signatures, {}, payload_path, out_metadata_size);
 }
 
 static void SignGeneratedPayload(const string& payload_path,
@@ -205,9 +202,7 @@
                                       const string& payload_path) {
   string private_key_path = GetBuildArtifactsPath(kUnittestPrivateKeyPath);
   if (signature_test == kSignatureGeneratedShellBadKey) {
-    ASSERT_TRUE(utils::MakeTempFile("key.XXXXXX",
-                                    &private_key_path,
-                                    nullptr));
+    ASSERT_TRUE(utils::MakeTempFile("key.XXXXXX", &private_key_path, nullptr));
   } else {
     ASSERT_TRUE(signature_test == kSignatureGeneratedShell ||
                 signature_test == kSignatureGeneratedShellRotateCl1 ||
@@ -239,8 +234,8 @@
   string signature_size_string;
   if (signature_test == kSignatureGeneratedShellRotateCl1 ||
       signature_test == kSignatureGeneratedShellRotateCl2)
-    signature_size_string = base::StringPrintf("%d:%d",
-                                               signature_size, signature_size);
+    signature_size_string =
+        base::StringPrintf("%d:%d", signature_size, signature_size);
   else
     signature_size_string = base::StringPrintf("%d", signature_size);
   string delta_generator_path = GetBuildArtifactsPath("delta_generator");
@@ -299,7 +294,7 @@
                               bool noop,
                               ssize_t chunk_size,
                               SignatureTest signature_test,
-                              DeltaState *state,
+                              DeltaState* state,
                               uint32_t minor_version) {
   EXPECT_TRUE(utils::MakeTempFile("a_img.XXXXXX", &state->a_img, nullptr));
   EXPECT_TRUE(utils::MakeTempFile("b_img.XXXXXX", &state->b_img, nullptr));
@@ -343,12 +338,13 @@
     brillo::Blob hardtocompress;
     while (hardtocompress.size() < 3 * kBlockSize) {
       hardtocompress.insert(hardtocompress.end(),
-                            std::begin(kRandomString), std::end(kRandomString));
+                            std::begin(kRandomString),
+                            std::end(kRandomString));
     }
-    EXPECT_TRUE(utils::WriteFile(base::StringPrintf("%s/hardtocompress",
-                                                    a_mnt.c_str()).c_str(),
-                                 hardtocompress.data(),
-                                 hardtocompress.size()));
+    EXPECT_TRUE(utils::WriteFile(
+        base::StringPrintf("%s/hardtocompress", a_mnt.c_str()).c_str(),
+        hardtocompress.data(),
+        hardtocompress.size()));
 
     brillo::Blob zeros(16 * 1024, 0);
     EXPECT_EQ(static_cast<int>(zeros.size()),
@@ -357,9 +353,8 @@
                               reinterpret_cast<const char*>(zeros.data()),
                               zeros.size()));
 
-    EXPECT_TRUE(
-        WriteSparseFile(base::StringPrintf("%s/move-from-sparse",
-                                           a_mnt.c_str()), 16 * 1024));
+    EXPECT_TRUE(WriteSparseFile(
+        base::StringPrintf("%s/move-from-sparse", a_mnt.c_str()), 16 * 1024));
 
     EXPECT_TRUE(WriteByteAtOffset(
         base::StringPrintf("%s/move-semi-sparse", a_mnt.c_str()), 4096));
@@ -367,10 +362,10 @@
     // Write 1 MiB of 0xff to try to catch the case where writing a bsdiff
     // patch fails to zero out the final block.
     brillo::Blob ones(1024 * 1024, 0xff);
-    EXPECT_TRUE(utils::WriteFile(base::StringPrintf("%s/ones",
-                                                    a_mnt.c_str()).c_str(),
-                                 ones.data(),
-                                 ones.size()));
+    EXPECT_TRUE(
+        utils::WriteFile(base::StringPrintf("%s/ones", a_mnt.c_str()).c_str(),
+                         ones.data(),
+                         ones.size()));
   }
 
   if (noop) {
@@ -381,9 +376,8 @@
     if (minor_version == kSourceMinorPayloadVersion) {
       // Create a result image with image_size bytes of garbage.
       brillo::Blob ones(state->image_size, 0xff);
-      EXPECT_TRUE(utils::WriteFile(state->result_img.c_str(),
-                                   ones.data(),
-                                   ones.size()));
+      EXPECT_TRUE(utils::WriteFile(
+          state->result_img.c_str(), ones.data(), ones.size()));
       EXPECT_EQ(utils::FileSize(state->a_img),
                 utils::FileSize(state->result_img));
     }
@@ -433,28 +427,26 @@
     brillo::Blob hardtocompress;
     while (hardtocompress.size() < 3 * kBlockSize) {
       hardtocompress.insert(hardtocompress.end(),
-                            std::begin(kRandomString), std::end(kRandomString));
+                            std::begin(kRandomString),
+                            std::end(kRandomString));
     }
-    EXPECT_TRUE(utils::WriteFile(base::StringPrintf("%s/hardtocompress",
-                                              b_mnt.c_str()).c_str(),
-                                 hardtocompress.data(),
-                                 hardtocompress.size()));
+    EXPECT_TRUE(utils::WriteFile(
+        base::StringPrintf("%s/hardtocompress", b_mnt.c_str()).c_str(),
+        hardtocompress.data(),
+        hardtocompress.size()));
   }
 
   string old_kernel;
-  EXPECT_TRUE(utils::MakeTempFile("old_kernel.XXXXXX",
-                                  &state->old_kernel,
-                                  nullptr));
+  EXPECT_TRUE(
+      utils::MakeTempFile("old_kernel.XXXXXX", &state->old_kernel, nullptr));
 
   string new_kernel;
-  EXPECT_TRUE(utils::MakeTempFile("new_kernel.XXXXXX",
-                                  &state->new_kernel,
-                                  nullptr));
+  EXPECT_TRUE(
+      utils::MakeTempFile("new_kernel.XXXXXX", &state->new_kernel, nullptr));
 
   string result_kernel;
-  EXPECT_TRUE(utils::MakeTempFile("result_kernel.XXXXXX",
-                                  &state->result_kernel,
-                                  nullptr));
+  EXPECT_TRUE(utils::MakeTempFile(
+      "result_kernel.XXXXXX", &state->result_kernel, nullptr));
 
   state->kernel_size = kDefaultKernelSize;
   state->old_kernel_data.resize(kDefaultKernelSize);
@@ -465,8 +457,8 @@
   test_utils::FillWithData(&state->result_kernel_data);
 
   // change the new kernel data
-  std::copy(std::begin(kNewData), std::end(kNewData),
-            state->new_kernel_data.begin());
+  std::copy(
+      std::begin(kNewData), std::end(kNewData), state->new_kernel_data.begin());
 
   if (noop) {
     state->old_kernel_data = state->new_kernel_data;
@@ -483,9 +475,7 @@
                                state->result_kernel_data.data(),
                                state->result_kernel_data.size()));
 
-  EXPECT_TRUE(utils::MakeTempFile("delta.XXXXXX",
-                                  &state->delta_path,
-                                  nullptr));
+  EXPECT_TRUE(utils::MakeTempFile("delta.XXXXXX", &state->delta_path, nullptr));
   LOG(INFO) << "delta path: " << state->delta_path;
   {
     const string private_key =
@@ -524,20 +514,18 @@
       EXPECT_TRUE(part.OpenFilesystem());
 
     EXPECT_TRUE(payload_config.Validate());
-    EXPECT_TRUE(
-        GenerateUpdatePayloadFile(
-            payload_config,
-            state->delta_path,
-            private_key,
-            &state->metadata_size));
+    EXPECT_TRUE(GenerateUpdatePayloadFile(
+        payload_config, state->delta_path, private_key, &state->metadata_size));
   }
   // Extend the "partitions" holding the file system a bit.
-  EXPECT_EQ(0, HANDLE_EINTR(truncate(state->a_img.c_str(),
-                                     state->image_size + 1024 * 1024)));
+  EXPECT_EQ(0,
+            HANDLE_EINTR(truncate(state->a_img.c_str(),
+                                  state->image_size + 1024 * 1024)));
   EXPECT_EQ(static_cast<off_t>(state->image_size + 1024 * 1024),
             utils::FileSize(state->a_img));
-  EXPECT_EQ(0, HANDLE_EINTR(truncate(state->b_img.c_str(),
-                                     state->image_size + 1024 * 1024)));
+  EXPECT_EQ(0,
+            HANDLE_EINTR(truncate(state->b_img.c_str(),
+                                  state->image_size + 1024 * 1024)));
   EXPECT_EQ(static_cast<off_t>(state->image_size + 1024 * 1024),
             utils::FileSize(state->b_img));
 
@@ -546,14 +534,14 @@
     int signature_size =
         GetSignatureSize(GetBuildArtifactsPath(kUnittestPrivateKeyPath));
     LOG(INFO) << "Inserting placeholder signature.";
-    ASSERT_TRUE(InsertSignaturePlaceholder(signature_size, state->delta_path,
-                                           &state->metadata_size));
+    ASSERT_TRUE(InsertSignaturePlaceholder(
+        signature_size, state->delta_path, &state->metadata_size));
 
     if (signature_test == kSignatureGeneratedPlaceholderMismatch) {
       signature_size -= 1;
       LOG(INFO) << "Inserting mismatched placeholder signature.";
-      ASSERT_FALSE(InsertSignaturePlaceholder(signature_size, state->delta_path,
-                                              &state->metadata_size));
+      ASSERT_FALSE(InsertSignaturePlaceholder(
+          signature_size, state->delta_path, &state->metadata_size));
       return;
     }
   }
@@ -574,8 +562,11 @@
   }
 }
 
-static void ApplyDeltaFile(bool full_kernel, bool full_rootfs, bool noop,
-                           SignatureTest signature_test, DeltaState* state,
+static void ApplyDeltaFile(bool full_kernel,
+                           bool full_rootfs,
+                           bool noop,
+                           SignatureTest signature_test,
+                           DeltaState* state,
                            bool hash_checks_mandatory,
                            OperationHashTest op_hash_test,
                            DeltaPerformer** performer,
@@ -615,8 +606,7 @@
         key_paths.push_back(GetBuildArtifactsPath(kUnittestPrivateKey2Path));
       }
       EXPECT_TRUE(PayloadSigner::SignatureBlobLength(
-          key_paths,
-          &expected_sig_data_length));
+          key_paths, &expected_sig_data_length));
       EXPECT_EQ(expected_sig_data_length, manifest.signatures_size());
       EXPECT_FALSE(signature.data().empty());
     }
@@ -663,7 +653,6 @@
       }
     }
 
-
     if (full_rootfs) {
       EXPECT_FALSE(manifest.has_old_rootfs_info());
       EXPECT_FALSE(manifest.has_old_image_info());
@@ -681,8 +670,8 @@
   }
 
   MockPrefs prefs;
-  EXPECT_CALL(prefs, SetInt64(kPrefsManifestMetadataSize,
-                              state->metadata_size)).WillOnce(Return(true));
+  EXPECT_CALL(prefs, SetInt64(kPrefsManifestMetadataSize, state->metadata_size))
+      .WillOnce(Return(true));
   EXPECT_CALL(prefs, SetInt64(kPrefsManifestSignatureSize, 0))
       .WillOnce(Return(true));
   EXPECT_CALL(prefs, SetInt64(kPrefsUpdateStateNextOperation, _))
@@ -745,12 +734,9 @@
 
   EXPECT_EQ(static_cast<off_t>(state->image_size),
             HashCalculator::RawHashOfFile(
-                state->a_img,
-                state->image_size,
-                &root_part.source_hash));
-  EXPECT_TRUE(HashCalculator::RawHashOfData(
-                  state->old_kernel_data,
-                  &kernel_part.source_hash));
+                state->a_img, state->image_size, &root_part.source_hash));
+  EXPECT_TRUE(HashCalculator::RawHashOfData(state->old_kernel_data,
+                                            &kernel_part.source_hash));
 
   // The partitions should be empty before DeltaPerformer.
   install_plan->partitions.clear();
@@ -801,9 +787,8 @@
   const size_t kBytesPerWrite = 5;
   for (size_t i = 0; i < state->delta.size(); i += kBytesPerWrite) {
     size_t count = std::min(state->delta.size() - i, kBytesPerWrite);
-    bool write_succeeded = ((*performer)->Write(&state->delta[i],
-                                                count,
-                                                &actual_error));
+    bool write_succeeded =
+        ((*performer)->Write(&state->delta[i], count, &actual_error));
     // Normally write_succeeded should be true every time and
     // actual_error should be ErrorCode::kSuccess. If so, continue the loop.
     // But if we seeded an operation hash error above, then write_succeeded
@@ -855,22 +840,21 @@
 
   brillo::Blob updated_kernel_partition;
   if (minor_version == kSourceMinorPayloadVersion) {
-    CompareFilesByBlock(state->result_kernel, state->new_kernel,
-                        state->kernel_size);
-    CompareFilesByBlock(state->result_img, state->b_img,
-                        state->image_size);
-    EXPECT_TRUE(utils::ReadFile(state->result_kernel,
-                                &updated_kernel_partition));
+    CompareFilesByBlock(
+        state->result_kernel, state->new_kernel, state->kernel_size);
+    CompareFilesByBlock(state->result_img, state->b_img, state->image_size);
+    EXPECT_TRUE(
+        utils::ReadFile(state->result_kernel, &updated_kernel_partition));
   } else {
-    CompareFilesByBlock(state->old_kernel, state->new_kernel,
-                        state->kernel_size);
-    CompareFilesByBlock(state->a_img, state->b_img,
-                        state->image_size);
+    CompareFilesByBlock(
+        state->old_kernel, state->new_kernel, state->kernel_size);
+    CompareFilesByBlock(state->a_img, state->b_img, state->image_size);
     EXPECT_TRUE(utils::ReadFile(state->old_kernel, &updated_kernel_partition));
   }
 
   ASSERT_GE(updated_kernel_partition.size(), arraysize(kNewData));
-  EXPECT_TRUE(std::equal(std::begin(kNewData), std::end(kNewData),
+  EXPECT_TRUE(std::equal(std::begin(kNewData),
+                         std::end(kNewData),
                          updated_kernel_partition.begin()));
 
   const auto& partitions = state->install_plan.partitions;
@@ -887,9 +871,8 @@
   EXPECT_EQ(state->image_size, partitions[0].target_size);
   brillo::Blob expected_new_rootfs_hash;
   EXPECT_EQ(static_cast<off_t>(state->image_size),
-            HashCalculator::RawHashOfFile(state->b_img,
-                                          state->image_size,
-                                          &expected_new_rootfs_hash));
+            HashCalculator::RawHashOfFile(
+                state->b_img, state->image_size, &expected_new_rootfs_hash));
   EXPECT_EQ(expected_new_rootfs_hash, partitions[0].target_hash);
 }
 
@@ -905,20 +888,29 @@
     case kSignatureGeneratedShellBadKey:
       expected_result = ErrorCode::kDownloadPayloadPubKeyVerificationError;
       break;
-    default: break;  // appease gcc
+    default:
+      break;  // appease gcc
   }
 
   VerifyPayloadResult(performer, state, expected_result, minor_version);
 }
 
-void DoSmallImageTest(bool full_kernel, bool full_rootfs, bool noop,
+void DoSmallImageTest(bool full_kernel,
+                      bool full_rootfs,
+                      bool noop,
                       ssize_t chunk_size,
                       SignatureTest signature_test,
-                      bool hash_checks_mandatory, uint32_t minor_version) {
+                      bool hash_checks_mandatory,
+                      uint32_t minor_version) {
   DeltaState state;
-  DeltaPerformer *performer = nullptr;
-  GenerateDeltaFile(full_kernel, full_rootfs, noop, chunk_size,
-                    signature_test, &state, minor_version);
+  DeltaPerformer* performer = nullptr;
+  GenerateDeltaFile(full_kernel,
+                    full_rootfs,
+                    noop,
+                    chunk_size,
+                    signature_test,
+                    &state,
+                    minor_version);
 
   ScopedPathUnlinker a_img_unlinker(state.a_img);
   ScopedPathUnlinker b_img_unlinker(state.b_img);
@@ -927,9 +919,15 @@
   ScopedPathUnlinker old_kernel_unlinker(state.old_kernel);
   ScopedPathUnlinker new_kernel_unlinker(state.new_kernel);
   ScopedPathUnlinker result_kernel_unlinker(state.result_kernel);
-  ApplyDeltaFile(full_kernel, full_rootfs, noop, signature_test,
-                 &state, hash_checks_mandatory, kValidOperationData,
-                 &performer, minor_version);
+  ApplyDeltaFile(full_kernel,
+                 full_rootfs,
+                 noop,
+                 signature_test,
+                 &state,
+                 hash_checks_mandatory,
+                 kValidOperationData,
+                 &performer,
+                 minor_version);
   VerifyPayload(performer, &state, signature_test, minor_version);
   delete performer;
 }
@@ -938,96 +936,170 @@
                                  bool hash_checks_mandatory) {
   DeltaState state;
   uint64_t minor_version = kFullPayloadMinorVersion;
-  GenerateDeltaFile(true, true, false, -1, kSignatureGenerated, &state,
-                    minor_version);
+  GenerateDeltaFile(
+      true, true, false, -1, kSignatureGenerated, &state, minor_version);
   ScopedPathUnlinker a_img_unlinker(state.a_img);
   ScopedPathUnlinker b_img_unlinker(state.b_img);
   ScopedPathUnlinker delta_unlinker(state.delta_path);
   ScopedPathUnlinker old_kernel_unlinker(state.old_kernel);
   ScopedPathUnlinker new_kernel_unlinker(state.new_kernel);
-  DeltaPerformer *performer = nullptr;
-  ApplyDeltaFile(true, true, false, kSignatureGenerated, &state,
-                 hash_checks_mandatory, op_hash_test, &performer,
+  DeltaPerformer* performer = nullptr;
+  ApplyDeltaFile(true,
+                 true,
+                 false,
+                 kSignatureGenerated,
+                 &state,
+                 hash_checks_mandatory,
+                 op_hash_test,
+                 &performer,
                  minor_version);
   delete performer;
 }
 
-
 TEST(DeltaPerformerIntegrationTest, RunAsRootSmallImageTest) {
-  DoSmallImageTest(false, false, false, -1, kSignatureGenerator,
-                   false, kInPlaceMinorPayloadVersion);
+  DoSmallImageTest(false,
+                   false,
+                   false,
+                   -1,
+                   kSignatureGenerator,
+                   false,
+                   kInPlaceMinorPayloadVersion);
 }
 
 TEST(DeltaPerformerIntegrationTest,
      RunAsRootSmallImageSignaturePlaceholderTest) {
-  DoSmallImageTest(false, false, false, -1, kSignatureGeneratedPlaceholder,
-                   false, kInPlaceMinorPayloadVersion);
+  DoSmallImageTest(false,
+                   false,
+                   false,
+                   -1,
+                   kSignatureGeneratedPlaceholder,
+                   false,
+                   kInPlaceMinorPayloadVersion);
 }
 
 TEST(DeltaPerformerIntegrationTest,
      RunAsRootSmallImageSignaturePlaceholderMismatchTest) {
   DeltaState state;
-  GenerateDeltaFile(false, false, false, -1,
-                    kSignatureGeneratedPlaceholderMismatch, &state,
+  GenerateDeltaFile(false,
+                    false,
+                    false,
+                    -1,
+                    kSignatureGeneratedPlaceholderMismatch,
+                    &state,
                     kInPlaceMinorPayloadVersion);
 }
 
 TEST(DeltaPerformerIntegrationTest, RunAsRootSmallImageChunksTest) {
-  DoSmallImageTest(false, false, false, kBlockSize, kSignatureGenerator,
-                   false, kInPlaceMinorPayloadVersion);
+  DoSmallImageTest(false,
+                   false,
+                   false,
+                   kBlockSize,
+                   kSignatureGenerator,
+                   false,
+                   kInPlaceMinorPayloadVersion);
 }
 
 TEST(DeltaPerformerIntegrationTest, RunAsRootFullKernelSmallImageTest) {
-  DoSmallImageTest(true, false, false, -1, kSignatureGenerator,
-                   false, kInPlaceMinorPayloadVersion);
+  DoSmallImageTest(true,
+                   false,
+                   false,
+                   -1,
+                   kSignatureGenerator,
+                   false,
+                   kInPlaceMinorPayloadVersion);
 }
 
 TEST(DeltaPerformerIntegrationTest, RunAsRootFullSmallImageTest) {
-  DoSmallImageTest(true, true, false, -1, kSignatureGenerator,
-                   true, kFullPayloadMinorVersion);
+  DoSmallImageTest(true,
+                   true,
+                   false,
+                   -1,
+                   kSignatureGenerator,
+                   true,
+                   kFullPayloadMinorVersion);
 }
 
 TEST(DeltaPerformerIntegrationTest, RunAsRootNoopSmallImageTest) {
-  DoSmallImageTest(false, false, true, -1, kSignatureGenerator,
-                   false, kInPlaceMinorPayloadVersion);
+  DoSmallImageTest(false,
+                   false,
+                   true,
+                   -1,
+                   kSignatureGenerator,
+                   false,
+                   kInPlaceMinorPayloadVersion);
 }
 
 TEST(DeltaPerformerIntegrationTest, RunAsRootSmallImageSignNoneTest) {
-  DoSmallImageTest(false, false, false, -1, kSignatureNone,
-                   false, kInPlaceMinorPayloadVersion);
+  DoSmallImageTest(false,
+                   false,
+                   false,
+                   -1,
+                   kSignatureNone,
+                   false,
+                   kInPlaceMinorPayloadVersion);
 }
 
 TEST(DeltaPerformerIntegrationTest, RunAsRootSmallImageSignGeneratedTest) {
-  DoSmallImageTest(false, false, false, -1, kSignatureGenerated,
-                   true, kInPlaceMinorPayloadVersion);
+  DoSmallImageTest(false,
+                   false,
+                   false,
+                   -1,
+                   kSignatureGenerated,
+                   true,
+                   kInPlaceMinorPayloadVersion);
 }
 
 TEST(DeltaPerformerIntegrationTest, RunAsRootSmallImageSignGeneratedShellTest) {
-  DoSmallImageTest(false, false, false, -1, kSignatureGeneratedShell,
-                   false, kInPlaceMinorPayloadVersion);
+  DoSmallImageTest(false,
+                   false,
+                   false,
+                   -1,
+                   kSignatureGeneratedShell,
+                   false,
+                   kInPlaceMinorPayloadVersion);
 }
 
 TEST(DeltaPerformerIntegrationTest,
      RunAsRootSmallImageSignGeneratedShellBadKeyTest) {
-  DoSmallImageTest(false, false, false, -1, kSignatureGeneratedShellBadKey,
-                   false, kInPlaceMinorPayloadVersion);
+  DoSmallImageTest(false,
+                   false,
+                   false,
+                   -1,
+                   kSignatureGeneratedShellBadKey,
+                   false,
+                   kInPlaceMinorPayloadVersion);
 }
 
 TEST(DeltaPerformerIntegrationTest,
      RunAsRootSmallImageSignGeneratedShellRotateCl1Test) {
-  DoSmallImageTest(false, false, false, -1, kSignatureGeneratedShellRotateCl1,
-                   false, kInPlaceMinorPayloadVersion);
+  DoSmallImageTest(false,
+                   false,
+                   false,
+                   -1,
+                   kSignatureGeneratedShellRotateCl1,
+                   false,
+                   kInPlaceMinorPayloadVersion);
 }
 
 TEST(DeltaPerformerIntegrationTest,
      RunAsRootSmallImageSignGeneratedShellRotateCl2Test) {
-  DoSmallImageTest(false, false, false, -1, kSignatureGeneratedShellRotateCl2,
-                   false, kInPlaceMinorPayloadVersion);
+  DoSmallImageTest(false,
+                   false,
+                   false,
+                   -1,
+                   kSignatureGeneratedShellRotateCl2,
+                   false,
+                   kInPlaceMinorPayloadVersion);
 }
 
 TEST(DeltaPerformerIntegrationTest, RunAsRootSmallImageSourceOpsTest) {
-  DoSmallImageTest(false, false, false, -1, kSignatureGenerator,
-                   false, kSourceMinorPayloadVersion);
+  DoSmallImageTest(false,
+                   false,
+                   false,
+                   -1,
+                   kSignatureGenerator,
+                   false,
+                   kSourceMinorPayloadVersion);
 }
 
 TEST(DeltaPerformerIntegrationTest,
diff --git a/payload_consumer/delta_performer_unittest.cc b/payload_consumer/delta_performer_unittest.cc
index 4cf9756..61b58ed 100644
--- a/payload_consumer/delta_performer_unittest.cc
+++ b/payload_consumer/delta_performer_unittest.cc
@@ -54,8 +54,8 @@
 using std::string;
 using std::vector;
 using test_utils::GetBuildArtifactsPath;
-using test_utils::System;
 using test_utils::kRandomString;
+using test_utils::System;
 using testing::_;
 
 extern const char* kUnittestPrivateKeyPath;
@@ -93,6 +93,7 @@
     0xa8, 0x00, 0x0a, 0xfc, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x59, 0x5a,
 };
 
+// clang-format off
 const uint8_t src_deflates[] = {
   /* raw      0  */ 0x11, 0x22,
   /* deflate  2  */ 0x63, 0x64, 0x62, 0x66, 0x61, 0x05, 0x00,
@@ -109,6 +110,7 @@
   /* deflate  9  */ 0x01, 0x05, 0x00, 0xFA, 0xFF, 0x01, 0x02, 0x03, 0x04, 0x05,
   /* deflate  19 */ 0x63, 0x04, 0x00
 };
+// clang-format on
 
 // To generate this patch either:
 // - Use puffin/src/patching_unittest.cc:TestPatching
@@ -124,29 +126,29 @@
 //   --patch_file=patch.bin
 // * hexdump -ve '"  " 12/1 "0x%02x, " "\n"' patch.bin
 const uint8_t puffdiff_patch[] = {
-  0x50, 0x55, 0x46, 0x31, 0x00, 0x00, 0x00, 0x51, 0x08, 0x01, 0x12, 0x27,
-  0x0A, 0x04, 0x08, 0x10, 0x10, 0x32, 0x0A, 0x04, 0x08, 0x50, 0x10, 0x0A,
-  0x0A, 0x04, 0x08, 0x60, 0x10, 0x12, 0x12, 0x04, 0x08, 0x10, 0x10, 0x58,
-  0x12, 0x04, 0x08, 0x78, 0x10, 0x28, 0x12, 0x05, 0x08, 0xA8, 0x01, 0x10,
-  0x38, 0x18, 0x1F, 0x1A, 0x24, 0x0A, 0x02, 0x10, 0x32, 0x0A, 0x04, 0x08,
-  0x48, 0x10, 0x50, 0x0A, 0x05, 0x08, 0x98, 0x01, 0x10, 0x12, 0x12, 0x02,
-  0x10, 0x58, 0x12, 0x04, 0x08, 0x70, 0x10, 0x58, 0x12, 0x05, 0x08, 0xC8,
-  0x01, 0x10, 0x38, 0x18, 0x21, 0x42, 0x53, 0x44, 0x49, 0x46, 0x46, 0x34,
-  0x30, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x42, 0x5A, 0x68, 0x39, 0x31, 0x41, 0x59, 0x26, 0x53, 0x59, 0x65,
-  0x29, 0x8C, 0x9B, 0x00, 0x00, 0x03, 0x60, 0x40, 0x7A, 0x0E, 0x08, 0x00,
-  0x40, 0x00, 0x20, 0x00, 0x21, 0x22, 0x9A, 0x3D, 0x4F, 0x50, 0x40, 0x0C,
-  0x3B, 0xC7, 0x9B, 0xB2, 0x21, 0x0E, 0xE9, 0x15, 0x98, 0x7A, 0x7C, 0x5D,
-  0xC9, 0x14, 0xE1, 0x42, 0x41, 0x94, 0xA6, 0x32, 0x6C, 0x42, 0x5A, 0x68,
-  0x39, 0x31, 0x41, 0x59, 0x26, 0x53, 0x59, 0xF1, 0x20, 0x5F, 0x0D, 0x00,
-  0x00, 0x02, 0x41, 0x15, 0x42, 0x08, 0x20, 0x00, 0x40, 0x00, 0x00, 0x02,
-  0x40, 0x00, 0x20, 0x00, 0x22, 0x3D, 0x23, 0x10, 0x86, 0x03, 0x96, 0x54,
-  0x11, 0x16, 0x5F, 0x17, 0x72, 0x45, 0x38, 0x50, 0x90, 0xF1, 0x20, 0x5F,
-  0x0D, 0x42, 0x5A, 0x68, 0x39, 0x31, 0x41, 0x59, 0x26, 0x53, 0x59, 0x07,
-  0xD4, 0xCB, 0x6E, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x20, 0x00,
-  0x21, 0x18, 0x46, 0x82, 0xEE, 0x48, 0xA7, 0x0A, 0x12, 0x00, 0xFA, 0x99,
-  0x6D, 0xC0};
+    0x50, 0x55, 0x46, 0x31, 0x00, 0x00, 0x00, 0x51, 0x08, 0x01, 0x12, 0x27,
+    0x0A, 0x04, 0x08, 0x10, 0x10, 0x32, 0x0A, 0x04, 0x08, 0x50, 0x10, 0x0A,
+    0x0A, 0x04, 0x08, 0x60, 0x10, 0x12, 0x12, 0x04, 0x08, 0x10, 0x10, 0x58,
+    0x12, 0x04, 0x08, 0x78, 0x10, 0x28, 0x12, 0x05, 0x08, 0xA8, 0x01, 0x10,
+    0x38, 0x18, 0x1F, 0x1A, 0x24, 0x0A, 0x02, 0x10, 0x32, 0x0A, 0x04, 0x08,
+    0x48, 0x10, 0x50, 0x0A, 0x05, 0x08, 0x98, 0x01, 0x10, 0x12, 0x12, 0x02,
+    0x10, 0x58, 0x12, 0x04, 0x08, 0x70, 0x10, 0x58, 0x12, 0x05, 0x08, 0xC8,
+    0x01, 0x10, 0x38, 0x18, 0x21, 0x42, 0x53, 0x44, 0x49, 0x46, 0x46, 0x34,
+    0x30, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x42, 0x5A, 0x68, 0x39, 0x31, 0x41, 0x59, 0x26, 0x53, 0x59, 0x65,
+    0x29, 0x8C, 0x9B, 0x00, 0x00, 0x03, 0x60, 0x40, 0x7A, 0x0E, 0x08, 0x00,
+    0x40, 0x00, 0x20, 0x00, 0x21, 0x22, 0x9A, 0x3D, 0x4F, 0x50, 0x40, 0x0C,
+    0x3B, 0xC7, 0x9B, 0xB2, 0x21, 0x0E, 0xE9, 0x15, 0x98, 0x7A, 0x7C, 0x5D,
+    0xC9, 0x14, 0xE1, 0x42, 0x41, 0x94, 0xA6, 0x32, 0x6C, 0x42, 0x5A, 0x68,
+    0x39, 0x31, 0x41, 0x59, 0x26, 0x53, 0x59, 0xF1, 0x20, 0x5F, 0x0D, 0x00,
+    0x00, 0x02, 0x41, 0x15, 0x42, 0x08, 0x20, 0x00, 0x40, 0x00, 0x00, 0x02,
+    0x40, 0x00, 0x20, 0x00, 0x22, 0x3D, 0x23, 0x10, 0x86, 0x03, 0x96, 0x54,
+    0x11, 0x16, 0x5F, 0x17, 0x72, 0x45, 0x38, 0x50, 0x90, 0xF1, 0x20, 0x5F,
+    0x0D, 0x42, 0x5A, 0x68, 0x39, 0x31, 0x41, 0x59, 0x26, 0x53, 0x59, 0x07,
+    0xD4, 0xCB, 0x6E, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x20, 0x00,
+    0x21, 0x18, 0x46, 0x82, 0xEE, 0x48, 0xA7, 0x0A, 0x12, 0x00, 0xFA, 0x99,
+    0x6D, 0xC0};
 
 }  // namespace
 
@@ -254,8 +256,8 @@
   brillo::Blob ApplyPayload(const brillo::Blob& payload_data,
                             const string& source_path,
                             bool expect_success) {
-    return ApplyPayloadToData(payload_data, source_path, brillo::Blob(),
-                              expect_success);
+    return ApplyPayloadToData(
+        payload_data, source_path, brillo::Blob(), expect_success);
   }
 
   // Apply the payload provided in |payload_data| reading from the |source_path|
@@ -329,8 +331,10 @@
                                bool hash_checks_mandatory) {
     // Loads the payload and parses the manifest.
     brillo::Blob payload = GeneratePayload(brillo::Blob(),
-        vector<AnnotatedOperation>(), sign_payload,
-        kChromeOSMajorPayloadVersion, kFullPayloadMinorVersion);
+                                           vector<AnnotatedOperation>(),
+                                           sign_payload,
+                                           kChromeOSMajorPayloadVersion,
+                                           kFullPayloadMinorVersion);
 
     LOG(INFO) << "Payload size: " << payload.size();
 
@@ -429,8 +433,8 @@
 
 TEST_F(DeltaPerformerTest, FullPayloadWriteTest) {
   payload_.type = InstallPayloadType::kFull;
-  brillo::Blob expected_data = brillo::Blob(std::begin(kRandomString),
-                                            std::end(kRandomString));
+  brillo::Blob expected_data =
+      brillo::Blob(std::begin(kRandomString), std::end(kRandomString));
   expected_data.resize(4096);  // block size
   vector<AnnotatedOperation> aops;
   AnnotatedOperation aop;
@@ -440,16 +444,19 @@
   aop.op.set_type(InstallOperation::REPLACE);
   aops.push_back(aop);
 
-  brillo::Blob payload_data = GeneratePayload(expected_data, aops, false,
-      kChromeOSMajorPayloadVersion, kFullPayloadMinorVersion);
+  brillo::Blob payload_data = GeneratePayload(expected_data,
+                                              aops,
+                                              false,
+                                              kChromeOSMajorPayloadVersion,
+                                              kFullPayloadMinorVersion);
 
   EXPECT_EQ(expected_data, ApplyPayload(payload_data, "/dev/null", true));
 }
 
 TEST_F(DeltaPerformerTest, ShouldCancelTest) {
   payload_.type = InstallPayloadType::kFull;
-  brillo::Blob expected_data = brillo::Blob(std::begin(kRandomString),
-                                            std::end(kRandomString));
+  brillo::Blob expected_data =
+      brillo::Blob(std::begin(kRandomString), std::end(kRandomString));
   expected_data.resize(4096);  // block size
   vector<AnnotatedOperation> aops;
   AnnotatedOperation aop;
@@ -459,21 +466,23 @@
   aop.op.set_type(InstallOperation::REPLACE);
   aops.push_back(aop);
 
-  brillo::Blob payload_data = GeneratePayload(expected_data, aops, false,
-      kChromeOSMajorPayloadVersion, kFullPayloadMinorVersion);
+  brillo::Blob payload_data = GeneratePayload(expected_data,
+                                              aops,
+                                              false,
+                                              kChromeOSMajorPayloadVersion,
+                                              kFullPayloadMinorVersion);
 
   testing::Mock::VerifyAndClearExpectations(&mock_delegate_);
   EXPECT_CALL(mock_delegate_, ShouldCancel(_))
-      .WillOnce(
-          testing::DoAll(testing::SetArgPointee<0>(ErrorCode::kError),
-                         testing::Return(true)));
+      .WillOnce(testing::DoAll(testing::SetArgPointee<0>(ErrorCode::kError),
+                               testing::Return(true)));
 
   ApplyPayload(payload_data, "/dev/null", false);
 }
 
 TEST_F(DeltaPerformerTest, ReplaceOperationTest) {
-  brillo::Blob expected_data = brillo::Blob(std::begin(kRandomString),
-                                            std::end(kRandomString));
+  brillo::Blob expected_data =
+      brillo::Blob(std::begin(kRandomString), std::end(kRandomString));
   expected_data.resize(4096);  // block size
   vector<AnnotatedOperation> aops;
   AnnotatedOperation aop;
@@ -489,8 +498,8 @@
 }
 
 TEST_F(DeltaPerformerTest, ReplaceBzOperationTest) {
-  brillo::Blob expected_data = brillo::Blob(std::begin(kRandomString),
-                                            std::end(kRandomString));
+  brillo::Blob expected_data =
+      brillo::Blob(std::begin(kRandomString), std::end(kRandomString));
   expected_data.resize(4096);  // block size
   brillo::Blob bz_data;
   EXPECT_TRUE(BzipCompress(expected_data, &bz_data));
@@ -510,7 +519,7 @@
 
 TEST_F(DeltaPerformerTest, ReplaceXzOperationTest) {
   brillo::Blob xz_data(std::begin(kXzCompressedData),
-                         std::end(kXzCompressedData));
+                       std::end(kXzCompressedData));
   // The compressed xz data contains a single "a" and padded with zero for the
   // rest of the block.
   brillo::Blob expected_data = brillo::Blob(4096, 0);
@@ -533,10 +542,10 @@
   brillo::Blob expected_data = existing_data;
   // Blocks 4, 5 and 7 should have zeros instead of 'a' after the operation is
   // applied.
-  std::fill(expected_data.data() + 4096 * 4, expected_data.data() + 4096 * 6,
-            0);
-  std::fill(expected_data.data() + 4096 * 7, expected_data.data() + 4096 * 8,
-            0);
+  std::fill(
+      expected_data.data() + 4096 * 4, expected_data.data() + 4096 * 6, 0);
+  std::fill(
+      expected_data.data() + 4096 * 7, expected_data.data() + 4096 * 8, 0);
 
   AnnotatedOperation aop;
   *(aop.op.add_dst_extents()) = ExtentForRange(4, 2);
@@ -708,10 +717,8 @@
 
   string expected_output = "4096:4096,16384:8192,0:4083";
   string actual_output;
-  EXPECT_TRUE(DeltaPerformer::ExtentsToBsdiffPositionsString(extents,
-                                                             block_size,
-                                                             file_length,
-                                                             &actual_output));
+  EXPECT_TRUE(DeltaPerformer::ExtentsToBsdiffPositionsString(
+      extents, block_size, file_length, &actual_output));
   EXPECT_EQ(expected_output, actual_output);
 }
 
@@ -876,9 +883,8 @@
 }
 
 TEST_F(DeltaPerformerTest, BrilloParsePayloadMetadataTest) {
-  brillo::Blob payload_data = GeneratePayload({}, {}, true,
-                                              kBrilloMajorPayloadVersion,
-                                              kSourceMinorPayloadVersion);
+  brillo::Blob payload_data = GeneratePayload(
+      {}, {}, true, kBrilloMajorPayloadVersion, kSourceMinorPayloadVersion);
   install_plan_.hash_checks_mandatory = true;
   performer_.set_public_key_path(GetBuildArtifactsPath(kUnittestPublicKeyPath));
   ErrorCode error;
diff --git a/payload_consumer/download_action.cc b/payload_consumer/download_action.cc
index 516a456..09afc42 100644
--- a/payload_consumer/download_action.cc
+++ b/payload_consumer/download_action.cc
@@ -72,8 +72,7 @@
   }
 
   if (delete_p2p_file) {
-    FilePath path =
-      system_state_->p2p_manager()->FileGetPath(p2p_file_id_);
+    FilePath path = system_state_->p2p_manager()->FileGetPath(p2p_file_id_);
     if (unlink(path.value().c_str()) != 0) {
       PLOG(ERROR) << "Error deleting p2p file " << path.value();
     } else {
@@ -86,7 +85,7 @@
 }
 
 bool DownloadAction::SetupP2PSharingFd() {
-  P2PManager *p2p_manager = system_state_->p2p_manager();
+  P2PManager* p2p_manager = system_state_->p2p_manager();
 
   if (!p2p_manager->FileShare(p2p_file_id_, payload_->size)) {
     LOG(ERROR) << "Unable to share file via p2p";
@@ -147,23 +146,21 @@
   }
   if (p2p_size < file_offset) {
     LOG(ERROR) << "Wanting to write to file offset " << file_offset
-               << " but existing p2p file is only " << p2p_size
-               << " bytes.";
+               << " but existing p2p file is only " << p2p_size << " bytes.";
     CloseP2PSharingFd(true);  // Delete p2p file.
     return;
   }
 
   off_t cur_file_offset = lseek(p2p_sharing_fd_, file_offset, SEEK_SET);
   if (cur_file_offset != static_cast<off_t>(file_offset)) {
-    PLOG(ERROR) << "Error seeking to position "
-                << file_offset << " in p2p file";
+    PLOG(ERROR) << "Error seeking to position " << file_offset
+                << " in p2p file";
     CloseP2PSharingFd(true);  // Delete p2p file.
   } else {
     // OK, seeking worked, now write the data
     ssize_t bytes_written = write(p2p_sharing_fd_, data, length);
     if (bytes_written != static_cast<ssize_t>(length)) {
-      PLOG(ERROR) << "Error writing "
-                  << length << " bytes at file offset "
+      PLOG(ERROR) << "Error writing " << length << " bytes at file offset "
                   << file_offset << " in p2p file";
       CloseP2PSharingFd(true);  // Delete p2p file.
     }
@@ -377,7 +374,7 @@
       code = delta_performer_->VerifyPayload(payload_->hash, payload_->size);
     if (code == ErrorCode::kSuccess) {
       if (payload_ < &install_plan_.payloads.back() &&
-                 system_state_->payload_state()->NextPayload()) {
+          system_state_->payload_state()->NextPayload()) {
         LOG(INFO) << "Incrementing to next payload";
         // No need to reset if this payload was already applied.
         if (delta_performer_ && !payload_->already_applied)
@@ -398,8 +395,8 @@
       // Log UpdateEngine.DownloadAction.* histograms to help diagnose
       // long-blocking operations.
       std::string histogram_output;
-      base::StatisticsRecorder::WriteGraph(
-          "UpdateEngine.DownloadAction.", &histogram_output);
+      base::StatisticsRecorder::WriteGraph("UpdateEngine.DownloadAction.",
+                                           &histogram_output);
       LOG(INFO) << histogram_output;
     } else {
       LOG(ERROR) << "Download of " << install_plan_.download_url
diff --git a/payload_consumer/download_action.h b/payload_consumer/download_action.h
index 028a99a..1777e22 100644
--- a/payload_consumer/download_action.h
+++ b/payload_consumer/download_action.h
@@ -64,8 +64,7 @@
 
 class PrefsInterface;
 
-class DownloadAction : public InstallPlanAction,
-                       public HttpFetcherDelegate {
+class DownloadAction : public InstallPlanAction, public HttpFetcherDelegate {
  public:
   // Debugging/logging
   static std::string StaticType() { return "DownloadAction"; }
@@ -90,9 +89,7 @@
   std::string Type() const override { return StaticType(); }
 
   // Testing
-  void SetTestFileWriter(FileWriter* writer) {
-    writer_ = writer;
-  }
+  void SetTestFileWriter(FileWriter* writer) { writer_ = writer; }
 
   int GetHTTPResponseCode() { return http_fetcher_->http_response_code(); }
 
@@ -105,9 +102,7 @@
   void TransferTerminated(HttpFetcher* fetcher) override;
 
   DownloadActionDelegate* delegate() const { return delegate_; }
-  void set_delegate(DownloadActionDelegate* delegate) {
-    delegate_ = delegate;
-  }
+  void set_delegate(DownloadActionDelegate* delegate) { delegate_ = delegate; }
 
   void set_base_offset(int64_t base_offset) { base_offset_ = base_offset; }
 
diff --git a/payload_consumer/download_action_unittest.cc b/payload_consumer/download_action_unittest.cc
index 84673c8..e6ca219 100644
--- a/payload_consumer/download_action_unittest.cc
+++ b/payload_consumer/download_action_unittest.cc
@@ -52,13 +52,13 @@
 using std::string;
 using std::unique_ptr;
 using test_utils::ScopedTempFile;
+using testing::_;
 using testing::AtLeast;
 using testing::InSequence;
 using testing::Return;
 using testing::SetArgPointee;
-using testing::_;
 
-class DownloadActionTest : public ::testing::Test { };
+class DownloadActionTest : public ::testing::Test {};
 
 namespace {
 
@@ -158,9 +158,8 @@
   auto feeder_action = std::make_unique<ObjectFeederAction<InstallPlan>>();
   feeder_action->set_obj(install_plan);
   MockPrefs prefs;
-  MockHttpFetcher* http_fetcher = new MockHttpFetcher(data.data(),
-                                                      data.size(),
-                                                      nullptr);
+  MockHttpFetcher* http_fetcher =
+      new MockHttpFetcher(data.data(), data.size(), nullptr);
   // takes ownership of passed in HttpFetcher
   auto download_action =
       std::make_unique<DownloadAction>(&prefs,
@@ -209,7 +208,7 @@
   const char* foo = "foo";
   small.insert(small.end(), foo, foo + strlen(foo));
   TestWithData(small,
-               0,  // fail_write
+               0,      // fail_write
                true);  // use_download_delegate
 }
 
@@ -221,7 +220,7 @@
     c = ('9' == c) ? '0' : c + 1;
   }
   TestWithData(big,
-               0,  // fail_write
+               0,      // fail_write
                true);  // use_download_delegate
 }
 
@@ -233,7 +232,7 @@
     c = ('9' == c) ? '0' : c + 1;
   }
   TestWithData(big,
-               2,  // fail_write
+               2,      // fail_write
                true);  // use_download_delegate
 }
 
@@ -242,7 +241,7 @@
   const char* foo = "foofoo";
   small.insert(small.end(), foo, foo + strlen(foo));
   TestWithData(small,
-               0,  // fail_write
+               0,       // fail_write
                false);  // use_download_delegate
 }
 
@@ -352,8 +351,7 @@
   brillo::FakeMessageLoop loop(nullptr);
   loop.SetAsCurrent();
 
-  brillo::Blob data(kMockHttpFetcherChunkSize +
-                      kMockHttpFetcherChunkSize / 2);
+  brillo::Blob data(kMockHttpFetcherChunkSize + kMockHttpFetcherChunkSize / 2);
   memset(data.data(), 0, data.size());
 
   ScopedTempFile temp_file;
@@ -414,7 +412,7 @@
 
 class DownloadActionTestAction;
 
-template<>
+template <>
 class ActionTraits<DownloadActionTestAction> {
  public:
   typedef InstallPlan OutputObjectType;
@@ -516,20 +514,15 @@
 class P2PDownloadActionTest : public testing::Test {
  protected:
   P2PDownloadActionTest()
-    : start_at_offset_(0),
-      fake_um_(fake_system_state_.fake_clock()) {}
+      : start_at_offset_(0), fake_um_(fake_system_state_.fake_clock()) {}
 
   ~P2PDownloadActionTest() override {}
 
   // Derived from testing::Test.
-  void SetUp() override {
-    loop_.SetAsCurrent();
-  }
+  void SetUp() override { loop_.SetAsCurrent(); }
 
   // Derived from testing::Test.
-  void TearDown() override {
-    EXPECT_FALSE(loop_.PendingTasks());
-  }
+  void TearDown() override { EXPECT_FALSE(loop_.PendingTasks()); }
 
   // To be called by tests to setup the download. The
   // |starting_offset| parameter is for where to resume.
@@ -541,10 +534,13 @@
       data_ += 'a' + (i % 25);
 
     // Setup p2p.
-    FakeP2PManagerConfiguration *test_conf = new FakeP2PManagerConfiguration();
-    p2p_manager_.reset(P2PManager::Construct(
-        test_conf, nullptr, &fake_um_, "cros_au", 3,
-        base::TimeDelta::FromDays(5)));
+    FakeP2PManagerConfiguration* test_conf = new FakeP2PManagerConfiguration();
+    p2p_manager_.reset(P2PManager::Construct(test_conf,
+                                             nullptr,
+                                             &fake_um_,
+                                             "cros_au",
+                                             3,
+                                             base::TimeDelta::FromDays(5)));
     fake_system_state_.set_p2p_manager(p2p_manager_.get());
   }
 
@@ -634,8 +630,8 @@
   EXPECT_EQ(static_cast<int>(data_.length()),
             p2p_manager_->FileGetExpectedSize(file_id));
   string p2p_file_contents;
-  EXPECT_TRUE(ReadFileToString(p2p_manager_->FileGetPath(file_id),
-                               &p2p_file_contents));
+  EXPECT_TRUE(
+      ReadFileToString(p2p_manager_->FileGetPath(file_id), &p2p_file_contents));
   EXPECT_EQ(data_, p2p_file_contents);
 }
 
@@ -660,8 +656,10 @@
   string existing_data;
   for (unsigned int i = 0; i < 1000; i++)
     existing_data += '0' + (i % 10);
-  ASSERT_EQ(WriteFile(p2p_manager_->FileGetPath(file_id), existing_data.c_str(),
-                      1000), 1000);
+  ASSERT_EQ(
+      WriteFile(
+          p2p_manager_->FileGetPath(file_id), existing_data.c_str(), 1000),
+      1000);
 
   StartDownload(true);  // use_p2p_to_share
 
@@ -675,8 +673,8 @@
   string p2p_file_contents;
   // Check that the first 1000 bytes wasn't touched and that we
   // appended the remaining as appropriate.
-  EXPECT_TRUE(ReadFileToString(p2p_manager_->FileGetPath(file_id),
-                               &p2p_file_contents));
+  EXPECT_TRUE(
+      ReadFileToString(p2p_manager_->FileGetPath(file_id), &p2p_file_contents));
   EXPECT_EQ(existing_data, p2p_file_contents.substr(0, 1000));
   EXPECT_EQ(data_.substr(1000), p2p_file_contents.substr(1000));
 }
@@ -692,8 +690,10 @@
   string existing_data;
   for (unsigned int i = 0; i < 1000; i++)
     existing_data += '0' + (i % 10);
-  ASSERT_EQ(WriteFile(p2p_manager_->FileGetPath(file_id), existing_data.c_str(),
-                      1000), 1000);
+  ASSERT_EQ(
+      WriteFile(
+          p2p_manager_->FileGetPath(file_id), existing_data.c_str(), 1000),
+      1000);
 
   // Check that the file is there.
   EXPECT_EQ(1000, p2p_manager_->FileGetSize(file_id));
diff --git a/payload_consumer/extent_reader.cc b/payload_consumer/extent_reader.cc
index 96ea918..ad983ae 100644
--- a/payload_consumer/extent_reader.cc
+++ b/payload_consumer/extent_reader.cc
@@ -16,6 +16,8 @@
 
 #include "update_engine/payload_consumer/extent_reader.h"
 
+#include <algorithm>
+
 #include <sys/types.h>
 #include <unistd.h>
 
@@ -52,8 +54,9 @@
   }
   // The first item is zero and upper_bound never returns it because it always
   // return the item which is greater than the given value.
-  auto extent_idx = std::upper_bound(
-      extents_upper_bounds_.begin(), extents_upper_bounds_.end(), offset) -
+  auto extent_idx =
+      std::upper_bound(
+          extents_upper_bounds_.begin(), extents_upper_bounds_.end(), offset) -
       extents_upper_bounds_.begin() - 1;
   cur_extent_ = std::next(extents_.begin(), extent_idx);
   offset_ = offset;
diff --git a/payload_consumer/extent_writer_unittest.cc b/payload_consumer/extent_writer_unittest.cc
index 580c4a6..aef856b 100644
--- a/payload_consumer/extent_writer_unittest.cc
+++ b/payload_consumer/extent_writer_unittest.cc
@@ -50,9 +50,7 @@
     fd_.reset(new EintrSafeFileDescriptor);
     ASSERT_TRUE(fd_->Open(temp_file_.path().c_str(), O_RDWR, 0600));
   }
-  void TearDown() override {
-    fd_->Close();
-  }
+  void TearDown() override { fd_->Close(); }
 
   // Writes data to an extent writer in 'chunk_size' chunks with
   // the first chunk of size first_chunk_size. It calculates what the
@@ -79,8 +77,8 @@
   EXPECT_TRUE(utils::ReadFile(temp_file_.path(), &result_file));
 
   brillo::Blob expected_file(kBlockSize);
-  expected_file.insert(expected_file.end(),
-                       bytes.data(), bytes.data() + bytes.size());
+  expected_file.insert(
+      expected_file.end(), bytes.data(), bytes.data() + bytes.size());
   ExpectVectorsEq(expected_file, result_file);
 }
 
@@ -135,10 +133,10 @@
   expected_file.insert(expected_file.end(),
                        data.begin() + kBlockSize,
                        data.begin() + kBlockSize * 2);
-  expected_file.insert(expected_file.end(),
-                       data.begin(), data.begin() + kBlockSize);
-  expected_file.insert(expected_file.end(),
-                       data.begin() + kBlockSize * 2, data.end());
+  expected_file.insert(
+      expected_file.end(), data.begin(), data.begin() + kBlockSize);
+  expected_file.insert(
+      expected_file.end(), data.begin() + kBlockSize * 2, data.end());
   ExpectVectorsEq(expected_file, result_file);
 }
 
@@ -158,8 +156,8 @@
 
   size_t bytes_written = 0;
   while (bytes_written < (block_count * kBlockSize)) {
-    size_t bytes_to_write = min(block_count * kBlockSize - bytes_written,
-                                data.size());
+    size_t bytes_to_write =
+        min(block_count * kBlockSize - bytes_written, data.size());
     EXPECT_TRUE(direct_writer.Write(data.data(), bytes_to_write));
     bytes_written += bytes_to_write;
   }
diff --git a/payload_consumer/fake_file_descriptor.h b/payload_consumer/fake_file_descriptor.h
index c9fea7d..8dbd10b 100644
--- a/payload_consumer/fake_file_descriptor.h
+++ b/payload_consumer/fake_file_descriptor.h
@@ -69,9 +69,7 @@
     return false;
   }
 
-  bool Flush() override {
-    return open_;
-  }
+  bool Flush() override { return open_; }
 
   bool Close() override {
     if (!open_)
diff --git a/payload_consumer/file_descriptor.cc b/payload_consumer/file_descriptor.cc
index 4eabb8f..1de615c 100644
--- a/payload_consumer/file_descriptor.cc
+++ b/payload_consumer/file_descriptor.cc
@@ -89,7 +89,7 @@
   // operations.
 #ifndef BLKZEROOUT
   return false;
-#else  // defined(BLKZEROOUT)
+#else   // defined(BLKZEROOUT)
   DCHECK(request == BLKDISCARD || request == BLKZEROOUT ||
          request == BLKSECDISCARD);
   // On some devices, the BLKDISCARD will actually read back as zeros, instead
diff --git a/payload_consumer/file_descriptor.h b/payload_consumer/file_descriptor.h
index 5e524d9..55f76c6 100644
--- a/payload_consumer/file_descriptor.h
+++ b/payload_consumer/file_descriptor.h
@@ -18,8 +18,8 @@
 #define UPDATE_ENGINE_PAYLOAD_CONSUMER_FILE_DESCRIPTOR_H_
 
 #include <errno.h>
-#include <memory>
 #include <sys/types.h>
+#include <memory>
 
 #include <base/logging.h>
 
@@ -125,12 +125,8 @@
                 int* result) override;
   bool Flush() override;
   bool Close() override;
-  bool IsSettingErrno() override {
-    return true;
-  }
-  bool IsOpen() override {
-    return (fd_ >= 0);
-  }
+  bool IsSettingErrno() override { return true; }
+  bool IsOpen() override { return (fd_ >= 0); }
 
  protected:
   int fd_;
diff --git a/payload_consumer/file_writer.cc b/payload_consumer/file_writer.cc
index d280ddb..84b19ed 100644
--- a/payload_consumer/file_writer.cc
+++ b/payload_consumer/file_writer.cc
@@ -34,8 +34,7 @@
 
   size_t bytes_written = 0;
   while (bytes_written < count) {
-    ssize_t rc = write(fd_, char_bytes + bytes_written,
-                       count - bytes_written);
+    ssize_t rc = write(fd_, char_bytes + bytes_written, count - bytes_written);
     if (rc < 0)
       return false;
     bytes_written += rc;
diff --git a/payload_consumer/file_writer.h b/payload_consumer/file_writer.h
index 96ebde6..cdc9fa0 100644
--- a/payload_consumer/file_writer.h
+++ b/payload_consumer/file_writer.h
@@ -47,11 +47,9 @@
   // in addition if the returned value is false. By default this method
   // returns kActionExitDownloadWriteError as the error code, but subclasses
   // can override if they wish to return more specific error codes.
-  virtual bool Write(const void* bytes,
-                     size_t count,
-                     ErrorCode* error) {
-     *error = ErrorCode::kDownloadWriteError;
-     return Write(bytes, count);
+  virtual bool Write(const void* bytes, size_t count, ErrorCode* error) {
+    *error = ErrorCode::kDownloadWriteError;
+    return Write(bytes, count);
   }
 
   // Wrapper around close. Returns 0 on success or -errno on error.
@@ -92,6 +90,7 @@
       LOG(ERROR) << "FileWriter::Close failed: "
                  << utils::ErrnoNumberAsString(-err);
   }
+
  private:
   FileWriter* writer_;
 
diff --git a/payload_consumer/file_writer_unittest.cc b/payload_consumer/file_writer_unittest.cc
index 05df307..59cfe2b 100644
--- a/payload_consumer/file_writer_unittest.cc
+++ b/payload_consumer/file_writer_unittest.cc
@@ -32,7 +32,7 @@
 
 namespace chromeos_update_engine {
 
-class FileWriterTest : public ::testing::Test { };
+class FileWriterTest : public ::testing::Test {};
 
 TEST(FileWriterTest, SimpleTest) {
   // Create a uniquely named file for testing.
@@ -53,8 +53,9 @@
 TEST(FileWriterTest, ErrorTest) {
   DirectFileWriter file_writer;
   const string path("/tmp/ENOENT/FileWriterTest");
-  EXPECT_EQ(-ENOENT, file_writer.Open(path.c_str(),
-                                      O_CREAT | O_LARGEFILE | O_TRUNC, 0644));
+  EXPECT_EQ(
+      -ENOENT,
+      file_writer.Open(path.c_str(), O_CREAT | O_LARGEFILE | O_TRUNC, 0644));
 }
 
 TEST(FileWriterTest, WriteErrorTest) {
@@ -69,5 +70,4 @@
   EXPECT_EQ(0, file_writer.Close());
 }
 
-
 }  // namespace chromeos_update_engine
diff --git a/payload_consumer/filesystem_verifier_action.cc b/payload_consumer/filesystem_verifier_action.cc
index c9cb5af..36e5a35 100644
--- a/payload_consumer/filesystem_verifier_action.cc
+++ b/payload_consumer/filesystem_verifier_action.cc
@@ -118,11 +118,11 @@
             << partition.name << ") on device " << part_path;
 
   brillo::ErrorPtr error;
-  src_stream_ = brillo::FileStream::Open(
-      base::FilePath(part_path),
-      brillo::Stream::AccessMode::READ,
-      brillo::FileStream::Disposition::OPEN_EXISTING,
-      &error);
+  src_stream_ =
+      brillo::FileStream::Open(base::FilePath(part_path),
+                               brillo::Stream::AccessMode::READ,
+                               brillo::FileStream::Disposition::OPEN_EXISTING,
+                               &error);
 
   if (!src_stream_) {
     LOG(ERROR) << "Unable to open " << part_path << " for reading";
@@ -220,8 +220,7 @@
   ScheduleRead();
 }
 
-void FilesystemVerifierAction::OnReadErrorCallback(
-      const brillo::Error* error) {
+void FilesystemVerifierAction::OnReadErrorCallback(const brillo::Error* error) {
   // TODO(deymo): Transform the read-error into an specific ErrorCode.
   LOG(ERROR) << "Asynchronous read failed.";
   Cleanup(ErrorCode::kError);
diff --git a/payload_consumer/filesystem_verifier_action_unittest.cc b/payload_consumer/filesystem_verifier_action_unittest.cc
index f7789f4..cb33404 100644
--- a/payload_consumer/filesystem_verifier_action_unittest.cc
+++ b/payload_consumer/filesystem_verifier_action_unittest.cc
@@ -38,9 +38,7 @@
 
 class FilesystemVerifierActionTest : public ::testing::Test {
  protected:
-  void SetUp() override {
-    loop_.SetAsCurrent();
-  }
+  void SetUp() override { loop_.SetAsCurrent(); }
 
   void TearDown() override {
     EXPECT_EQ(0, brillo::MessageLoopRunMaxIterations(&loop_, 1));
@@ -270,7 +268,8 @@
   ASSERT_EQ(0U, getuid());
   EXPECT_TRUE(DoTest(true, false));
   // TerminateEarlyTest may leak some null callbacks from the Stream class.
-  while (loop_.RunOnce(false)) {}
+  while (loop_.RunOnce(false)) {
+  }
 }
 
 #ifdef __ANDROID__
diff --git a/payload_consumer/install_plan.cc b/payload_consumer/install_plan.cc
index 1fa27ab..f52cd2d 100644
--- a/payload_consumer/install_plan.cc
+++ b/payload_consumer/install_plan.cc
@@ -120,12 +120,9 @@
 
 bool InstallPlan::Partition::operator==(
     const InstallPlan::Partition& that) const {
-  return (name == that.name &&
-          source_path == that.source_path &&
-          source_size == that.source_size &&
-          source_hash == that.source_hash &&
-          target_path == that.target_path &&
-          target_size == that.target_size &&
+  return (name == that.name && source_path == that.source_path &&
+          source_size == that.source_size && source_hash == that.source_hash &&
+          target_path == that.target_path && target_size == that.target_size &&
           target_hash == that.target_hash &&
           run_postinstall == that.run_postinstall &&
           postinstall_path == that.postinstall_path &&
diff --git a/payload_consumer/install_plan.h b/payload_consumer/install_plan.h
index 755d913..ede36b3 100644
--- a/payload_consumer/install_plan.h
+++ b/payload_consumer/install_plan.h
@@ -157,7 +157,7 @@
 
 class InstallPlanAction;
 
-template<>
+template <>
 class ActionTraits<InstallPlanAction> {
  public:
   // Takes the install plan as input
@@ -172,8 +172,8 @@
 class InstallPlanAction : public Action<InstallPlanAction> {
  public:
   InstallPlanAction() {}
-  explicit InstallPlanAction(const InstallPlan& install_plan):
-    install_plan_(install_plan) {}
+  explicit InstallPlanAction(const InstallPlan& install_plan)
+      : install_plan_(install_plan) {}
 
   void PerformAction() override {
     if (HasOutputPipe()) {
diff --git a/payload_consumer/mtd_file_descriptor.cc b/payload_consumer/mtd_file_descriptor.cc
index 5d7758a..5d940cb 100644
--- a/payload_consumer/mtd_file_descriptor.cc
+++ b/payload_consumer/mtd_file_descriptor.cc
@@ -67,9 +67,8 @@
     return ret;
   }
 
-  base::TrimWhitespaceASCII(s_reserved_ebs,
-                            base::TRIM_TRAILING,
-                            &s_reserved_ebs);
+  base::TrimWhitespaceASCII(
+      s_reserved_ebs, base::TRIM_TRAILING, &s_reserved_ebs);
   base::TrimWhitespaceASCII(s_eb_size, base::TRIM_TRAILING, &s_eb_size);
 
   uint64_t reserved_ebs, eb_size;
@@ -142,9 +141,8 @@
 
 ssize_t MtdFileDescriptor::Write(const void* buf, size_t count) {
   CHECK(write_ctx_);
-  ssize_t result = mtd_write_data(write_ctx_.get(),
-                                  static_cast<const char*>(buf),
-                                  count);
+  ssize_t result =
+      mtd_write_data(write_ctx_.get(), static_cast<const char*>(buf), count);
   if (result > 0) {
     nr_written_ += result;
   }
@@ -168,8 +166,8 @@
 bool UbiFileDescriptor::IsUbi(const char* path) {
   base::FilePath device_node(path);
   base::FilePath ubi_name(device_node.BaseName());
-  TEST_AND_RETURN_FALSE(base::StartsWith(ubi_name.MaybeAsASCII(), "ubi",
-                                         base::CompareCase::SENSITIVE));
+  TEST_AND_RETURN_FALSE(base::StartsWith(
+      ubi_name.MaybeAsASCII(), "ubi", base::CompareCase::SENSITIVE));
 
   return static_cast<bool>(GetUbiVolumeInfo(path));
 }
diff --git a/payload_consumer/mtd_file_descriptor.h b/payload_consumer/mtd_file_descriptor.h
index 6c945b2..c0170b7 100644
--- a/payload_consumer/mtd_file_descriptor.h
+++ b/payload_consumer/mtd_file_descriptor.h
@@ -20,6 +20,8 @@
 // This module defines file descriptors that deal with NAND media. We are
 // concerned with raw NAND access (as MTD device), and through UBI layer.
 
+#include <memory>
+
 #include <mtdutils.h>
 
 #include "update_engine/payload_consumer/file_descriptor.h"
@@ -86,10 +88,7 @@
   bool Close() override;
 
  private:
-  enum Mode {
-    kReadOnly,
-    kWriteOnly
-  };
+  enum Mode { kReadOnly, kWriteOnly };
 
   uint64_t usable_eb_blocks_;
   uint64_t eraseblock_size_;
diff --git a/payload_consumer/payload_verifier.cc b/payload_consumer/payload_verifier.cc
index f3d4626..2f7c133 100644
--- a/payload_consumer/payload_verifier.cc
+++ b/payload_consumer/payload_verifier.cc
@@ -50,39 +50,32 @@
 //   }
 //   OCTET STRING(2+32) <actual signature bytes...>
 //  }
+// clang-format off
 const uint8_t kRSA2048SHA256Padding[] = {
-  // PKCS1-v1_5 padding
-  0x00, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-  0xff, 0xff, 0xff, 0xff, 0x00,
-  // ASN.1 header
-  0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
-  0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05,
-  0x00, 0x04, 0x20,
+    // PKCS1-v1_5 padding
+    0x00, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0x00,
+    // ASN.1 header
+    0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03,
+    0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20,
 };
+// clang-format on
 
 }  // namespace
 
@@ -90,9 +83,9 @@
                                       const string& pem_public_key,
                                       const brillo::Blob& hash_data) {
   Signatures signatures;
-  LOG(INFO) << "signature blob size = " <<  signature_blob.size();
-  TEST_AND_RETURN_FALSE(signatures.ParseFromArray(signature_blob.data(),
-                                                  signature_blob.size()));
+  LOG(INFO) << "signature blob size = " << signature_blob.size();
+  TEST_AND_RETURN_FALSE(
+      signatures.ParseFromArray(signature_blob.data(), signature_blob.size()));
 
   if (!signatures.signatures_size()) {
     LOG(ERROR) << "No signatures stored in the blob.";
@@ -148,11 +141,8 @@
 
   // Decrypts the signature.
   brillo::Blob hash_data(keysize);
-  int decrypt_size = RSA_public_decrypt(sig_data.size(),
-                                        sig_data.data(),
-                                        hash_data.data(),
-                                        rsa,
-                                        RSA_NO_PADDING);
+  int decrypt_size = RSA_public_decrypt(
+      sig_data.size(), sig_data.data(), hash_data.data(), rsa, RSA_NO_PADDING);
   RSA_free(rsa);
   TEST_AND_RETURN_FALSE(decrypt_size > 0 &&
                         decrypt_size <= static_cast<int>(hash_data.size()));
diff --git a/payload_consumer/postinstall_runner_action.h b/payload_consumer/postinstall_runner_action.h
index 2e48e11..b9b7069 100644
--- a/payload_consumer/postinstall_runner_action.h
+++ b/payload_consumer/postinstall_runner_action.h
@@ -89,8 +89,7 @@
   void Cleanup();
 
   // Subprocess::Exec callback.
-  void CompletePartitionPostinstall(int return_code,
-                                    const std::string& output);
+  void CompletePartitionPostinstall(int return_code, const std::string& output);
 
   // Complete the Action with the passed |error_code| and mark the new slot as
   // ready. Called when the post-install script was run for all the partitions.
diff --git a/payload_consumer/xz_extent_writer.cc b/payload_consumer/xz_extent_writer.cc
index 835dcf7..a5b939d 100644
--- a/payload_consumer/xz_extent_writer.cc
+++ b/payload_consumer/xz_extent_writer.cc
@@ -32,7 +32,9 @@
 const uint32_t kXzMaxDictSize = 64 * 1024 * 1024;
 
 const char* XzErrorString(enum xz_ret error) {
-  #define __XZ_ERROR_STRING_CASE(code) case code: return #code;
+#define __XZ_ERROR_STRING_CASE(code) \
+  case code:                         \
+    return #code;
   switch (error) {
     __XZ_ERROR_STRING_CASE(XZ_OK)
     __XZ_ERROR_STRING_CASE(XZ_STREAM_END)
@@ -46,7 +48,7 @@
     default:
       return "<unknown xz error>";
   }
-  #undef __XZ_ERROR_STRING_CASE
+#undef __XZ_ERROR_STRING_CASE
 }
 }  // namespace
 
diff --git a/payload_consumer/xz_extent_writer_unittest.cc b/payload_consumer/xz_extent_writer_unittest.cc
index 76a53a4..34980a9 100644
--- a/payload_consumer/xz_extent_writer_unittest.cc
+++ b/payload_consumer/xz_extent_writer_unittest.cc
@@ -99,8 +99,7 @@
   std::unique_ptr<XzExtentWriter> xz_writer_;
 
   const brillo::Blob sample_data_{
-      std::begin(kSampleData),
-      std::begin(kSampleData) + strlen(kSampleData)};
+      std::begin(kSampleData), std::begin(kSampleData) + strlen(kSampleData)};
   FileDescriptorPtr fd_;
 };
 
@@ -111,13 +110,13 @@
 
 TEST_F(XzExtentWriterTest, CompressedSampleData) {
   WriteAll(brillo::Blob(std::begin(kCompressedDataNoCheck),
-                          std::end(kCompressedDataNoCheck)));
+                        std::end(kCompressedDataNoCheck)));
   EXPECT_EQ(sample_data_, fake_extent_writer_->WrittenData());
 }
 
 TEST_F(XzExtentWriterTest, CompressedSampleDataWithCrc) {
   WriteAll(brillo::Blob(std::begin(kCompressedDataCRC32),
-                          std::end(kCompressedDataCRC32)));
+                        std::end(kCompressedDataCRC32)));
   EXPECT_EQ(sample_data_, fake_extent_writer_->WrittenData());
 }
 
@@ -125,7 +124,7 @@
   // Test that even if the output data is bigger than the internal buffer, all
   // the data is written.
   WriteAll(brillo::Blob(std::begin(kCompressed30KiBofA),
-                          std::end(kCompressed30KiBofA)));
+                        std::end(kCompressed30KiBofA)));
   brillo::Blob expected_data(30 * 1024, 'a');
   EXPECT_EQ(expected_data, fake_extent_writer_->WrittenData());
 }
@@ -138,7 +137,7 @@
 
 TEST_F(XzExtentWriterTest, PartialDataIsKept) {
   brillo::Blob compressed(std::begin(kCompressed30KiBofA),
-                            std::end(kCompressed30KiBofA));
+                          std::end(kCompressed30KiBofA));
   EXPECT_TRUE(xz_writer_->Init(fd_, {}, 1024));
   for (uint8_t byte : compressed) {
     EXPECT_TRUE(xz_writer_->Write(&byte, 1));