Replace libchrome size() with C++ standard ones
This change is for partially replacing <base/stl_util.h>'s base::size()
with std::size() in the C++ standard.
Also remove #include <base/stl_util.h>.
Test: build
Bug: 360917504
Change-Id: I09dbec56cda00c00f195875395461676bd55287a
diff --git a/common/http_fetcher_unittest.cc b/common/http_fetcher_unittest.cc
index b229660..d5b319a 100644
--- a/common/http_fetcher_unittest.cc
+++ b/common/http_fetcher_unittest.cc
@@ -1031,7 +1031,7 @@
unique_ptr<HttpServer> server(this->test_.CreateServer());
ASSERT_TRUE(server->started_);
- for (size_t c = 0; c < base::size(kRedirectCodes); ++c) {
+ for (size_t c = 0; c < std::size(kRedirectCodes); ++c) {
const string url = base::StringPrintf(
"/redirect/%d/download/%d", kRedirectCodes[c], kMediumLength);
RedirectTest(server.get(), true, url, this->test_.NewLargeFetcher());
@@ -1048,7 +1048,7 @@
string url;
for (int r = 0; r < kDownloadMaxRedirects; r++) {
url += base::StringPrintf("/redirect/%d",
- kRedirectCodes[r % base::size(kRedirectCodes)]);
+ kRedirectCodes[r % std::size(kRedirectCodes)]);
}
url += base::StringPrintf("/download/%d", kMediumLength);
RedirectTest(server.get(), true, url, this->test_.NewLargeFetcher());
@@ -1064,7 +1064,7 @@
string url;
for (int r = 0; r < kDownloadMaxRedirects + 1; r++) {
url += base::StringPrintf("/redirect/%d",
- kRedirectCodes[r % base::size(kRedirectCodes)]);
+ kRedirectCodes[r % std::size(kRedirectCodes)]);
}
url += base::StringPrintf("/download/%d", kMediumLength);
RedirectTest(server.get(), false, url, this->test_.NewLargeFetcher());
diff --git a/common/subprocess.cc b/common/subprocess.cc
index 9e53d6d..03ec22a 100644
--- a/common/subprocess.cc
+++ b/common/subprocess.cc
@@ -30,7 +30,6 @@
#include <base/bind.h>
#include <base/logging.h>
#include <base/posix/eintr_wrapper.h>
-#include <base/stl_util.h>
#include <base/strings/string_util.h>
#include <base/strings/stringprintf.h>
#include <brillo/secure_blob.h>
@@ -128,7 +127,7 @@
bytes_read = 0;
bool eof;
bool ok = utils::ReadAll(
- record->stdout_fd, buf, base::size(buf), &bytes_read, &eof);
+ record->stdout_fd, buf, std::size(buf), &bytes_read, &eof);
record->stdout_str.append(buf, bytes_read);
if (!ok || eof) {
// There was either an error or an EOF condition, so we are done watching
diff --git a/libcurl_http_fetcher.cc b/libcurl_http_fetcher.cc
index b8d11f5..2e5a520 100644
--- a/libcurl_http_fetcher.cc
+++ b/libcurl_http_fetcher.cc
@@ -83,7 +83,7 @@
LibcurlHttpFetcher* fetcher = static_cast<LibcurlHttpFetcher*>(clientp);
// Stop watching the socket before closing it.
- for (size_t t = 0; t < base::size(fetcher->fd_controller_maps_); ++t) {
+ for (size_t t = 0; t < std::size(fetcher->fd_controller_maps_); ++t) {
fetcher->fd_controller_maps_[t].erase(item);
}
@@ -683,7 +683,7 @@
// We should iterate through all file descriptors up to libcurl's fd_max or
// the highest one we're tracking, whichever is larger.
- for (size_t t = 0; t < base::size(fd_controller_maps_); ++t) {
+ for (size_t t = 0; t < std::size(fd_controller_maps_); ++t) {
if (!fd_controller_maps_[t].empty())
fd_max = max(fd_max, fd_controller_maps_[t].rbegin()->first);
}
@@ -701,7 +701,7 @@
is_exc || (FD_ISSET(fd, &fd_write) != 0) // track 1 -- write
};
- for (size_t t = 0; t < base::size(fd_controller_maps_); ++t) {
+ for (size_t t = 0; t < std::size(fd_controller_maps_); ++t) {
bool tracked =
fd_controller_maps_[t].find(fd) != fd_controller_maps_[t].end();
@@ -782,7 +782,7 @@
MessageLoop::current()->CancelTask(timeout_id_);
timeout_id_ = MessageLoop::kTaskIdNull;
- for (size_t t = 0; t < base::size(fd_controller_maps_); ++t) {
+ for (size_t t = 0; t < std::size(fd_controller_maps_); ++t) {
fd_controller_maps_[t].clear();
}
diff --git a/payload_consumer/delta_performer_integration_test.cc b/payload_consumer/delta_performer_integration_test.cc
index bffee8d..ffc753a 100644
--- a/payload_consumer/delta_performer_integration_test.cc
+++ b/payload_consumer/delta_performer_integration_test.cc
@@ -20,12 +20,12 @@
#include <sys/mount.h>
#include <algorithm>
+#include <list>
#include <string>
#include <vector>
#include <base/files/file_path.h>
#include <base/files/file_util.h>
-#include <base/stl_util.h>
#include <base/strings/string_util.h>
#include <base/strings/stringprintf.h>
#include <gmock/gmock-matchers.h>
@@ -914,7 +914,7 @@
brillo::Blob updated_kernel_partition;
ASSERT_TRUE(
utils::ReadFile(state->result_kernel->path(), &updated_kernel_partition));
- ASSERT_GE(updated_kernel_partition.size(), base::size(kNewData));
+ ASSERT_GE(updated_kernel_partition.size(), std::size(kNewData));
ASSERT_TRUE(std::equal(std::begin(kNewData),
std::end(kNewData),
updated_kernel_partition.begin()));
diff --git a/payload_consumer/delta_performer_unittest.cc b/payload_consumer/delta_performer_unittest.cc
index 04cfaad..443bef6 100644
--- a/payload_consumer/delta_performer_unittest.cc
+++ b/payload_consumer/delta_performer_unittest.cc
@@ -28,7 +28,6 @@
#include <base/files/file_path.h>
#include <base/files/file_util.h>
#include <base/files/scoped_temp_dir.h>
-#include <base/stl_util.h>
#include <base/strings/string_number_conversions.h>
#include <base/strings/string_util.h>
#include <base/strings/stringprintf.h>
@@ -657,12 +656,12 @@
TEST_F(DeltaPerformerTest, ExtentsToByteStringTest) {
uint64_t test[] = {1, 1, 4, 2, 0, 1};
- static_assert(base::size(test) % 2 == 0, "Array size uneven");
+ static_assert(std::size(test) % 2 == 0, "Array size uneven");
const uint64_t block_size = 4096;
const uint64_t file_length = 4 * block_size - 13;
google::protobuf::RepeatedPtrField<Extent> extents;
- for (size_t i = 0; i < base::size(test); i += 2) {
+ for (size_t i = 0; i < std::size(test); i += 2) {
*(extents.Add()) = ExtentForRange(test[i], test[i + 1]);
}
diff --git a/payload_consumer/postinstall_runner_action.cc b/payload_consumer/postinstall_runner_action.cc
index 4de75aa..aaa8a43 100644
--- a/payload_consumer/postinstall_runner_action.cc
+++ b/payload_consumer/postinstall_runner_action.cc
@@ -30,7 +30,6 @@
#include <base/files/file_path.h>
#include <base/files/file_util.h>
#include <base/logging.h>
-#include <base/stl_util.h>
#include <base/strings/string_split.h>
#include <base/strings/string_util.h>
@@ -327,7 +326,7 @@
bytes_read = 0;
bool eof;
bool ok =
- utils::ReadAll(progress_fd_, buf, base::size(buf), &bytes_read, &eof);
+ utils::ReadAll(progress_fd_, buf, std::size(buf), &bytes_read, &eof);
progress_buffer_.append(buf, bytes_read);
// Process every line.
vector<string> lines = base::SplitString(
diff --git a/payload_generator/extent_ranges_unittest.cc b/payload_generator/extent_ranges_unittest.cc
index 5f36aa3..28a9d93 100644
--- a/payload_generator/extent_ranges_unittest.cc
+++ b/payload_generator/extent_ranges_unittest.cc
@@ -18,11 +18,10 @@
#include <vector>
-#include <base/stl_util.h>
#include <gtest/gtest.h>
-#include "update_engine/payload_generator/extent_utils.h"
#include "update_engine/payload_consumer/payload_constants.h"
+#include "update_engine/payload_generator/extent_utils.h"
using std::vector;
using chromeos_update_engine::operator==;
@@ -53,7 +52,7 @@
}
#define ASSERT_RANGE_EQ(ranges, var) \
- ASSERT_NO_FATAL_FAILURE(ExpectRangeEq(ranges, var, base::size(var), __LINE__))
+ ASSERT_NO_FATAL_FAILURE(ExpectRangeEq(ranges, var, std::size(var), __LINE__))
void ExpectRangesOverlapOrTouch(uint64_t a_start,
uint64_t a_num,
diff --git a/payload_generator/payload_signer_unittest.cc b/payload_generator/payload_signer_unittest.cc
index 96e4431..ac11fcf 100644
--- a/payload_generator/payload_signer_unittest.cc
+++ b/payload_generator/payload_signer_unittest.cc
@@ -20,7 +20,6 @@
#include <vector>
#include <base/logging.h>
-#include <base/stl_util.h>
#include <gtest/gtest.h>
#include "update_engine/common/hash_calculator.h"
@@ -111,8 +110,8 @@
EXPECT_EQ(1, signatures.signatures_size());
const Signatures::Signature& sig = signatures.signatures(0);
const string& sig_data = sig.data();
- ASSERT_EQ(base::size(kDataSignature), sig_data.size());
- for (size_t i = 0; i < base::size(kDataSignature); i++) {
+ ASSERT_EQ(std::size(kDataSignature), sig_data.size());
+ for (size_t i = 0; i < std::size(kDataSignature); i++) {
EXPECT_EQ(kDataSignature[i], static_cast<uint8_t>(sig_data[i]));
}
}