update_engine: Use integer types from stdint.h

This CL replaces the deprecated int* and uint* types from
'base/basictypes.h' with the int*_t and uint*_t types from 'stdint.h'.

BUG=chromium:401356
TEST=`FEATURES=test emerge-$BOARD update_engine`

Change-Id: I658b34ad9e6feb938e0b569b72947a052ef8f8af
Reviewed-on: https://chromium-review.googlesource.com/211380
Reviewed-by: Mike Frysinger <[email protected]>
Tested-by: Ben Chan <[email protected]>
Commit-Queue: Ben Chan <[email protected]>
diff --git a/omaha_request_action.cc b/omaha_request_action.cc
index 7ccd0d5..76eeee7 100644
--- a/omaha_request_action.cc
+++ b/omaha_request_action.cc
@@ -984,7 +984,7 @@
 OmahaRequestAction::IsWallClockBasedWaitingSatisfied(
     OmahaResponse* output_object) {
   Time update_first_seen_at;
-  int64 update_first_seen_at_int;
+  int64_t update_first_seen_at_int;
 
   if (system_state_->prefs()->Exists(kPrefsUpdateFirstSeenAt)) {
     if (system_state_->prefs()->GetInt64(kPrefsUpdateFirstSeenAt,
@@ -1084,7 +1084,7 @@
 }
 
 bool OmahaRequestAction::IsUpdateCheckCountBasedWaitingSatisfied() {
-  int64 update_check_count_value;
+  int64_t update_check_count_value;
 
   if (system_state_->prefs()->Exists(kPrefsUpdateCheckCount)) {
     if (!system_state_->prefs()->GetInt64(kPrefsUpdateCheckCount,
diff --git a/omaha_request_action_unittest.cc b/omaha_request_action_unittest.cc
index d210879..8036f46 100644
--- a/omaha_request_action_unittest.cc
+++ b/omaha_request_action_unittest.cc
@@ -2,11 +2,12 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include <glib.h>
+#include <stdint.h>
+
 #include <string>
 #include <vector>
 
-#include <glib.h>
-
 #include <base/strings/string_util.h>
 #include <base/strings/stringprintf.h>
 #include <base/time/time.h>
@@ -741,7 +742,7 @@
                       &response,
                       NULL));
 
-  int64 count;
+  int64_t count;
   ASSERT_TRUE(prefs.GetInt64(kPrefsUpdateCheckCount, &count));
   ASSERT_EQ(count, 0);
   EXPECT_TRUE(response.update_exists);
@@ -795,7 +796,7 @@
                       &response,
                       NULL));
 
-  int64 count;
+  int64_t count;
   ASSERT_TRUE(prefs.GetInt64(kPrefsUpdateCheckCount, &count));
   ASSERT_GT(count, 0);
   EXPECT_FALSE(response.update_exists);
@@ -883,7 +884,7 @@
                       &response,
                       NULL));
 
-  int64 count;
+  int64_t count;
   ASSERT_TRUE(prefs.GetInt64(kPrefsUpdateCheckCount, &count));
   // count remains the same, as the decrementing happens in update_attempter
   // which this test doesn't exercise.
@@ -1252,7 +1253,7 @@
                                         "file.signed",  // file name
                                         "HASH1234=",  // checksum
                                         "false",  // needs admin
-                                        // overflows int32:
+                                        // overflows int32_t:
                                         "123123123123123",  // size
                                         "deadline"),
                       -1,
@@ -1937,7 +1938,7 @@
                       &response,
                       NULL));
 
-  int64 timestamp = 0;
+  int64_t timestamp = 0;
   ASSERT_TRUE(prefs.GetInt64(kPrefsUpdateFirstSeenAt, &timestamp));
   ASSERT_GT(timestamp, 0);
   EXPECT_FALSE(response.update_exists);
@@ -2028,7 +2029,7 @@
   EXPECT_TRUE(response.update_exists);
 
   // Make sure the timestamp t1 is unchanged showing that it was reused.
-  int64 timestamp = 0;
+  int64_t timestamp = 0;
   ASSERT_TRUE(prefs.GetInt64(kPrefsUpdateFirstSeenAt, &timestamp));
   ASSERT_TRUE(timestamp == t1.ToInternalValue());
 }
diff --git a/omaha_request_params.h b/omaha_request_params.h
index 06461aa..1c0ac0d 100644
--- a/omaha_request_params.h
+++ b/omaha_request_params.h
@@ -5,6 +5,8 @@
 #ifndef UPDATE_ENGINE_OMAHA_REQUEST_PARAMS_H_
 #define UPDATE_ENGINE_OMAHA_REQUEST_PARAMS_H_
 
+#include <stdint.h>
+
 #include <string>
 
 #include <base/basictypes.h>
@@ -163,17 +165,17 @@
     return update_check_count_wait_enabled_;
   }
 
-  inline void set_min_update_checks_needed(int64 min) {
+  inline void set_min_update_checks_needed(int64_t min) {
     min_update_checks_needed_ = min;
   }
-  inline int64 min_update_checks_needed() const {
+  inline int64_t min_update_checks_needed() const {
     return min_update_checks_needed_;
   }
 
-  inline void set_max_update_checks_allowed(int64 max) {
+  inline void set_max_update_checks_allowed(int64_t max) {
     max_update_checks_allowed_ = max;
   }
-  inline int64 max_update_checks_allowed() const {
+  inline int64_t max_update_checks_allowed() const {
     return max_update_checks_allowed_;
   }
 
@@ -213,8 +215,8 @@
   static const char* const kUpdateUrl;
   static const char* const kUpdateChannelKey;
   static const char* const kIsPowerwashAllowedKey;
-  static const int64 kDefaultMinUpdateChecks = 0;
-  static const int64 kDefaultMaxUpdateChecks = 8;
+  static const int64_t kDefaultMinUpdateChecks = 0;
+  static const int64_t kDefaultMaxUpdateChecks = 8;
 
   // Initializes all the data in the object. Non-empty
   // |in_app_version| or |in_update_url| prevents automatic detection
@@ -372,8 +374,8 @@
   // values establish the bounds for a random number to be chosen within that
   // range to enable such a wait.
   bool update_check_count_wait_enabled_;
-  int64 min_update_checks_needed_;
-  int64 max_update_checks_allowed_;
+  int64_t min_update_checks_needed_;
+  int64_t max_update_checks_allowed_;
 
   // True if we are allowed to do powerwash, if required, on a channel change.
   bool is_powerwash_allowed_;
diff --git a/prefs_interface.h b/prefs_interface.h
index daf9196..6c0a741 100644
--- a/prefs_interface.h
+++ b/prefs_interface.h
@@ -5,6 +5,8 @@
 #ifndef UPDATE_ENGINE_PREFS_INTERFACE_H_
 #define UPDATE_ENGINE_PREFS_INTERFACE_H_
 
+#include <stdint.h>
+
 #include <string>
 
 namespace chromeos_update_engine {
@@ -25,12 +27,12 @@
   // false otherwise.
   virtual bool SetString(const std::string& key, const std::string& value) = 0;
 
-  // Gets an int64 |value| associated with |key|. Returns true on
+  // Gets an int64_t |value| associated with |key|. Returns true on
   // success, false on failure (including when the |key| is not
   // present in the store).
   virtual bool GetInt64(const std::string& key, int64_t* value) = 0;
 
-  // Associates |key| with an int64 |value|. Returns true on success,
+  // Associates |key| with an int64_t |value|. Returns true on success,
   // false otherwise.
   virtual bool SetInt64(const std::string& key, const int64_t value) = 0;
 
diff --git a/update_attempter.cc b/update_attempter.cc
index bd086a8..437ff42 100644
--- a/update_attempter.cc
+++ b/update_attempter.cc
@@ -4,6 +4,8 @@
 
 #include "update_engine/update_attempter.h"
 
+#include <stdint.h>
+
 #include <algorithm>
 #include <memory>
 #include <set>
@@ -447,7 +449,7 @@
   TimeDelta old_scatter_factor = scatter_factor_;
   const policy::DevicePolicy* device_policy = system_state_->device_policy();
   if (device_policy) {
-    int64 new_scatter_factor_in_secs = 0;
+    int64_t new_scatter_factor_in_secs = 0;
     device_policy->GetScatterFactorInSeconds(&new_scatter_factor_in_secs);
     if (new_scatter_factor_in_secs < 0)  // sanitize input, just in case.
       new_scatter_factor_in_secs  = 0;
@@ -474,7 +476,7 @@
     //    (omaha_request_params_->waiting_period will be zero in this case).
     // 2. Admin has changed the scattering policy value.
     //    (new scattering value will be different from old one in this case).
-    int64 wait_period_in_secs = 0;
+    int64_t wait_period_in_secs = 0;
     if (omaha_request_params_->waiting_period().InSeconds() == 0) {
       // First case. Check if we have a suitable value to set for
       // the waiting period.
@@ -1427,7 +1429,7 @@
 
 
 bool UpdateAttempter::DecrementUpdateCheckCount() {
-  int64 update_check_count_value;
+  int64_t update_check_count_value;
 
   if (!prefs_->Exists(kPrefsUpdateCheckCount)) {
     // This file does not exist. This means we haven't started our update
diff --git a/update_attempter_unittest.cc b/update_attempter_unittest.cc
index 43897aa..632c297 100644
--- a/update_attempter_unittest.cc
+++ b/update_attempter_unittest.cc
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include <stdint.h>
+
 #include <base/file_util.h>
 #include <gtest/gtest.h>
 #include <policy/libpolicy.h>
@@ -893,7 +895,7 @@
 // Tests that the scatter_factor_in_seconds value is properly fetched
 // from the device policy.
 void UpdateAttempterTest::ReadScatterFactorFromPolicyTestStart() {
-  int64 scatter_factor_in_seconds = 36000;
+  int64_t scatter_factor_in_seconds = 36000;
 
   policy::MockDevicePolicy* device_policy = new policy::MockDevicePolicy();
   attempter_.policy_provider_.reset(new policy::PolicyProvider(device_policy));
@@ -923,7 +925,7 @@
 void UpdateAttempterTest::DecrementUpdateCheckCountTestStart() {
   // Tests that the scatter_factor_in_seconds value is properly fetched
   // from the device policy and is decremented if value > 0.
-  int64 initial_value = 5;
+  int64_t initial_value = 5;
   Prefs prefs;
   attempter_.prefs_ = &prefs;
 
@@ -938,7 +940,7 @@
       << "Failed to initialize preferences.";
   EXPECT_TRUE(prefs.SetInt64(kPrefsUpdateCheckCount, initial_value));
 
-  int64 scatter_factor_in_seconds = 10;
+  int64_t scatter_factor_in_seconds = 10;
 
   policy::MockDevicePolicy* device_policy = new policy::MockDevicePolicy();
   attempter_.policy_provider_.reset(new policy::PolicyProvider(device_policy));
@@ -957,7 +959,7 @@
   // Make sure the file still exists.
   EXPECT_TRUE(prefs.Exists(kPrefsUpdateCheckCount));
 
-  int64 new_value;
+  int64_t new_value;
   EXPECT_TRUE(prefs.GetInt64(kPrefsUpdateCheckCount, &new_value));
   EXPECT_EQ(initial_value - 1, new_value);
 
@@ -986,7 +988,7 @@
 void UpdateAttempterTest::NoScatteringDoneDuringManualUpdateTestStart() {
   // Tests that no scattering logic is enabled if the update check
   // is manually done (as opposed to a scheduled update check)
-  int64 initial_value = 8;
+  int64_t initial_value = 8;
   Prefs prefs;
   attempter_.prefs_ = &prefs;
 
@@ -1004,7 +1006,7 @@
 
   // make sure scatter_factor is non-zero as scattering is disabled
   // otherwise.
-  int64 scatter_factor_in_seconds = 50;
+  int64_t scatter_factor_in_seconds = 50;
 
   policy::MockDevicePolicy* device_policy = new policy::MockDevicePolicy();
   attempter_.policy_provider_.reset(new policy::PolicyProvider(device_policy));
diff --git a/utils.cc b/utils.cc
index 8f1a122..f69dab4 100644
--- a/utils.cc
+++ b/utils.cc
@@ -4,6 +4,8 @@
 
 #include "update_engine/utils.h"
 
+#include <stdint.h>
+
 #include <attr/xattr.h>
 #include <dirent.h>
 #include <errno.h>
@@ -732,7 +734,7 @@
   // 0x12: e_machine, 2 byte endianness based on ei_data
   if (size < 0x12 + 2)
     return true;
-  uint16 e_machine = *reinterpret_cast<const uint16*>(buffer+0x12);
+  uint16_t e_machine = *reinterpret_cast<const uint16_t*>(buffer+0x12);
   // Fix endianess regardless of the host endianess.
   if (ei_data == 1)
     e_machine = le16toh(e_machine);
@@ -1373,8 +1375,8 @@
 }
 
 Time TimeFromStructTimespec(struct timespec *ts) {
-  int64 us = static_cast<int64>(ts->tv_sec) * Time::kMicrosecondsPerSecond +
-      static_cast<int64>(ts->tv_nsec) / Time::kNanosecondsPerMicrosecond;
+  int64_t us = static_cast<int64_t>(ts->tv_sec) * Time::kMicrosecondsPerSecond +
+      static_cast<int64_t>(ts->tv_nsec) / Time::kNanosecondsPerMicrosecond;
   return Time::UnixEpoch() + TimeDelta::FromMicroseconds(us);
 }
 
diff --git a/utils_unittest.cc b/utils_unittest.cc
index a9ce287..aa1f919 100644
--- a/utils_unittest.cc
+++ b/utils_unittest.cc
@@ -3,6 +3,7 @@
 // found in the LICENSE file.
 
 #include <errno.h>
+#include <stdint.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 
@@ -356,7 +357,7 @@
 
 namespace {
 void GetFileFormatTester(const string& expected,
-                         const vector<uint8>& contents) {
+                         const vector<uint8_t>& contents) {
   ScopedTempFile file;
   ASSERT_TRUE(utils::WriteFile(file.GetPath().c_str(),
                                reinterpret_cast<const char*>(contents.data()),
@@ -367,33 +368,33 @@
 
 TEST(UtilsTest, GetFileFormatTest) {
   EXPECT_EQ("File not found.", utils::GetFileFormat("/path/to/nowhere"));
-  GetFileFormatTester("data", vector<uint8>{1, 2, 3, 4, 5, 6, 7, 8});
-  GetFileFormatTester("ELF", vector<uint8>{0x7f, 0x45, 0x4c, 0x46});
+  GetFileFormatTester("data", vector<uint8_t>{1, 2, 3, 4, 5, 6, 7, 8});
+  GetFileFormatTester("ELF", vector<uint8_t>{0x7f, 0x45, 0x4c, 0x46});
 
   // Real tests from cros_installer on different boards.
   // ELF 32-bit LSB executable, Intel 80386
   GetFileFormatTester(
       "ELF 32-bit little-endian x86",
-      vector<uint8>{0x7f, 0x45, 0x4c, 0x46, 0x01, 0x01, 0x01, 0x00,
-                    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-                    0x02, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00,
-                    0x90, 0x83, 0x04, 0x08, 0x34, 0x00, 0x00, 0x00});
+      vector<uint8_t>{0x7f, 0x45, 0x4c, 0x46, 0x01, 0x01, 0x01, 0x00,
+                      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                      0x02, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00,
+                      0x90, 0x83, 0x04, 0x08, 0x34, 0x00, 0x00, 0x00});
 
   // ELF 32-bit LSB executable, ARM
   GetFileFormatTester(
       "ELF 32-bit little-endian arm",
-      vector<uint8>{0x7f, 0x45, 0x4c, 0x46, 0x01, 0x01, 0x01, 0x00,
-                    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-                    0x02, 0x00, 0x28, 0x00, 0x01, 0x00, 0x00, 0x00,
-                    0x85, 0x8b, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00});
+      vector<uint8_t>{0x7f, 0x45, 0x4c, 0x46, 0x01, 0x01, 0x01, 0x00,
+                      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                      0x02, 0x00, 0x28, 0x00, 0x01, 0x00, 0x00, 0x00,
+                      0x85, 0x8b, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00});
 
   // ELF 64-bit LSB executable, x86-64
   GetFileFormatTester(
       "ELF 64-bit little-endian x86-64",
-      vector<uint8>{0x7f, 0x45, 0x4c, 0x46, 0x02, 0x01, 0x01, 0x00,
-                    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-                    0x02, 0x00, 0x3e, 0x00, 0x01, 0x00, 0x00, 0x00,
-                    0xb0, 0x04, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00});
+      vector<uint8_t>{0x7f, 0x45, 0x4c, 0x46, 0x02, 0x01, 0x01, 0x00,
+                      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                      0x02, 0x00, 0x3e, 0x00, 0x01, 0x00, 0x00, 0x00,
+                      0xb0, 0x04, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00});
 }
 
 namespace {