Initialized unitialized variables.

Test: tested compilation.
Change-Id: Ia5e5c0b9e52244ac49e02be873c65722efb1e733
diff --git a/common/http_fetcher_unittest.cc b/common/http_fetcher_unittest.cc
index c6f6c48..06f3e15 100644
--- a/common/http_fetcher_unittest.cc
+++ b/common/http_fetcher_unittest.cc
@@ -20,11 +20,11 @@
 #include <unistd.h>
 
 #include <algorithm>
+#include <deque>
 #include <memory>
 #include <string>
 #include <utility>
 #include <vector>
-#include <deque>
 
 #include <base/bind.h>
 #include <base/location.h>
@@ -50,8 +50,8 @@
 #endif  // __CHROMEOS__
 #include <brillo/streams/file_stream.h>
 #include <brillo/streams/stream.h>
-#include <gtest/gtest.h>
 #include <gmock/gmock.h>
+#include <gtest/gtest.h>
 
 #include "update_engine/common/fake_hardware.h"
 #include "update_engine/common/file_fetcher.h"
@@ -141,7 +141,7 @@
     vector<char> buf(128);
     string line;
     while (line.find('\n') == string::npos) {
-      size_t read;
+      size_t read{};
       if (!stdout->ReadBlocking(buf.data(), buf.size(), &read, nullptr)) {
         ADD_FAILURE() << "error reading http server stdout";
         return;
@@ -208,25 +208,25 @@
     return res;
   }
 
-    virtual HttpFetcher* NewSmallFetcher() = 0;
+  virtual HttpFetcher* NewSmallFetcher() = 0;
 
-    virtual string BigUrl(in_port_t port) const { return kUnusedUrl; }
-    virtual string SmallUrl(in_port_t port) const { return kUnusedUrl; }
-    virtual string ErrorUrl(in_port_t port) const { return kUnusedUrl; }
+  virtual string BigUrl(in_port_t port) const { return kUnusedUrl; }
+  virtual string SmallUrl(in_port_t port) const { return kUnusedUrl; }
+  virtual string ErrorUrl(in_port_t port) const { return kUnusedUrl; }
 
-    virtual bool IsMock() const = 0;
-    virtual bool IsMulti() const = 0;
-    virtual bool IsHttpSupported() const = 0;
-    virtual bool IsFileFetcher() const = 0;
+  virtual bool IsMock() const = 0;
+  virtual bool IsMulti() const = 0;
+  virtual bool IsHttpSupported() const = 0;
+  virtual bool IsFileFetcher() const = 0;
 
-    virtual void IgnoreServerAborting(HttpServer* server) const {}
+  virtual void IgnoreServerAborting(HttpServer* server) const {}
 
-    virtual HttpServer* CreateServer() = 0;
+  virtual HttpServer* CreateServer() = 0;
 
-    FakeHardware* fake_hardware() { return &fake_hardware_; }
+  FakeHardware* fake_hardware() { return &fake_hardware_; }
 
-   protected:
-    FakeHardware fake_hardware_;
+ protected:
+  FakeHardware fake_hardware_;
 };
 
 class MockHttpFetcherFactory : public AnyHttpFetcherFactory {
@@ -621,7 +621,7 @@
   unique_ptr<HttpServer> server(this->test_.CreateServer());
   ASSERT_TRUE(server->started_);
 
-  MessageLoop::TaskId callback_id;
+  MessageLoop::TaskId callback_id{};
   callback_id = this->loop_.PostDelayedTask(
       FROM_HERE,
       base::Bind(&UnpausingTimeoutCallback, &delegate, &callback_id),
diff --git a/common/utils.cc b/common/utils.cc
index 0b76eea..e3ffa1c 100644
--- a/common/utils.cc
+++ b/common/utils.cc
@@ -56,7 +56,6 @@
 
 #include "update_engine/common/constants.h"
 #include "update_engine/common/platform_constants.h"
-#include "update_engine/common/prefs_interface.h"
 #include "update_engine/common/subprocess.h"
 #include "update_engine/payload_consumer/file_descriptor.h"
 
@@ -359,7 +358,7 @@
 }
 
 off_t BlockDevSize(int fd) {
-  uint64_t dev_size;
+  uint64_t dev_size{};
   int rc = ioctl(fd, BLKGETSIZE64, &dev_size);
   if (rc == -1) {
     dev_size = -1;
@@ -369,7 +368,7 @@
 }
 
 off_t FileSize(int fd) {
-  struct stat stbuf;
+  struct stat stbuf {};
   int rc = fstat(fd, &stbuf);
   CHECK_EQ(rc, 0);
   if (rc < 0) {
@@ -491,17 +490,17 @@
 }
 
 bool FileExists(const char* path) {
-  struct stat stbuf;
+  struct stat stbuf {};
   return 0 == lstat(path, &stbuf);
 }
 
 bool IsSymlink(const char* path) {
-  struct stat stbuf;
+  struct stat stbuf {};
   return lstat(path, &stbuf) == 0 && S_ISLNK(stbuf.st_mode) != 0;
 }
 
 bool IsRegFile(const char* path) {
-  struct stat stbuf;
+  struct stat stbuf {};
   return lstat(path, &stbuf) == 0 && S_ISREG(stbuf.st_mode) != 0;
 }
 
@@ -539,7 +538,7 @@
   }
   ScopedFdCloser fd_closer(&fd);
   // We take no action if not needed.
-  int read_only_flag;
+  int read_only_flag{};
   int expected_flag = read_only ? 1 : 0;
   int rc = ioctl(fd, BLKROGET, &read_only_flag);
   // In case of failure reading the setting we will try to set it anyway.
@@ -607,7 +606,8 @@
 }
 
 bool IsMountpoint(const std::string& mountpoint) {
-  struct stat stdir, stparent;
+  struct stat stdir {
+  }, stparent{};
 
   // Check whether the passed mountpoint is a directory and the /.. is in the
   // same device or not. If mountpoint/.. is in a different device it means that
@@ -678,7 +678,7 @@
   // and size is the same for both 32 and 64 bits.
   if (size < offsetof(Elf32_Ehdr, e_machine) + sizeof(hdr->e_machine))
     return true;
-  uint16_t e_machine;
+  uint16_t e_machine{};
   // Fix endianness regardless of the host endianness.
   if (ei_data == ELFDATA2LSB)
     e_machine = le16toh(hdr->e_machine);
@@ -766,7 +766,7 @@
 }
 
 string ToString(const Time utc_time) {
-  Time::Exploded exp_time;
+  Time::Exploded exp_time{};
   utc_time.UTCExplode(&exp_time);
   return base::StringPrintf("%d/%d/%d %d:%02d:%02d GMT",
                             exp_time.month,
@@ -1004,7 +1004,7 @@
   }
   vector<string> tokens = base::SplitString(
       version, ".", base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL);
-  int value;
+  int value{};
   if (tokens.empty() || !base::StringToInt(tokens[0], &value))
     return -1;  // Target version is invalid.
   return value;
@@ -1025,8 +1025,8 @@
     return;
   }
 
-  int high;
-  int low;
+  int high{};
+  int low{};
   if (!(base::StringToInt(parts[0], &high) &&
         base::StringToInt(parts[1], &low))) {
     // Both parts of the version could not be parsed correctly.
@@ -1051,7 +1051,7 @@
 }
 
 string GetTimeAsString(time_t utime) {
-  struct tm tm;
+  struct tm tm {};
   CHECK_EQ(localtime_r(&utime, &tm), &tm);
   char str[16];
   CHECK_EQ(strftime(str, sizeof(str), "%Y%m%d-%H%M%S", &tm), 15u);
diff --git a/download_action.cc b/download_action.cc
index ab86a7e..c0463de 100644
--- a/download_action.cc
+++ b/download_action.cc
@@ -25,7 +25,6 @@
 #include <base/metrics/statistics_recorder.h>
 #include <base/strings/stringprintf.h>
 
-#include "update_engine/common/action_pipe.h"
 #include "update_engine/common/boot_control_interface.h"
 #include "update_engine/common/error_code_utils.h"
 #include "update_engine/common/multi_range_http_fetcher.h"
diff --git a/payload_consumer/delta_performer_integration_test.cc b/payload_consumer/delta_performer_integration_test.cc
index de948fb..d56c1ab 100644
--- a/payload_consumer/delta_performer_integration_test.cc
+++ b/payload_consumer/delta_performer_integration_test.cc
@@ -46,7 +46,6 @@
 #include "update_engine/payload_consumer/install_plan.h"
 #include "update_engine/payload_consumer/payload_constants.h"
 #include "update_engine/payload_consumer/payload_metadata.h"
-#include "update_engine/payload_consumer/payload_verifier.h"
 #include "update_engine/payload_generator/delta_diff_generator.h"
 #include "update_engine/payload_generator/payload_signer.h"
 #include "update_engine/update_metadata.pb.h"
@@ -221,7 +220,7 @@
 static void SignGeneratedPayload(const string& payload_path,
                                  uint64_t* out_metadata_size) {
   string private_key_path = GetBuildArtifactsPath(kUnittestPrivateKeyPath);
-  size_t signature_size;
+  size_t signature_size{};
   ASSERT_TRUE(PayloadSigner::GetMaximumSignatureSize(private_key_path,
                                                      &signature_size));
   brillo::Blob metadata_hash, payload_hash;
@@ -249,7 +248,7 @@
     bool verification_success) {
   vector<string> signature_size_strings;
   for (const auto& key_path : private_key_paths) {
-    size_t signature_size;
+    size_t signature_size{};
     ASSERT_TRUE(
         PayloadSigner::GetMaximumSignatureSize(key_path, &signature_size));
     signature_size_strings.push_back(base::StringPrintf("%zu", signature_size));
@@ -593,7 +592,7 @@
 
   if (signature_test == kSignatureGeneratedPlaceholder ||
       signature_test == kSignatureGeneratedPlaceholderMismatch) {
-    size_t signature_size;
+    size_t signature_size{};
     ASSERT_TRUE(PayloadSigner::GetMaximumSignatureSize(
         GetBuildArtifactsPath(kUnittestPrivateKeyPath), &signature_size));
     LOG(INFO) << "Inserting placeholder signature.";
@@ -828,8 +827,8 @@
                                                install_plan->target_slot,
                                                state->result_kernel->path());
 
-  ErrorCode expected_error, actual_error;
-  bool continue_writing;
+  ErrorCode expected_error{}, actual_error{};
+  bool continue_writing{};
   switch (op_hash_test) {
     case kInvalidOperationData: {
       // Muck with some random offset post the metadata size so that
diff --git a/payload_consumer/delta_performer_unittest.cc b/payload_consumer/delta_performer_unittest.cc
index effc8f3..0f48da1 100644
--- a/payload_consumer/delta_performer_unittest.cc
+++ b/payload_consumer/delta_performer_unittest.cc
@@ -49,7 +49,6 @@
 #include "update_engine/common/test_utils.h"
 #include "update_engine/common/testing_constants.h"
 #include "update_engine/common/utils.h"
-#include "update_engine/payload_consumer/fake_file_descriptor.h"
 #include "update_engine/payload_consumer/mock_partition_writer.h"
 #include "update_engine/payload_consumer/payload_constants.h"
 #include "update_engine/payload_consumer/payload_metadata.h"
@@ -339,7 +338,7 @@
 
     payload_.metadata_size = expected_metadata_size;
     payload_.size = actual_metadata_size + 1;
-    ErrorCode error_code;
+    ErrorCode error_code{};
     // When filling in size in manifest, exclude the size of the 24-byte header.
     uint64_t size_in_manifest = htobe64(actual_metadata_size - 24);
     performer_.Write(&size_in_manifest, 8, &error_code);
@@ -374,8 +373,8 @@
 
     install_plan_.hash_checks_mandatory = hash_checks_mandatory;
 
-    MetadataParseResult expected_result, actual_result;
-    ErrorCode expected_error, actual_error;
+    MetadataParseResult expected_result{}, actual_result{};
+    ErrorCode expected_error{}, actual_error{};
 
     // Fill up the metadata signature in install plan according to the test.
     switch (metadata_signature_test) {
@@ -886,7 +885,7 @@
                                PayloadMetadata::kDeltaManifestSizeSize));
   uint32_t metadata_signature_size_be = htobe32(metadata_signature_size);
 
-  ErrorCode error;
+  ErrorCode error{};
   EXPECT_FALSE(
       performer_.Write(&metadata_signature_size_be,
                        PayloadMetadata::kDeltaMetadataSignatureSizeSize + 1,
@@ -916,7 +915,7 @@
                                PayloadMetadata::kDeltaManifestSizeSize));
 
   uint32_t metadata_signature_size_be = htobe32(metadata_signature_size);
-  ErrorCode error;
+  ErrorCode error{};
   EXPECT_FALSE(
       performer_.Write(&metadata_signature_size_be,
                        PayloadMetadata::kDeltaMetadataSignatureSizeSize + 1,
@@ -930,7 +929,7 @@
       {}, {}, true, kBrilloMajorPayloadVersion, kSourceMinorPayloadVersion);
   install_plan_.hash_checks_mandatory = true;
   payload_.size = payload_data.size();
-  ErrorCode error;
+  ErrorCode error{};
   EXPECT_EQ(MetadataParseResult::kSuccess,
             performer_.ParsePayloadMetadata(payload_data, &error));
   EXPECT_EQ(ErrorCode::kSuccess, error);
@@ -1072,14 +1071,14 @@
 TEST(DISABLED_ConfVersionTest, ConfVersionsMatch) {
   // Test that the versions in update_engine.conf that is installed to the
   // image match the maximum supported delta versions in the update engine.
-  uint32_t minor_version;
+  uint32_t minor_version{};
   brillo::KeyValueStore store;
   EXPECT_TRUE(store.Load(GetBuildArtifactsPath().Append("update_engine.conf")));
   EXPECT_TRUE(utils::GetMinorVersion(store, &minor_version));
   EXPECT_EQ(kMaxSupportedMinorPayloadVersion, minor_version);
 
   string major_version_str;
-  uint64_t major_version;
+  uint64_t major_version{};
   EXPECT_TRUE(store.GetString("PAYLOAD_MAJOR_VERSION", &major_version_str));
   EXPECT_TRUE(base::StringToUint64(major_version_str, &major_version));
   EXPECT_EQ(kMaxSupportedMajorPayloadVersion, major_version);
diff --git a/payload_consumer/filesystem_verifier_action_unittest.cc b/payload_consumer/filesystem_verifier_action_unittest.cc
index 533292a..b2ed158 100644
--- a/payload_consumer/filesystem_verifier_action_unittest.cc
+++ b/payload_consumer/filesystem_verifier_action_unittest.cc
@@ -37,7 +37,6 @@
 #include "update_engine/common/mock_dynamic_partition_control.h"
 #include "update_engine/common/test_utils.h"
 #include "update_engine/common/utils.h"
-#include "update_engine/payload_consumer/fake_file_descriptor.h"
 #include "update_engine/payload_consumer/install_plan.h"
 #include "update_engine/payload_consumer/verity_writer_android.h"
 
diff --git a/payload_generator/delta_diff_utils.cc b/payload_generator/delta_diff_utils.cc
index 389cf97..8ee1436 100644
--- a/payload_generator/delta_diff_utils.cc
+++ b/payload_generator/delta_diff_utils.cc
@@ -57,8 +57,8 @@
 #include <zucchini/zucchini.h>
 
 #include "update_engine/common/hash_calculator.h"
-#include "update_engine/common/subprocess.h"
 #include "update_engine/common/utils.h"
+#include "update_engine/lz4diff/lz4diff.h"
 #include "update_engine/payload_consumer/payload_constants.h"
 #include "update_engine/payload_generator/ab_generator.h"
 #include "update_engine/payload_generator/block_mapping.h"
@@ -67,10 +67,7 @@
 #include "update_engine/payload_generator/delta_diff_generator.h"
 #include "update_engine/payload_generator/extent_ranges.h"
 #include "update_engine/payload_generator/extent_utils.h"
-#include "update_engine/payload_generator/merge_sequence_generator.h"
-#include "update_engine/payload_generator/squashfs_filesystem.h"
 #include "update_engine/payload_generator/xz.h"
-#include "update_engine/lz4diff/lz4diff.h"
 
 using std::list;
 using std::map;
@@ -220,7 +217,7 @@
       config_.OperationEnabled(InstallOperation::LZ4DIFF_BSDIFF) &&
       config_.OperationEnabled(InstallOperation::LZ4DIFF_PUFFDIFF)) {
     brillo::Blob patch;
-    InstallOperation::Type op_type;
+    InstallOperation::Type op_type{};
     if (Lz4Diff(old_data_,
                 new_data_,
                 old_block_info_,
@@ -1071,7 +1068,7 @@
 
   // Try generating a full operation for the given new data, regardless of the
   // old_data.
-  InstallOperation::Type op_type;
+  InstallOperation::Type op_type{};
   TEST_AND_RETURN_FALSE(
       GenerateBestFullOperation(new_data, version, &data_blob, &op_type));
   operation.set_type(op_type);
diff --git a/payload_generator/generate_delta_main.cc b/payload_generator/generate_delta_main.cc
index 96883a8..64e7249 100644
--- a/payload_generator/generate_delta_main.cc
+++ b/payload_generator/generate_delta_main.cc
@@ -123,7 +123,7 @@
   vector<brillo::Blob> payload_signatures, metadata_signatures;
   SignatureFileFlagToBlobs(payload_signature_file, &payload_signatures);
   SignatureFileFlagToBlobs(metadata_signature_file, &metadata_signatures);
-  uint64_t final_metadata_size;
+  uint64_t final_metadata_size{};
   CHECK(PayloadSigner::AddSignatureToPayload(in_file,
                                              signature_sizes,
                                              payload_signatures,
@@ -483,7 +483,7 @@
         << "Private key is not provided when calculating the maximum signature "
            "size.";
 
-    size_t maximum_signature_size;
+    size_t maximum_signature_size{};
     if (!PayloadSigner::GetMaximumSignatureSize(FLAGS_private_key,
                                                 &maximum_signature_size)) {
       LOG(ERROR) << "Failed to get the maximum signature size of private key: "
@@ -690,7 +690,7 @@
     // image.
     if (payload_config.is_delta) {
       brillo::KeyValueStore store;
-      uint32_t minor_version;
+      uint32_t minor_version{};
       bool minor_version_found = false;
       for (const PartitionConfig& part : payload_config.source.partitions) {
         if (part.fs_interface && part.fs_interface->LoadSettings(&store) &&
@@ -758,7 +758,7 @@
     return 1;
   }
 
-  uint64_t metadata_size;
+  uint64_t metadata_size{};
   if (!GenerateUpdatePayloadFile(
           payload_config, FLAGS_out_file, FLAGS_private_key, &metadata_size)) {
     return 1;
diff --git a/test_http_server.cc b/test_http_server.cc
index 388949f..ba5e9ac 100644
--- a/test_http_server.cc
+++ b/test_http_server.cc
@@ -112,7 +112,7 @@
   LOG(INFO) << "URL: " << request->url;
 
   // Decode remaining lines.
-  size_t i;
+  size_t i{};
   for (i = 1; i < lines.size(); i++) {
     terms = base::SplitString(lines[i],
                               base::kWhitespaceASCII,
@@ -184,7 +184,7 @@
                      const off_t start_offset,
                      const off_t end_offset,
                      HttpResponseCode return_code) {
-  ssize_t written = 0, ret;
+  ssize_t written = 0, ret{};
 
   ret = WriteString(fd,
                     string("HTTP/1.1 ") + Itoa(return_code) + " " +
@@ -239,7 +239,7 @@
   string line;
   line.reserve(line_len);
   char byte = first_byte;
-  size_t i;
+  size_t i{};
   for (i = 0; i < line_len; i++)
     line += byte++;
 
@@ -299,7 +299,7 @@
                   const size_t truncate_length,
                   const int sleep_every,
                   const int sleep_secs) {
-  ssize_t ret;
+  ssize_t ret{};
   size_t written = 0;
 
   // Obtain start offset, make sure it is within total payload length.
@@ -403,7 +403,7 @@
   LOG(INFO) << "Code: " << code << " " << status;
   LOG(INFO) << "New URL: " << url;
 
-  ssize_t ret;
+  ssize_t ret{};
   if ((ret = WriteString(fd, "HTTP/1.1 " + Itoa(code) + " " + status + EOL)) <
       0)
     return;
@@ -416,7 +416,7 @@
 ssize_t HandleError(int fd, const HttpRequest& request) {
   LOG(INFO) << "Generating error HTTP response";
 
-  ssize_t ret;
+  ssize_t ret{};
   size_t written = 0;
 
   const string data("This is an error page.");
@@ -444,7 +444,7 @@
   if (request.start_offset > 0 && num_fails < max_fails) {
     LOG(INFO) << "Generating error HTTP response";
 
-    ssize_t ret;
+    ssize_t ret{};
     size_t written = 0;
 
     const string data("This is an error page.");
@@ -475,7 +475,7 @@
 
 void HandleHang(int fd) {
   LOG(INFO) << "Hanging until the other side of the connection is closed.";
-  char c;
+  char c{};
   while (HANDLE_EINTR(read(fd, &c, 1)) > 0) {
   }
 }
@@ -484,7 +484,7 @@
   const off_t start_offset = request.start_offset;
   const string data("unhandled path");
   const size_t size = data.size();
-  ssize_t ret;
+  ssize_t ret{};
 
   if ((ret = WriteHeaders(fd, start_offset, size, request.return_code)) < 0)
     return;