Use base::size where appropriate, and ArraySize elsewhere
This is a follow-up to c8a016b99d97, following the post-landing
discussion at
https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1393921/5#message-2058541d8c4505d20a990ab7734cd758e437a5f7
base::size, and std::size that will eventually replace it when C++17 is
assured, does not allow the size of non-static data members to be taken
in constant expression context. The remaining uses of ArraySize are in:
minidump/minidump_exception_writer.cc (×1)
minidump/minidump_system_info_writer.cc (×2, also uses base::size)
snapshot/cpu_context.cc (×4, also uses base::size)
util/misc/arraysize_test.cc (×10, of course)
The first of these occurs when initializing a constexpr variable. All
others are in expressions used with static_assert.
Includes:
Update mini_chromium to 737433ebade4d446643c6c07daae02a67e8deccao
f701716d9546 Add Windows ARM64 build target to mini_chromium
87a95a3d6ac2 Remove the arraysize macro
1f7255ead1f7 Placate MSVC in areas of base::size usage
737433ebade4 Add cast
Bug: chromium:837308
Change-Id: I6a5162654461b1bdd9b7b6864d0d71a734bcde19
Reviewed-on: https://chromium-review.googlesource.com/c/1396108
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
diff --git a/DEPS b/DEPS
index 635e141..10c37bc 100644
--- a/DEPS
+++ b/DEPS
@@ -30,7 +30,7 @@
'5e2b3ddde7cda5eb6bc09a5546a76b00e49d888f',
'crashpad/third_party/mini_chromium/mini_chromium':
Var('chromium_git') + '/chromium/mini_chromium@' +
- '4a6189577978b86fbd6935aec0d16a127803467c',
+ '737433ebade4d446643c6c07daae02a67e8decca',
'crashpad/third_party/libfuzzer/src':
Var('chromium_git') + '/chromium/llvm-project/compiler-rt/lib/fuzzer.git@' +
'fda403cf93ecb8792cb1d061564d89a6553ca020',
diff --git a/client/crash_report_database_mac.mm b/client/crash_report_database_mac.mm
index 0980fe3..414dd5a 100644
--- a/client/crash_report_database_mac.mm
+++ b/client/crash_report_database_mac.mm
@@ -29,13 +29,13 @@
#include "base/mac/scoped_nsautorelease_pool.h"
#include "base/posix/eintr_wrapper.h"
#include "base/scoped_generic.h"
+#include "base/stl_util.h"
#include "base/strings/string_piece.h"
#include "base/strings/stringprintf.h"
#include "base/strings/sys_string_conversions.h"
#include "client/settings.h"
#include "util/file/file_io.h"
#include "util/mac/xattr.h"
-#include "util/misc/arraysize.h"
#include "util/misc/initialization_state_dcheck.h"
#include "util/misc/metrics.h"
@@ -280,7 +280,7 @@
}
// Create the three processing directories for the database.
- for (size_t i = 0; i < ArraySize(kReportDirectories); ++i) {
+ for (size_t i = 0; i < base::size(kReportDirectories); ++i) {
if (!CreateOrEnsureDirectoryExists(base_dir_.Append(kReportDirectories[i])))
return false;
}
diff --git a/client/simulate_crash_mac.cc b/client/simulate_crash_mac.cc
index 1f7eca9..43d05b8 100644
--- a/client/simulate_crash_mac.cc
+++ b/client/simulate_crash_mac.cc
@@ -20,13 +20,13 @@
#include "base/logging.h"
#include "base/mac/mach_logging.h"
#include "base/mac/scoped_mach_port.h"
+#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "build/build_config.h"
#include "util/mach/exc_client_variants.h"
#include "util/mach/exception_behaviors.h"
#include "util/mach/exception_ports.h"
#include "util/mach/mach_extensions.h"
-#include "util/misc/arraysize.h"
#include "util/misc/implicit_cast.h"
namespace crashpad {
@@ -191,7 +191,7 @@
base::mac::ScopedMachSendRight thread(mach_thread_self());
exception_type_t exception = kMachExceptionSimulated;
mach_exception_data_type_t codes[] = {0, 0};
- mach_msg_type_number_t code_count = ArraySize(codes);
+ mach_msg_type_number_t code_count = base::size(codes);
// Look up the handler for EXC_CRASH exceptions in the same way that the
// kernel would: try a thread handler, then a task handler, and finally a host
@@ -213,7 +213,7 @@
bool success = false;
for (size_t target_type_index = 0;
- !success && target_type_index < ArraySize(kTargetTypes);
+ !success && target_type_index < base::size(kTargetTypes);
++target_type_index) {
ExceptionPorts::ExceptionHandlerVector handlers;
ExceptionPorts exception_ports(kTargetTypes[target_type_index],
diff --git a/client/simulate_crash_mac_test.cc b/client/simulate_crash_mac_test.cc
index 910971a..c2f4c20 100644
--- a/client/simulate_crash_mac_test.cc
+++ b/client/simulate_crash_mac_test.cc
@@ -19,6 +19,7 @@
#include <sys/types.h>
#include "base/macros.h"
+#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "build/build_config.h"
#include "gtest/gtest.h"
@@ -31,7 +32,6 @@
#include "util/mach/mach_message.h"
#include "util/mach/mach_message_server.h"
#include "util/mach/symbolic_constants_mach.h"
-#include "util/misc/arraysize.h"
#include "util/misc/implicit_cast.h"
namespace crashpad {
@@ -343,13 +343,13 @@
#endif
};
- for (size_t target_index = 0; target_index < ArraySize(kTargets);
+ for (size_t target_index = 0; target_index < base::size(kTargets);
++target_index) {
TestSimulateCrashMac::ExceptionPortsTarget target = kTargets[target_index];
SCOPED_TRACE(base::StringPrintf(
"target_index %zu, target %d", target_index, target));
- for (size_t behavior_index = 0; behavior_index < ArraySize(kBehaviors);
+ for (size_t behavior_index = 0; behavior_index < base::size(kBehaviors);
++behavior_index) {
exception_behavior_t behavior = kBehaviors[behavior_index];
SCOPED_TRACE(base::StringPrintf(
@@ -363,7 +363,7 @@
target, behavior, THREAD_STATE_NONE);
test_simulate_crash_mac.Run();
} else {
- for (size_t flavor_index = 0; flavor_index < ArraySize(kFlavors);
+ for (size_t flavor_index = 0; flavor_index < base::size(kFlavors);
++flavor_index) {
thread_state_flavor_t flavor = kFlavors[flavor_index];
SCOPED_TRACE(base::StringPrintf(
diff --git a/handler/mac/file_limit_annotation.cc b/handler/mac/file_limit_annotation.cc
index 5646bde..a01e87d 100644
--- a/handler/mac/file_limit_annotation.cc
+++ b/handler/mac/file_limit_annotation.cc
@@ -24,10 +24,10 @@
#include <string>
#include "base/format_macros.h"
+#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "client/crashpad_info.h"
#include "client/simple_string_dictionary.h"
-#include "util/misc/arraysize.h"
#include "util/posix/scoped_dir.h"
namespace crashpad {
@@ -108,7 +108,7 @@
int mib[] = {CTL_KERN, KERN_MAXFILES};
size = sizeof(value);
std::string max_files = FormatFromSysctl(
- sysctl(mib, ArraySize(mib), &value, &size, nullptr, 0), &value, &size);
+ sysctl(mib, base::size(mib), &value, &size, nullptr, 0), &value, &size);
std::string open_files = CountOpenFileDescriptors();
diff --git a/handler/win/crashy_test_program.cc b/handler/win/crashy_test_program.cc
index d6b4dea..990929b 100644
--- a/handler/win/crashy_test_program.cc
+++ b/handler/win/crashy_test_program.cc
@@ -26,10 +26,10 @@
#include "base/files/file_path.h"
#include "base/logging.h"
+#include "base/stl_util.h"
#include "build/build_config.h"
#include "client/crashpad_client.h"
#include "client/crashpad_info.h"
-#include "util/misc/arraysize.h"
#include "util/win/critical_section_with_debug_info.h"
#include "util/win/get_function.h"
@@ -83,11 +83,11 @@
// All of these allocations are leaked, we want to view them in windbg via
// !vprot.
void* reserve = VirtualAlloc(
- nullptr, ArraySize(kPageTypes) * kPageSize, MEM_RESERVE, PAGE_READWRITE);
+ nullptr, base::size(kPageTypes) * kPageSize, MEM_RESERVE, PAGE_READWRITE);
PCHECK(reserve) << "VirtualAlloc MEM_RESERVE";
uintptr_t reserve_as_int = reinterpret_cast<uintptr_t>(reserve);
- for (size_t i = 0; i < ArraySize(kPageTypes); ++i) {
+ for (size_t i = 0; i < base::size(kPageTypes); ++i) {
void* result =
VirtualAlloc(reinterpret_cast<void*>(reserve_as_int + (kPageSize * i)),
kPageSize,
diff --git a/handler/win/hanging_program.cc b/handler/win/hanging_program.cc
index 49d5cea..f4e5b98 100644
--- a/handler/win/hanging_program.cc
+++ b/handler/win/hanging_program.cc
@@ -17,11 +17,11 @@
#include "base/debug/alias.h"
#include "base/logging.h"
+#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "client/crashpad_client.h"
#include "client/crashpad_info.h"
-#include "util/misc/arraysize.h"
namespace {
@@ -124,7 +124,7 @@
// This is not expected to return.
DWORD count = WaitForMultipleObjects(
- static_cast<DWORD>(ArraySize(threads)), threads, true, INFINITE);
+ static_cast<DWORD>(base::size(threads)), threads, true, INFINITE);
if (count == WAIT_FAILED) {
PLOG(ERROR) << "WaitForMultipleObjects";
} else {
diff --git a/minidump/minidump_annotation_writer_test.cc b/minidump/minidump_annotation_writer_test.cc
index f86ff46..dc05cc6 100644
--- a/minidump/minidump_annotation_writer_test.cc
+++ b/minidump/minidump_annotation_writer_test.cc
@@ -16,13 +16,13 @@
#include <memory>
+#include "base/stl_util.h"
#include "gtest/gtest.h"
#include "minidump/minidump_extensions.h"
#include "minidump/test/minidump_byte_array_writer_test_util.h"
#include "minidump/test/minidump_string_writer_test_util.h"
#include "minidump/test/minidump_writable_test_util.h"
#include "util/file/string_file.h"
-#include "util/misc/arraysize.h"
namespace crashpad {
namespace test {
@@ -107,7 +107,7 @@
MinidumpAnnotationListWriter list_writer;
- for (size_t i = 0; i < ArraySize(kNames); ++i) {
+ for (size_t i = 0; i < base::size(kNames); ++i) {
auto annotation = std::make_unique<MinidumpAnnotationWriter>();
annotation->InitializeWithData(kNames[i], kTypes[i], kValues[i]);
list_writer.AddObject(std::move(annotation));
diff --git a/minidump/minidump_byte_array_writer_test.cc b/minidump/minidump_byte_array_writer_test.cc
index 94fad5c..e4cd526 100644
--- a/minidump/minidump_byte_array_writer_test.cc
+++ b/minidump/minidump_byte_array_writer_test.cc
@@ -17,11 +17,11 @@
#include <memory>
#include "base/format_macros.h"
+#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "gtest/gtest.h"
#include "minidump/test/minidump_writable_test_util.h"
#include "util/file/string_file.h"
-#include "util/misc/arraysize.h"
namespace crashpad {
namespace test {
@@ -35,7 +35,7 @@
{},
};
- for (size_t i = 0; i < ArraySize(kTests); ++i) {
+ for (size_t i = 0; i < base::size(kTests); ++i) {
SCOPED_TRACE(base::StringPrintf("index %" PRIuS, i));
StringFile string_file;
@@ -67,7 +67,7 @@
{},
};
- for (size_t i = 0; i < ArraySize(kTests); ++i) {
+ for (size_t i = 0; i < base::size(kTests); ++i) {
SCOPED_TRACE(base::StringPrintf("index %" PRIuS, i));
crashpad::MinidumpByteArrayWriter writer;
diff --git a/minidump/minidump_exception_writer_test.cc b/minidump/minidump_exception_writer_test.cc
index b3a4e80..75adbee 100644
--- a/minidump/minidump_exception_writer_test.cc
+++ b/minidump/minidump_exception_writer_test.cc
@@ -17,6 +17,7 @@
#include <string>
#include <utility>
+#include "base/stl_util.h"
#include "gtest/gtest.h"
#include "minidump/minidump_context.h"
#include "minidump/minidump_context_writer.h"
@@ -29,7 +30,6 @@
#include "snapshot/test/test_exception_snapshot.h"
#include "test/gtest_death.h"
#include "util/file/string_file.h"
-#include "util/misc/arraysize.h"
namespace crashpad {
namespace test {
@@ -81,7 +81,7 @@
expected->ExceptionRecord.NumberParameters);
EXPECT_EQ(observed->ExceptionRecord.__unusedAlignment, 0u);
for (size_t index = 0;
- index < ArraySize(observed->ExceptionRecord.ExceptionInformation);
+ index < base::size(observed->ExceptionRecord.ExceptionInformation);
++index) {
EXPECT_EQ(observed->ExceptionRecord.ExceptionInformation[index],
expected->ExceptionRecord.ExceptionInformation[index]);
diff --git a/minidump/minidump_file_writer_test.cc b/minidump/minidump_file_writer_test.cc
index ef4813e..8483229 100644
--- a/minidump/minidump_file_writer_test.cc
+++ b/minidump/minidump_file_writer_test.cc
@@ -20,6 +20,7 @@
#include <string>
#include <utility>
+#include "base/stl_util.h"
#include "build/build_config.h"
#include "gtest/gtest.h"
#include "minidump/minidump_stream_writer.h"
@@ -36,7 +37,6 @@
#include "snapshot/test/test_thread_snapshot.h"
#include "test/gtest_death.h"
#include "util/file/string_file.h"
-#include "util/misc/arraysize.h"
namespace crashpad {
namespace test {
@@ -135,7 +135,7 @@
minidump_file.SetTimestamp(kTimestamp);
static constexpr uint8_t kStreamData[] = "Hello World!";
- constexpr size_t kStreamSize = ArraySize(kStreamData);
+ constexpr size_t kStreamSize = base::size(kStreamData);
constexpr MinidumpStreamType kStreamType =
static_cast<MinidumpStreamType>(0x4d);
diff --git a/minidump/minidump_memory_writer_test.cc b/minidump/minidump_memory_writer_test.cc
index fa71caf..90287cb 100644
--- a/minidump/minidump_memory_writer_test.cc
+++ b/minidump/minidump_memory_writer_test.cc
@@ -17,6 +17,7 @@
#include <utility>
#include "base/format_macros.h"
+#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "gtest/gtest.h"
#include "minidump/minidump_extensions.h"
@@ -26,7 +27,6 @@
#include "minidump/test/minidump_writable_test_util.h"
#include "snapshot/test/test_memory_snapshot.h"
#include "util/file/string_file.h"
-#include "util/misc/arraysize.h"
namespace crashpad {
namespace test {
@@ -341,7 +341,7 @@
TEST(MinidumpMemoryWriter, AddFromSnapshot) {
MINIDUMP_MEMORY_DESCRIPTOR expect_memory_descriptors[3] = {};
- uint8_t values[ArraySize(expect_memory_descriptors)] = {};
+ uint8_t values[base::size(expect_memory_descriptors)] = {};
expect_memory_descriptors[0].StartOfMemoryRange = 0;
expect_memory_descriptors[0].Memory.DataSize = 0x1000;
@@ -357,7 +357,7 @@
std::vector<std::unique_ptr<TestMemorySnapshot>> memory_snapshots_owner;
std::vector<const MemorySnapshot*> memory_snapshots;
- for (size_t index = 0; index < ArraySize(expect_memory_descriptors);
+ for (size_t index = 0; index < base::size(expect_memory_descriptors);
++index) {
memory_snapshots_owner.push_back(std::make_unique<TestMemorySnapshot>());
TestMemorySnapshot* memory_snapshot = memory_snapshots_owner.back().get();
@@ -396,7 +396,7 @@
TEST(MinidumpMemoryWriter, CoalesceExplicitMultiple) {
MINIDUMP_MEMORY_DESCRIPTOR expect_memory_descriptors[4] = {};
- uint8_t values[ArraySize(expect_memory_descriptors)] = {};
+ uint8_t values[base::size(expect_memory_descriptors)] = {};
expect_memory_descriptors[0].StartOfMemoryRange = 0;
expect_memory_descriptors[0].Memory.DataSize = 1000;
diff --git a/minidump/minidump_misc_info_writer.cc b/minidump/minidump_misc_info_writer.cc
index 2d70d00..a134076 100644
--- a/minidump/minidump_misc_info_writer.cc
+++ b/minidump/minidump_misc_info_writer.cc
@@ -18,6 +18,7 @@
#include "base/logging.h"
#include "base/numerics/safe_conversions.h"
+#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
@@ -26,7 +27,6 @@
#include "snapshot/process_snapshot.h"
#include "snapshot/system_snapshot.h"
#include "util/file/file_writer.h"
-#include "util/misc/arraysize.h"
#include "util/numeric/in_range_cast.h"
#include "util/numeric/safe_assignment.h"
@@ -302,7 +302,7 @@
internal::MinidumpWriterUtil::AssignUTF8ToUTF16(
misc_info_.TimeZone.StandardName,
- ArraySize(misc_info_.TimeZone.StandardName),
+ base::size(misc_info_.TimeZone.StandardName),
standard_name);
misc_info_.TimeZone.StandardDate = standard_date;
@@ -310,7 +310,7 @@
internal::MinidumpWriterUtil::AssignUTF8ToUTF16(
misc_info_.TimeZone.DaylightName,
- ArraySize(misc_info_.TimeZone.DaylightName),
+ base::size(misc_info_.TimeZone.DaylightName),
daylight_name);
misc_info_.TimeZone.DaylightDate = daylight_date;
@@ -327,10 +327,10 @@
misc_info_.Flags1 |= MINIDUMP_MISC4_BUILDSTRING;
internal::MinidumpWriterUtil::AssignUTF8ToUTF16(
- misc_info_.BuildString, ArraySize(misc_info_.BuildString), build_string);
+ misc_info_.BuildString, base::size(misc_info_.BuildString), build_string);
internal::MinidumpWriterUtil::AssignUTF8ToUTF16(
misc_info_.DbgBldStr,
- ArraySize(misc_info_.DbgBldStr),
+ base::size(misc_info_.DbgBldStr),
debug_build_string);
}
diff --git a/minidump/minidump_misc_info_writer_test.cc b/minidump/minidump_misc_info_writer_test.cc
index e134ccd..bd92733 100644
--- a/minidump/minidump_misc_info_writer_test.cc
+++ b/minidump/minidump_misc_info_writer_test.cc
@@ -21,6 +21,7 @@
#include "base/compiler_specific.h"
#include "base/format_macros.h"
+#include "base/stl_util.h"
#include "base/strings/string16.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
@@ -31,7 +32,6 @@
#include "snapshot/test/test_process_snapshot.h"
#include "snapshot/test/test_system_snapshot.h"
#include "util/file/string_file.h"
-#include "util/misc/arraysize.h"
#include "util/stdlib/strlcpy.h"
namespace crashpad {
@@ -127,7 +127,7 @@
SCOPED_TRACE("Standard");
ExpectNULPaddedString16Equal(expected->TimeZone.StandardName,
observed->TimeZone.StandardName,
- ArraySize(expected->TimeZone.StandardName));
+ base::size(expected->TimeZone.StandardName));
ExpectSystemTimeEqual(&expected->TimeZone.StandardDate,
&observed->TimeZone.StandardDate);
EXPECT_EQ(observed->TimeZone.StandardBias, expected->TimeZone.StandardBias);
@@ -136,7 +136,7 @@
SCOPED_TRACE("Daylight");
ExpectNULPaddedString16Equal(expected->TimeZone.DaylightName,
observed->TimeZone.DaylightName,
- ArraySize(expected->TimeZone.DaylightName));
+ base::size(expected->TimeZone.DaylightName));
ExpectSystemTimeEqual(&expected->TimeZone.DaylightDate,
&observed->TimeZone.DaylightDate);
EXPECT_EQ(observed->TimeZone.DaylightBias, expected->TimeZone.DaylightBias);
@@ -154,13 +154,13 @@
SCOPED_TRACE("BuildString");
ExpectNULPaddedString16Equal(expected->BuildString,
observed->BuildString,
- ArraySize(expected->BuildString));
+ base::size(expected->BuildString));
}
{
SCOPED_TRACE("DbgBldStr");
ExpectNULPaddedString16Equal(expected->DbgBldStr,
observed->DbgBldStr,
- ArraySize(expected->DbgBldStr));
+ base::size(expected->DbgBldStr));
}
}
@@ -176,7 +176,7 @@
EXPECT_EQ(observed->XStateData.EnabledFeatures,
expected->XStateData.EnabledFeatures);
for (size_t feature_index = 0;
- feature_index < ArraySize(observed->XStateData.Features);
+ feature_index < base::size(observed->XStateData.Features);
++feature_index) {
SCOPED_TRACE(base::StringPrintf("feature_index %" PRIuS, feature_index));
EXPECT_EQ(observed->XStateData.Features[feature_index].Offset,
@@ -396,7 +396,7 @@
base::string16 standard_name_utf16 = base::UTF8ToUTF16(kStandardName);
c16lcpy(expected.TimeZone.StandardName,
standard_name_utf16.c_str(),
- ArraySize(expected.TimeZone.StandardName));
+ base::size(expected.TimeZone.StandardName));
memcpy(&expected.TimeZone.StandardDate,
&kStandardDate,
sizeof(expected.TimeZone.StandardDate));
@@ -404,7 +404,7 @@
base::string16 daylight_name_utf16 = base::UTF8ToUTF16(kDaylightName);
c16lcpy(expected.TimeZone.DaylightName,
daylight_name_utf16.c_str(),
- ArraySize(expected.TimeZone.DaylightName));
+ base::size(expected.TimeZone.DaylightName));
memcpy(&expected.TimeZone.DaylightDate,
&kDaylightDate,
sizeof(expected.TimeZone.DaylightDate));
@@ -424,9 +424,9 @@
constexpr int32_t kBias = 300;
MINIDUMP_MISC_INFO_N tmp;
ALLOW_UNUSED_LOCAL(tmp);
- std::string standard_name(ArraySize(tmp.TimeZone.StandardName) + 1, 's');
+ std::string standard_name(base::size(tmp.TimeZone.StandardName) + 1, 's');
constexpr int32_t kStandardBias = 0;
- std::string daylight_name(ArraySize(tmp.TimeZone.DaylightName), 'd');
+ std::string daylight_name(base::size(tmp.TimeZone.DaylightName), 'd');
constexpr int32_t kDaylightBias = -60;
// Test using kSystemTimeZero, because not all platforms will be able to
@@ -457,7 +457,7 @@
base::string16 standard_name_utf16 = base::UTF8ToUTF16(standard_name);
c16lcpy(expected.TimeZone.StandardName,
standard_name_utf16.c_str(),
- ArraySize(expected.TimeZone.StandardName));
+ base::size(expected.TimeZone.StandardName));
memcpy(&expected.TimeZone.StandardDate,
&kSystemTimeZero,
sizeof(expected.TimeZone.StandardDate));
@@ -465,7 +465,7 @@
base::string16 daylight_name_utf16 = base::UTF8ToUTF16(daylight_name);
c16lcpy(expected.TimeZone.DaylightName,
daylight_name_utf16.c_str(),
- ArraySize(expected.TimeZone.DaylightName));
+ base::size(expected.TimeZone.DaylightName));
memcpy(&expected.TimeZone.DaylightDate,
&kSystemTimeZero,
sizeof(expected.TimeZone.DaylightDate));
@@ -496,12 +496,12 @@
base::string16 build_string_utf16 = base::UTF8ToUTF16(kBuildString);
c16lcpy(expected.BuildString,
build_string_utf16.c_str(),
- ArraySize(expected.BuildString));
+ base::size(expected.BuildString));
base::string16 debug_build_string_utf16 =
base::UTF8ToUTF16(kDebugBuildString);
c16lcpy(expected.DbgBldStr,
debug_build_string_utf16.c_str(),
- ArraySize(expected.DbgBldStr));
+ base::size(expected.DbgBldStr));
ExpectMiscInfoEqual(&expected, observed);
}
@@ -515,8 +515,8 @@
MINIDUMP_MISC_INFO_N tmp;
ALLOW_UNUSED_LOCAL(tmp);
- std::string build_string(ArraySize(tmp.BuildString) + 1, 'B');
- std::string debug_build_string(ArraySize(tmp.DbgBldStr), 'D');
+ std::string build_string(base::size(tmp.BuildString) + 1, 'B');
+ std::string debug_build_string(base::size(tmp.DbgBldStr), 'D');
misc_info_writer->SetBuildString(build_string, debug_build_string);
@@ -533,12 +533,12 @@
base::string16 build_string_utf16 = base::UTF8ToUTF16(build_string);
c16lcpy(expected.BuildString,
build_string_utf16.c_str(),
- ArraySize(expected.BuildString));
+ base::size(expected.BuildString));
base::string16 debug_build_string_utf16 =
base::UTF8ToUTF16(debug_build_string);
c16lcpy(expected.DbgBldStr,
debug_build_string_utf16.c_str(),
- ArraySize(expected.DbgBldStr));
+ base::size(expected.DbgBldStr));
ExpectMiscInfoEqual(&expected, observed);
}
@@ -678,7 +678,7 @@
base::string16 standard_name_utf16 = base::UTF8ToUTF16(kStandardName);
c16lcpy(expected.TimeZone.StandardName,
standard_name_utf16.c_str(),
- ArraySize(expected.TimeZone.StandardName));
+ base::size(expected.TimeZone.StandardName));
memcpy(&expected.TimeZone.StandardDate,
&kSystemTimeZero,
sizeof(expected.TimeZone.StandardDate));
@@ -686,7 +686,7 @@
base::string16 daylight_name_utf16 = base::UTF8ToUTF16(kDaylightName);
c16lcpy(expected.TimeZone.DaylightName,
daylight_name_utf16.c_str(),
- ArraySize(expected.TimeZone.DaylightName));
+ base::size(expected.TimeZone.DaylightName));
memcpy(&expected.TimeZone.DaylightDate,
&kSystemTimeZero,
sizeof(expected.TimeZone.DaylightDate));
@@ -694,12 +694,12 @@
base::string16 build_string_utf16 = base::UTF8ToUTF16(kBuildString);
c16lcpy(expected.BuildString,
build_string_utf16.c_str(),
- ArraySize(expected.BuildString));
+ base::size(expected.BuildString));
base::string16 debug_build_string_utf16 =
base::UTF8ToUTF16(kDebugBuildString);
c16lcpy(expected.DbgBldStr,
debug_build_string_utf16.c_str(),
- ArraySize(expected.DbgBldStr));
+ base::size(expected.DbgBldStr));
ExpectMiscInfoEqual(&expected, observed);
}
@@ -743,18 +743,18 @@
expect_misc_info.TimeZone.Bias = 300;
c16lcpy(expect_misc_info.TimeZone.StandardName,
standard_time_name_utf16.c_str(),
- ArraySize(expect_misc_info.TimeZone.StandardName));
+ base::size(expect_misc_info.TimeZone.StandardName));
expect_misc_info.TimeZone.StandardBias = 0;
c16lcpy(expect_misc_info.TimeZone.DaylightName,
daylight_time_name_utf16.c_str(),
- ArraySize(expect_misc_info.TimeZone.DaylightName));
+ base::size(expect_misc_info.TimeZone.DaylightName));
expect_misc_info.TimeZone.DaylightBias = -60;
c16lcpy(expect_misc_info.BuildString,
build_string_utf16.c_str(),
- ArraySize(expect_misc_info.BuildString));
+ base::size(expect_misc_info.BuildString));
c16lcpy(expect_misc_info.DbgBldStr,
debug_build_string_utf16.c_str(),
- ArraySize(expect_misc_info.DbgBldStr));
+ base::size(expect_misc_info.DbgBldStr));
const timeval kStartTime =
{ static_cast<time_t>(expect_misc_info.ProcessCreateTime), 0 };
diff --git a/minidump/minidump_module_crashpad_info_writer_test.cc b/minidump/minidump_module_crashpad_info_writer_test.cc
index 83401ec..ba4ab05 100644
--- a/minidump/minidump_module_crashpad_info_writer_test.cc
+++ b/minidump/minidump_module_crashpad_info_writer_test.cc
@@ -19,6 +19,7 @@
#include <utility>
+#include "base/stl_util.h"
#include "gtest/gtest.h"
#include "minidump/minidump_annotation_writer.h"
#include "minidump/minidump_simple_string_dictionary_writer.h"
@@ -28,7 +29,6 @@
#include "minidump/test/minidump_writable_test_util.h"
#include "snapshot/test/test_module_snapshot.h"
#include "util/file/string_file.h"
-#include "util/misc/arraysize.h"
namespace crashpad {
namespace test {
@@ -155,9 +155,9 @@
sizeof(MinidumpSimpleStringDictionaryEntry) +
sizeof(MinidumpAnnotationList) + 2 + // padding
sizeof(MinidumpAnnotation) + sizeof(MinidumpUTF8String) +
- ArraySize(kEntry) + 2 + // padding
- sizeof(MinidumpUTF8String) + ArraySize(kKey) +
- sizeof(MinidumpUTF8String) + ArraySize(kValue) +
+ base::size(kEntry) + 2 + // padding
+ sizeof(MinidumpUTF8String) + base::size(kKey) +
+ sizeof(MinidumpUTF8String) + base::size(kValue) +
sizeof(MinidumpUTF8String) + annotation.name.size() + 1 +
sizeof(MinidumpByteArray) + annotation.value.size());
diff --git a/minidump/minidump_module_writer_test.cc b/minidump/minidump_module_writer_test.cc
index bef6a8c..8b5fc06 100644
--- a/minidump/minidump_module_writer_test.cc
+++ b/minidump/minidump_module_writer_test.cc
@@ -20,6 +20,7 @@
#include <utility>
#include "base/format_macros.h"
+#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "gtest/gtest.h"
@@ -30,7 +31,6 @@
#include "snapshot/test/test_module_snapshot.h"
#include "test/gtest_death.h"
#include "util/file/string_file.h"
-#include "util/misc/arraysize.h"
#include "util/misc/implicit_cast.h"
#include "util/misc/uuid.h"
@@ -651,10 +651,10 @@
TEST(MinidumpModuleWriter, InitializeFromSnapshot) {
MINIDUMP_MODULE expect_modules[3] = {};
- const char* module_paths[ArraySize(expect_modules)] = {};
- const char* module_pdbs[ArraySize(expect_modules)] = {};
- UUID uuids[ArraySize(expect_modules)] = {};
- uint32_t ages[ArraySize(expect_modules)] = {};
+ const char* module_paths[base::size(expect_modules)] = {};
+ const char* module_pdbs[base::size(expect_modules)] = {};
+ UUID uuids[base::size(expect_modules)] = {};
+ uint32_t ages[base::size(expect_modules)] = {};
expect_modules[0].BaseOfImage = 0x100101000;
expect_modules[0].SizeOfImage = 0xf000;
@@ -706,7 +706,7 @@
std::vector<std::unique_ptr<TestModuleSnapshot>> module_snapshots_owner;
std::vector<const ModuleSnapshot*> module_snapshots;
- for (size_t index = 0; index < ArraySize(expect_modules); ++index) {
+ for (size_t index = 0; index < base::size(expect_modules); ++index) {
module_snapshots_owner.push_back(std::make_unique<TestModuleSnapshot>());
TestModuleSnapshot* module_snapshot = module_snapshots_owner.back().get();
InitializeTestModuleSnapshotFromMinidumpModule(module_snapshot,
diff --git a/minidump/minidump_rva_list_writer_test.cc b/minidump/minidump_rva_list_writer_test.cc
index bd376a9..3807432 100644
--- a/minidump/minidump_rva_list_writer_test.cc
+++ b/minidump/minidump_rva_list_writer_test.cc
@@ -17,12 +17,12 @@
#include <utility>
#include "base/format_macros.h"
+#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "gtest/gtest.h"
#include "minidump/test/minidump_rva_list_test_util.h"
#include "minidump/test/minidump_writable_test_util.h"
#include "util/file/string_file.h"
-#include "util/misc/arraysize.h"
namespace crashpad {
namespace test {
@@ -87,10 +87,10 @@
ASSERT_TRUE(list_writer.WriteEverything(&string_file));
const MinidumpRVAList* list =
- MinidumpRVAListAtStart(string_file.string(), ArraySize(kValues));
+ MinidumpRVAListAtStart(string_file.string(), base::size(kValues));
ASSERT_TRUE(list);
- for (size_t index = 0; index < ArraySize(kValues); ++index) {
+ for (size_t index = 0; index < base::size(kValues); ++index) {
SCOPED_TRACE(base::StringPrintf("index %" PRIuS, index));
const uint32_t* child = MinidumpWritableAtRVA<uint32_t>(
diff --git a/minidump/minidump_string_writer_test.cc b/minidump/minidump_string_writer_test.cc
index aa73503..ddb8c48 100644
--- a/minidump/minidump_string_writer_test.cc
+++ b/minidump/minidump_string_writer_test.cc
@@ -18,6 +18,7 @@
#include "base/compiler_specific.h"
#include "base/format_macros.h"
+#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "gtest/gtest.h"
@@ -25,7 +26,6 @@
#include "minidump/test/minidump_string_writer_test_util.h"
#include "minidump/test/minidump_writable_test_util.h"
#include "util/file/string_file.h"
-#include "util/misc/arraysize.h"
namespace crashpad {
namespace test {
@@ -67,15 +67,16 @@
{4, "\360\220\204\202", 2, {0xd800, 0xdd02}}, // 𐄂 (non-BMP)
};
- for (size_t index = 0; index < ArraySize(kTestData); ++index) {
+ for (size_t index = 0; index < base::size(kTestData); ++index) {
SCOPED_TRACE(base::StringPrintf(
"index %" PRIuS ", input %s", index, kTestData[index].input_string));
// Make sure that the expected output string with its NUL terminator fits in
// the space provided.
- ASSERT_EQ(kTestData[index]
- .output_string[ArraySize(kTestData[index].output_string) - 1],
- 0);
+ ASSERT_EQ(
+ kTestData[index]
+ .output_string[base::size(kTestData[index].output_string) - 1],
+ 0);
string_file.Reset();
crashpad::internal::MinidumpUTF16StringWriter string_writer;
@@ -119,7 +120,7 @@
"\303\0\251", // NUL in middle of valid sequence
};
- for (size_t index = 0; index < ArraySize(kTestData); ++index) {
+ for (size_t index = 0; index < base::size(kTestData); ++index) {
SCOPED_TRACE(base::StringPrintf(
"index %" PRIuS ", input %s", index, kTestData[index]));
string_file.Reset();
@@ -182,7 +183,7 @@
{4, "\360\220\204\202"}, // 𐄂 (non-BMP)
};
- for (size_t index = 0; index < ArraySize(kTestData); ++index) {
+ for (size_t index = 0; index < base::size(kTestData); ++index) {
SCOPED_TRACE(base::StringPrintf(
"index %" PRIuS ", input %s", index, kTestData[index].string));
diff --git a/minidump/minidump_system_info_writer.cc b/minidump/minidump_system_info_writer.cc
index df0e348..9bc013d 100644
--- a/minidump/minidump_system_info_writer.cc
+++ b/minidump/minidump_system_info_writer.cc
@@ -17,6 +17,7 @@
#include <string.h>
#include "base/logging.h"
+#include "base/stl_util.h"
#include "minidump/minidump_string_writer.h"
#include "snapshot/system_snapshot.h"
#include "util/file/file_writer.h"
@@ -230,7 +231,7 @@
sizeof(registers) == sizeof(system_info_.Cpu.X86CpuInfo.VendorId),
"VendorId sizes must be equal");
- for (size_t index = 0; index < ArraySize(registers); ++index) {
+ for (size_t index = 0; index < base::size(registers); ++index) {
memcpy(®isters[index],
&vendor[index * sizeof(*registers)],
sizeof(*registers));
diff --git a/minidump/minidump_thread_id_map_test.cc b/minidump/minidump_thread_id_map_test.cc
index d64d810..548729e 100644
--- a/minidump/minidump_thread_id_map_test.cc
+++ b/minidump/minidump_thread_id_map_test.cc
@@ -19,9 +19,9 @@
#include <vector>
#include "base/macros.h"
+#include "base/stl_util.h"
#include "gtest/gtest.h"
#include "snapshot/test/test_thread_snapshot.h"
-#include "util/misc/arraysize.h"
namespace crashpad {
namespace test {
@@ -39,7 +39,8 @@
// testing::Test:
void SetUp() override {
- for (size_t index = 0; index < ArraySize(test_thread_snapshots_); ++index) {
+ for (size_t index = 0; index < base::size(test_thread_snapshots_);
+ ++index) {
thread_snapshots_.push_back(&test_thread_snapshots_[index]);
}
}
@@ -60,7 +61,7 @@
}
void SetThreadID(size_t index, uint64_t thread_id) {
- ASSERT_LT(index, ArraySize(test_thread_snapshots_));
+ ASSERT_LT(index, base::size(test_thread_snapshots_));
test_thread_snapshots_[index].SetThreadID(thread_id);
}
diff --git a/minidump/minidump_thread_writer_test.cc b/minidump/minidump_thread_writer_test.cc
index 63269ce..956d100 100644
--- a/minidump/minidump_thread_writer_test.cc
+++ b/minidump/minidump_thread_writer_test.cc
@@ -19,6 +19,7 @@
#include "base/compiler_specific.h"
#include "base/format_macros.h"
+#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "gtest/gtest.h"
#include "minidump/minidump_context_writer.h"
@@ -33,7 +34,6 @@
#include "snapshot/test/test_thread_snapshot.h"
#include "test/gtest_death.h"
#include "util/file/string_file.h"
-#include "util/misc/arraysize.h"
namespace crashpad {
namespace test {
@@ -523,10 +523,10 @@
void RunInitializeFromSnapshotTest(bool thread_id_collision) {
using MinidumpContextType = typename Traits::MinidumpContextType;
MINIDUMP_THREAD expect_threads[3] = {};
- uint64_t thread_ids[ArraySize(expect_threads)] = {};
- uint8_t memory_values[ArraySize(expect_threads)] = {};
- uint32_t context_seeds[ArraySize(expect_threads)] = {};
- MINIDUMP_MEMORY_DESCRIPTOR tebs[ArraySize(expect_threads)] = {};
+ uint64_t thread_ids[base::size(expect_threads)] = {};
+ uint8_t memory_values[base::size(expect_threads)] = {};
+ uint32_t context_seeds[base::size(expect_threads)] = {};
+ MINIDUMP_MEMORY_DESCRIPTOR tebs[base::size(expect_threads)] = {};
constexpr size_t kTebSize = 1024;
@@ -582,7 +582,7 @@
std::vector<std::unique_ptr<TestThreadSnapshot>> thread_snapshots_owner;
std::vector<const ThreadSnapshot*> thread_snapshots;
- for (size_t index = 0; index < ArraySize(expect_threads); ++index) {
+ for (size_t index = 0; index < base::size(expect_threads); ++index) {
thread_snapshots_owner.push_back(std::make_unique<TestThreadSnapshot>());
TestThreadSnapshot* thread_snapshot = thread_snapshots_owner.back().get();
diff --git a/minidump/minidump_writable.cc b/minidump/minidump_writable.cc
index c8075c6..fa3e2f1 100644
--- a/minidump/minidump_writable.cc
+++ b/minidump/minidump_writable.cc
@@ -17,8 +17,8 @@
#include <stdint.h>
#include "base/logging.h"
+#include "base/stl_util.h"
#include "util/file/file_writer.h"
-#include "util/misc/arraysize.h"
#include "util/numeric/safe_assignment.h"
namespace {
@@ -245,7 +245,7 @@
// The number of elements in kZeroes must be at least one less than the
// maximum Alignment() ever encountered.
static constexpr uint8_t kZeroes[kMaximumAlignment - 1] = {};
- DCHECK_LE(leading_pad_bytes_, ArraySize(kZeroes));
+ DCHECK_LE(leading_pad_bytes_, base::size(kZeroes));
if (leading_pad_bytes_) {
if (!file_writer->Write(&kZeroes, leading_pad_bytes_)) {
diff --git a/minidump/test/minidump_context_test_util.cc b/minidump/test/minidump_context_test_util.cc
index ae80d00..c94fa20 100644
--- a/minidump/test/minidump_context_test_util.cc
+++ b/minidump/test/minidump_context_test_util.cc
@@ -18,12 +18,12 @@
#include <sys/types.h>
#include "base/format_macros.h"
+#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "gtest/gtest.h"
#include "snapshot/cpu_context.h"
#include "snapshot/test/test_cpu_context.h"
#include "test/hex_string.h"
-#include "util/misc/arraysize.h"
namespace crashpad {
namespace test {
@@ -128,7 +128,8 @@
context->ds = static_cast<uint16_t>(value++);
context->es = static_cast<uint16_t>(value++);
context->ss = static_cast<uint16_t>(value++);
- for (size_t index = 0; index < ArraySize(context->vector_register); ++index) {
+ for (size_t index = 0; index < base::size(context->vector_register);
+ ++index) {
context->vector_register[index].lo = value++;
context->vector_register[index].hi = value++;
}
@@ -151,7 +152,7 @@
uint32_t value = seed;
- for (size_t index = 0; index < ArraySize(context->regs); ++index) {
+ for (size_t index = 0; index < base::size(context->regs); ++index) {
context->regs[index] = value++;
}
context->fp = value++;
@@ -162,7 +163,7 @@
context->pc = value++;
context->cpsr = value++;
- for (size_t index = 0; index < ArraySize(context->vfp); ++index) {
+ for (size_t index = 0; index < base::size(context->vfp); ++index) {
context->vfp[index] = value++;
}
context->fpscr = value++;
@@ -180,7 +181,7 @@
uint32_t value = seed;
- for (size_t index = 0; index < ArraySize(context->regs); ++index) {
+ for (size_t index = 0; index < base::size(context->regs); ++index) {
context->regs[index] = value++;
}
context->fp = value++;
@@ -189,7 +190,7 @@
context->pc = value++;
context->cpsr = value++;
- for (size_t index = 0; index < ArraySize(context->fpsimd); ++index) {
+ for (size_t index = 0; index < base::size(context->fpsimd); ++index) {
context->fpsimd[index].lo = value++;
context->fpsimd[index].hi = value++;
}
@@ -209,7 +210,7 @@
uint32_t value = seed;
- for (size_t index = 0; index < ArraySize(context->regs); ++index) {
+ for (size_t index = 0; index < base::size(context->regs); ++index) {
context->regs[index] = value++;
}
@@ -220,7 +221,7 @@
context->status = value++;
context->cause = value++;
- for (size_t index = 0; index < ArraySize(context->fpregs.fregs); ++index) {
+ for (size_t index = 0; index < base::size(context->fpregs.fregs); ++index) {
context->fpregs.fregs[index]._fp_fregs = static_cast<float>(value++);
}
@@ -247,7 +248,7 @@
uint64_t value = seed;
- for (size_t index = 0; index < ArraySize(context->regs); ++index) {
+ for (size_t index = 0; index < base::size(context->regs); ++index) {
context->regs[index] = value++;
}
@@ -258,7 +259,7 @@
context->status = value++;
context->cause = value++;
- for (size_t index = 0; index < ArraySize(context->fpregs.dregs); ++index) {
+ for (size_t index = 0; index < base::size(context->fpregs.dregs); ++index) {
context->fpregs.dregs[index] = static_cast<double>(value++);
}
context->fpcsr = value++;
@@ -293,33 +294,33 @@
EXPECT_EQ(observed->reserved_3, expected->reserved_3);
EXPECT_EQ(observed->mxcsr, expected->mxcsr);
EXPECT_EQ(observed->mxcsr_mask, expected->mxcsr_mask);
- for (size_t st_mm_index = 0; st_mm_index < ArraySize(expected->st_mm);
+ for (size_t st_mm_index = 0; st_mm_index < base::size(expected->st_mm);
++st_mm_index) {
SCOPED_TRACE(base::StringPrintf("st_mm_index %" PRIuS, st_mm_index));
EXPECT_EQ(BytesToHexString(observed->st_mm[st_mm_index].st,
- ArraySize(observed->st_mm[st_mm_index].st)),
+ base::size(observed->st_mm[st_mm_index].st)),
BytesToHexString(expected->st_mm[st_mm_index].st,
- ArraySize(expected->st_mm[st_mm_index].st)));
+ base::size(expected->st_mm[st_mm_index].st)));
EXPECT_EQ(
BytesToHexString(observed->st_mm[st_mm_index].st_reserved,
- ArraySize(observed->st_mm[st_mm_index].st_reserved)),
+ base::size(observed->st_mm[st_mm_index].st_reserved)),
BytesToHexString(expected->st_mm[st_mm_index].st_reserved,
- ArraySize(expected->st_mm[st_mm_index].st_reserved)));
+ base::size(expected->st_mm[st_mm_index].st_reserved)));
}
- for (size_t xmm_index = 0; xmm_index < ArraySize(expected->xmm);
+ for (size_t xmm_index = 0; xmm_index < base::size(expected->xmm);
++xmm_index) {
EXPECT_EQ(BytesToHexString(observed->xmm[xmm_index],
- ArraySize(observed->xmm[xmm_index])),
+ base::size(observed->xmm[xmm_index])),
BytesToHexString(expected->xmm[xmm_index],
- ArraySize(expected->xmm[xmm_index])))
+ base::size(expected->xmm[xmm_index])))
<< "xmm_index " << xmm_index;
}
EXPECT_EQ(
- BytesToHexString(observed->reserved_4, ArraySize(observed->reserved_4)),
- BytesToHexString(expected->reserved_4, ArraySize(expected->reserved_4)));
+ BytesToHexString(observed->reserved_4, base::size(observed->reserved_4)),
+ BytesToHexString(expected->reserved_4, base::size(expected->reserved_4)));
EXPECT_EQ(
- BytesToHexString(observed->available, ArraySize(observed->available)),
- BytesToHexString(expected->available, ArraySize(expected->available)));
+ BytesToHexString(observed->available, base::size(observed->available)),
+ BytesToHexString(expected->available, base::size(expected->available)));
}
} // namespace
@@ -344,11 +345,11 @@
EXPECT_EQ(observed->fsave.fpu_cs, expected.fsave.fpu_cs);
EXPECT_EQ(observed->fsave.fpu_dp, expected.fsave.fpu_dp);
EXPECT_EQ(observed->fsave.fpu_ds, expected.fsave.fpu_ds);
- for (size_t index = 0; index < ArraySize(expected.fsave.st); ++index) {
+ for (size_t index = 0; index < base::size(expected.fsave.st); ++index) {
EXPECT_EQ(BytesToHexString(observed->fsave.st[index],
- ArraySize(observed->fsave.st[index])),
+ base::size(observed->fsave.st[index])),
BytesToHexString(expected.fsave.st[index],
- ArraySize(expected.fsave.st[index])))
+ base::size(expected.fsave.st[index])))
<< "index " << index;
}
if (snapshot) {
@@ -447,7 +448,8 @@
ExpectMinidumpContextFxsave(&expected.fxsave, &observed->fxsave);
- for (size_t index = 0; index < ArraySize(expected.vector_register); ++index) {
+ for (size_t index = 0; index < base::size(expected.vector_register);
+ ++index) {
if (snapshot) {
EXPECT_EQ(observed->vector_register[index].lo, 0u) << "index " << index;
EXPECT_EQ(observed->vector_register[index].hi, 0u) << "index " << index;
@@ -487,7 +489,7 @@
EXPECT_EQ(observed->context_flags, expected.context_flags);
- for (size_t index = 0; index < ArraySize(expected.regs); ++index) {
+ for (size_t index = 0; index < base::size(expected.regs); ++index) {
EXPECT_EQ(observed->regs[index], expected.regs[index]);
}
EXPECT_EQ(observed->fp, expected.fp);
@@ -498,10 +500,10 @@
EXPECT_EQ(observed->cpsr, expected.cpsr);
EXPECT_EQ(observed->fpscr, expected.fpscr);
- for (size_t index = 0; index < ArraySize(expected.vfp); ++index) {
+ for (size_t index = 0; index < base::size(expected.vfp); ++index) {
EXPECT_EQ(observed->vfp[index], expected.vfp[index]);
}
- for (size_t index = 0; index < ArraySize(expected.extra); ++index) {
+ for (size_t index = 0; index < base::size(expected.extra); ++index) {
EXPECT_EQ(observed->extra[index], snapshot ? 0 : expected.extra[index]);
}
}
@@ -514,14 +516,14 @@
EXPECT_EQ(observed->context_flags, expected.context_flags);
- for (size_t index = 0; index < ArraySize(expected.regs); ++index) {
+ for (size_t index = 0; index < base::size(expected.regs); ++index) {
EXPECT_EQ(observed->regs[index], expected.regs[index]);
}
EXPECT_EQ(observed->cpsr, expected.cpsr);
EXPECT_EQ(observed->fpsr, expected.fpsr);
EXPECT_EQ(observed->fpcr, expected.fpcr);
- for (size_t index = 0; index < ArraySize(expected.fpsimd); ++index) {
+ for (size_t index = 0; index < base::size(expected.fpsimd); ++index) {
EXPECT_EQ(observed->fpsimd[index].lo, expected.fpsimd[index].lo);
EXPECT_EQ(observed->fpsimd[index].hi, expected.fpsimd[index].hi);
}
@@ -535,7 +537,7 @@
EXPECT_EQ(observed->context_flags, expected.context_flags);
- for (size_t index = 0; index < ArraySize(expected.regs); ++index) {
+ for (size_t index = 0; index < base::size(expected.regs); ++index) {
EXPECT_EQ(observed->regs[index], expected.regs[index]);
}
@@ -546,7 +548,7 @@
EXPECT_EQ(observed->status, expected.status);
EXPECT_EQ(observed->cause, expected.cause);
- for (size_t index = 0; index < ArraySize(expected.fpregs.fregs); ++index) {
+ for (size_t index = 0; index < base::size(expected.fpregs.fregs); ++index) {
EXPECT_EQ(observed->fpregs.fregs[index]._fp_fregs,
expected.fpregs.fregs[index]._fp_fregs);
}
@@ -568,7 +570,7 @@
EXPECT_EQ(observed->context_flags, expected.context_flags);
- for (size_t index = 0; index < ArraySize(expected.regs); ++index) {
+ for (size_t index = 0; index < base::size(expected.regs); ++index) {
EXPECT_EQ(observed->regs[index], expected.regs[index]);
}
@@ -579,7 +581,7 @@
EXPECT_EQ(observed->status, expected.status);
EXPECT_EQ(observed->cause, expected.cause);
- for (size_t index = 0; index < ArraySize(expected.fpregs.dregs); ++index) {
+ for (size_t index = 0; index < base::size(expected.fpregs.dregs); ++index) {
EXPECT_EQ(observed->fpregs.dregs[index], expected.fpregs.dregs[index]);
}
EXPECT_EQ(observed->fpcsr, expected.fpcsr);
diff --git a/snapshot/capture_memory.cc b/snapshot/capture_memory.cc
index 3ffbcd2..a51626c 100644
--- a/snapshot/capture_memory.cc
+++ b/snapshot/capture_memory.cc
@@ -19,8 +19,8 @@
#include <limits>
#include <memory>
+#include "base/stl_util.h"
#include "snapshot/memory_snapshot.h"
-#include "util/misc/arraysize.h"
namespace crashpad {
namespace internal {
@@ -98,17 +98,17 @@
#elif defined(ARCH_CPU_ARM_FAMILY)
if (context.architecture == kCPUArchitectureARM64) {
MaybeCaptureMemoryAround(delegate, context.arm64->pc);
- for (size_t i = 0; i < ArraySize(context.arm64->regs); ++i) {
+ for (size_t i = 0; i < base::size(context.arm64->regs); ++i) {
MaybeCaptureMemoryAround(delegate, context.arm64->regs[i]);
}
} else {
MaybeCaptureMemoryAround(delegate, context.arm->pc);
- for (size_t i = 0; i < ArraySize(context.arm->regs); ++i) {
+ for (size_t i = 0; i < base::size(context.arm->regs); ++i) {
MaybeCaptureMemoryAround(delegate, context.arm->regs[i]);
}
}
#elif defined(ARCH_CPU_MIPS_FAMILY)
- for (size_t i = 0; i < ArraySize(context.mipsel->regs); ++i) {
+ for (size_t i = 0; i < base::size(context.mipsel->regs); ++i) {
MaybeCaptureMemoryAround(delegate, context.mipsel->regs[i]);
}
#else
diff --git a/snapshot/cpu_context.cc b/snapshot/cpu_context.cc
index 0ed1691..6fb8d7e 100644
--- a/snapshot/cpu_context.cc
+++ b/snapshot/cpu_context.cc
@@ -18,6 +18,7 @@
#include <string.h>
#include "base/logging.h"
+#include "base/stl_util.h"
#include "util/misc/arraysize.h"
#include "util/misc/implicit_cast.h"
@@ -57,7 +58,7 @@
fsave->reserved_4 = 0;
static_assert(ArraySize(fsave->st) == ArraySize(fxsave.st_mm),
"FPU stack registers must be equivalent");
- for (size_t index = 0; index < ArraySize(fsave->st); ++index) {
+ for (size_t index = 0; index < base::size(fsave->st); ++index) {
memcpy(fsave->st[index], fxsave.st_mm[index].st, sizeof(fsave->st[index]));
}
}
@@ -79,7 +80,7 @@
fxsave->mxcsr_mask = 0;
static_assert(ArraySize(fxsave->st_mm) == ArraySize(fsave.st),
"FPU stack registers must be equivalent");
- for (size_t index = 0; index < ArraySize(fsave.st); ++index) {
+ for (size_t index = 0; index < base::size(fsave.st); ++index) {
memcpy(fxsave->st_mm[index].st, fsave.st[index], sizeof(fsave.st[index]));
memset(fxsave->st_mm[index].st_reserved,
0,
diff --git a/snapshot/cpu_context_test.cc b/snapshot/cpu_context_test.cc
index 794d9b9..109510d 100644
--- a/snapshot/cpu_context_test.cc
+++ b/snapshot/cpu_context_test.cc
@@ -18,9 +18,9 @@
#include <string.h>
#include <sys/types.h>
+#include "base/stl_util.h"
#include "gtest/gtest.h"
#include "test/hex_string.h"
-#include "util/misc/arraysize.h"
namespace crashpad {
namespace test {
@@ -124,7 +124,7 @@
&fxsave.st_mm[6].st, kExponentAllZero, false, kFractionAllZero);
SetX87Register(
&fxsave.st_mm[7].st, kExponentNormal, true, kFractionNormal); // valid
- for (size_t index = 0; index < ArraySize(fxsave.st_mm); ++index) {
+ for (size_t index = 0; index < base::size(fxsave.st_mm); ++index) {
memset(&fxsave.st_mm[index].st_reserved,
0x5a,
sizeof(fxsave.st_mm[index].st_reserved));
@@ -148,10 +148,10 @@
EXPECT_EQ(fsave.fpu_dp, fxsave.fpu_dp);
EXPECT_EQ(fsave.fpu_ds, fxsave.fpu_ds);
EXPECT_EQ(fsave.reserved_4, 0);
- for (size_t index = 0; index < ArraySize(fsave.st); ++index) {
- EXPECT_EQ(BytesToHexString(fsave.st[index], ArraySize(fsave.st[index])),
+ for (size_t index = 0; index < base::size(fsave.st); ++index) {
+ EXPECT_EQ(BytesToHexString(fsave.st[index], base::size(fsave.st[index])),
BytesToHexString(fxsave.st_mm[index].st,
- ArraySize(fxsave.st_mm[index].st)))
+ base::size(fxsave.st_mm[index].st)))
<< "index " << index;
}
}
@@ -204,14 +204,14 @@
EXPECT_EQ(fxsave.reserved_3, 0);
EXPECT_EQ(fxsave.mxcsr, 0u);
EXPECT_EQ(fxsave.mxcsr_mask, 0u);
- for (size_t index = 0; index < ArraySize(fxsave.st_mm); ++index) {
+ for (size_t index = 0; index < base::size(fxsave.st_mm); ++index) {
EXPECT_EQ(BytesToHexString(fxsave.st_mm[index].st,
- ArraySize(fxsave.st_mm[index].st)),
- BytesToHexString(fsave.st[index], ArraySize(fsave.st[index])))
+ base::size(fxsave.st_mm[index].st)),
+ BytesToHexString(fsave.st[index], base::size(fsave.st[index])))
<< "index " << index;
EXPECT_EQ(BytesToHexString(fxsave.st_mm[index].st_reserved,
- ArraySize(fxsave.st_mm[index].st_reserved)),
- std::string(ArraySize(fxsave.st_mm[index].st_reserved) * 2, '0'))
+ base::size(fxsave.st_mm[index].st_reserved)),
+ std::string(base::size(fxsave.st_mm[index].st_reserved) * 2, '0'))
<< "index " << index;
}
size_t unused_len = sizeof(fxsave) - offsetof(decltype(fxsave), xmm);
@@ -318,7 +318,7 @@
// In this set, everything is valid.
fsw = 0 << 11; // top = 0: logical 0-7 maps to physical 0-7
fxsave_tag = 0xff; // nothing empty
- for (size_t index = 0; index < ArraySize(st_mm); ++index) {
+ for (size_t index = 0; index < base::size(st_mm); ++index) {
SetX87OrMMXRegister(&st_mm[index], kExponentNormal, true, kFractionAllZero);
}
EXPECT_EQ(CPUContextX86::FxsaveToFsaveTagWord(fsw, fxsave_tag, st_mm), 0);
diff --git a/snapshot/fuchsia/memory_map_region_snapshot_fuchsia.cc b/snapshot/fuchsia/memory_map_region_snapshot_fuchsia.cc
index 45d39d2..1133c4d 100644
--- a/snapshot/fuchsia/memory_map_region_snapshot_fuchsia.cc
+++ b/snapshot/fuchsia/memory_map_region_snapshot_fuchsia.cc
@@ -15,7 +15,7 @@
#include "snapshot/fuchsia/memory_map_region_snapshot_fuchsia.h"
#include "base/logging.h"
-#include "util/misc/arraysize.h"
+#include "base/stl_util.h"
namespace crashpad {
namespace internal {
@@ -50,7 +50,7 @@
const uint32_t index =
flags & (ZX_VM_PERM_READ | ZX_VM_PERM_WRITE | ZX_VM_PERM_EXECUTE);
- DCHECK_LT(index, ArraySize(mapping));
+ DCHECK_LT(index, base::size(mapping));
const uint32_t protect_flags = mapping[index];
DCHECK_NE(protect_flags, 0u);
diff --git a/snapshot/fuchsia/process_reader_fuchsia_test.cc b/snapshot/fuchsia/process_reader_fuchsia_test.cc
index 5832a22..83385a8 100644
--- a/snapshot/fuchsia/process_reader_fuchsia_test.cc
+++ b/snapshot/fuchsia/process_reader_fuchsia_test.cc
@@ -20,11 +20,11 @@
#include <zircon/syscalls/port.h>
#include <zircon/types.h>
+#include "base/stl_util.h"
#include "gtest/gtest.h"
#include "test/multiprocess_exec.h"
#include "test/test_paths.h"
#include "util/fuchsia/scoped_task_suspend.h"
-#include "util/misc/arraysize.h"
namespace crashpad {
namespace test {
@@ -35,7 +35,7 @@
ASSERT_TRUE(process_reader.Initialize(*zx::process::self()));
static constexpr char kTestMemory[] = "Some test memory";
- char buffer[ArraySize(kTestMemory)];
+ char buffer[base::size(kTestMemory)];
ASSERT_TRUE(process_reader.Memory()->Read(
reinterpret_cast<zx_vaddr_t>(kTestMemory), sizeof(kTestMemory), &buffer));
EXPECT_STREQ(kTestMemory, buffer);
diff --git a/snapshot/fuchsia/process_snapshot_fuchsia_test.cc b/snapshot/fuchsia/process_snapshot_fuchsia_test.cc
index ebb612b..a96d37c 100644
--- a/snapshot/fuchsia/process_snapshot_fuchsia_test.cc
+++ b/snapshot/fuchsia/process_snapshot_fuchsia_test.cc
@@ -19,12 +19,12 @@
#include "base/fuchsia/fuchsia_logging.h"
#include "base/logging.h"
+#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "gtest/gtest.h"
#include "snapshot/fuchsia/process_snapshot_fuchsia.h"
#include "test/multiprocess_exec.h"
#include "util/fuchsia/scoped_task_suspend.h"
-#include "util/misc/arraysize.h"
namespace crashpad {
namespace test {
@@ -104,8 +104,8 @@
private:
void MultiprocessParent() override {
- uintptr_t test_addresses[ArraySize(kTestMappingPermAndSizes)];
- for (size_t i = 0; i < ArraySize(test_addresses); ++i) {
+ uintptr_t test_addresses[base::size(kTestMappingPermAndSizes)];
+ for (size_t i = 0; i < base::size(test_addresses); ++i) {
ASSERT_TRUE(ReadFileExactly(
ReadPipeHandle(), &test_addresses[i], sizeof(test_addresses[i])));
}
@@ -115,7 +115,7 @@
ProcessSnapshotFuchsia process_snapshot;
ASSERT_TRUE(process_snapshot.Initialize(*ChildProcess()));
- for (size_t i = 0; i < ArraySize(test_addresses); ++i) {
+ for (size_t i = 0; i < base::size(test_addresses); ++i) {
const auto& t = kTestMappingPermAndSizes[i];
EXPECT_TRUE(HasSingleMatchingMapping(process_snapshot.MemoryMap(),
test_addresses[i],
diff --git a/snapshot/linux/exception_snapshot_linux_test.cc b/snapshot/linux/exception_snapshot_linux_test.cc
index e632bc1..e4ff1ab 100644
--- a/snapshot/linux/exception_snapshot_linux_test.cc
+++ b/snapshot/linux/exception_snapshot_linux_test.cc
@@ -23,6 +23,7 @@
#include "base/bit_cast.h"
#include "base/macros.h"
+#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "gtest/gtest.h"
#include "snapshot/cpu_architecture.h"
@@ -32,7 +33,6 @@
#include "test/errors.h"
#include "test/linux/fake_ptrace_connection.h"
#include "util/linux/address_types.h"
-#include "util/misc/arraysize.h"
#include "util/misc/clock.h"
#include "util/misc/from_pointer_cast.h"
#include "util/posix/signals.h"
@@ -171,7 +171,7 @@
test_context->vfp.head.magic = VFP_MAGIC;
test_context->vfp.head.size = sizeof(test_context->vfp);
memset(&test_context->vfp.context, 'v', sizeof(test_context->vfp.context));
- for (size_t reg = 0; reg < ArraySize(test_context->vfp.context.vfp.fpregs);
+ for (size_t reg = 0; reg < base::size(test_context->vfp.context.vfp.fpregs);
++reg) {
test_context->vfp.context.vfp.fpregs[reg] = reg;
}
@@ -219,7 +219,7 @@
void InitializeContext(NativeCPUContext* context) {
memset(context, 'x', sizeof(*context));
- for (size_t index = 0; index < ArraySize(context->uc_mcontext.regs);
+ for (size_t index = 0; index < base::size(context->uc_mcontext.regs);
++index) {
context->uc_mcontext.regs[index] = index;
}
@@ -238,7 +238,7 @@
test_context->fpsimd.head.size = sizeof(test_context->fpsimd);
test_context->fpsimd.fpsr = 1;
test_context->fpsimd.fpcr = 2;
- for (size_t reg = 0; reg < ArraySize(test_context->fpsimd.vregs); ++reg) {
+ for (size_t reg = 0; reg < base::size(test_context->fpsimd.vregs); ++reg) {
test_context->fpsimd.vregs[reg] = reg;
}
@@ -271,7 +271,7 @@
using NativeCPUContext = ucontext_t;
void InitializeContext(NativeCPUContext* context) {
- for (size_t reg = 0; reg < ArraySize(context->uc_mcontext.gregs); ++reg) {
+ for (size_t reg = 0; reg < base::size(context->uc_mcontext.gregs); ++reg) {
context->uc_mcontext.gregs[reg] = reg;
}
memset(&context->uc_mcontext.fpregs, 44, sizeof(context->uc_mcontext.fpregs));
@@ -286,7 +286,7 @@
#define CPU_ARCH_NAME mips64
#endif
- for (size_t reg = 0; reg < ArraySize(expected.uc_mcontext.gregs); ++reg) {
+ for (size_t reg = 0; reg < base::size(expected.uc_mcontext.gregs); ++reg) {
EXPECT_EQ(actual.CPU_ARCH_NAME->regs[reg], expected.uc_mcontext.gregs[reg]);
}
diff --git a/snapshot/linux/process_reader_linux_test.cc b/snapshot/linux/process_reader_linux_test.cc
index 61b84f3..e2e5566 100644
--- a/snapshot/linux/process_reader_linux_test.cc
+++ b/snapshot/linux/process_reader_linux_test.cc
@@ -33,6 +33,7 @@
#include "base/format_macros.h"
#include "base/memory/free_deleter.h"
+#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "build/build_config.h"
#include "gtest/gtest.h"
@@ -47,7 +48,6 @@
#include "util/file/filesystem.h"
#include "util/linux/direct_ptrace_connection.h"
#include "util/misc/address_sanitizer.h"
-#include "util/misc/arraysize.h"
#include "util/misc/from_pointer_cast.h"
#include "util/synchronization/semaphore.h"
@@ -80,7 +80,7 @@
EXPECT_EQ(process_reader.ParentProcessID(), getppid());
static constexpr char kTestMemory[] = "Some test memory";
- char buffer[ArraySize(kTestMemory)];
+ char buffer[base::size(kTestMemory)];
ASSERT_TRUE(process_reader.Memory()->Read(
reinterpret_cast<LinuxVMAddress>(kTestMemory),
sizeof(kTestMemory),
diff --git a/snapshot/mac/mach_o_image_reader.cc b/snapshot/mac/mach_o_image_reader.cc
index 650b0c7..bd258ca 100644
--- a/snapshot/mac/mach_o_image_reader.cc
+++ b/snapshot/mac/mach_o_image_reader.cc
@@ -22,13 +22,13 @@
#include <utility>
#include "base/logging.h"
+#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "client/crashpad_info.h"
#include "snapshot/mac/mach_o_image_segment_reader.h"
#include "snapshot/mac/mach_o_image_symbol_table_reader.h"
#include "snapshot/mac/process_reader_mac.h"
#include "util/mac/checked_mach_address_range.h"
-#include "util/misc/arraysize.h"
#include "util/misc/implicit_cast.h"
namespace {
@@ -183,7 +183,7 @@
// This vector is parallel to the kLoadCommandReaders array, and tracks
// whether a singleton load command matching the |command| field has been
// found yet.
- std::vector<uint32_t> singleton_indices(ArraySize(kLoadCommandReaders),
+ std::vector<uint32_t> singleton_indices(base::size(kLoadCommandReaders),
kInvalidSegmentIndex);
size_t offset = mach_header.Size();
@@ -236,7 +236,8 @@
return false;
}
- for (size_t reader_index = 0; reader_index < ArraySize(kLoadCommandReaders);
+ for (size_t reader_index = 0;
+ reader_index < base::size(kLoadCommandReaders);
++reader_index) {
if (load_command.cmd != kLoadCommandReaders[reader_index].command) {
continue;
diff --git a/snapshot/mac/mach_o_image_segment_reader_test.cc b/snapshot/mac/mach_o_image_segment_reader_test.cc
index cfbddc1..4731a5f 100644
--- a/snapshot/mac/mach_o_image_segment_reader_test.cc
+++ b/snapshot/mac/mach_o_image_segment_reader_test.cc
@@ -16,9 +16,9 @@
#include <mach-o/loader.h>
+#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "gtest/gtest.h"
-#include "util/misc/arraysize.h"
namespace crashpad {
namespace test {
@@ -63,7 +63,7 @@
SEG_IMPORT,
};
- for (size_t index = 0; index < ArraySize(kSegmentTestData); ++index) {
+ for (size_t index = 0; index < base::size(kSegmentTestData); ++index) {
EXPECT_EQ(
MachOImageSegmentReader::SegmentNameString(kSegmentTestData[index]),
kSegmentTestData[index])
@@ -106,7 +106,7 @@
SECT_ICON_TIFF,
};
- for (size_t index = 0; index < ArraySize(kSectionTestData); ++index) {
+ for (size_t index = 0; index < base::size(kSectionTestData); ++index) {
EXPECT_EQ(
MachOImageSegmentReader::SectionNameString(kSectionTestData[index]),
kSectionTestData[index])
@@ -169,7 +169,7 @@
{SEG_IMPORT, "", "__IMPORT,"},
};
- for (size_t index = 0; index < ArraySize(kSegmentAndSectionTestData);
+ for (size_t index = 0; index < base::size(kSegmentAndSectionTestData);
++index) {
const auto& test = kSegmentAndSectionTestData[index];
EXPECT_EQ(MachOImageSegmentReader::SegmentAndSectionNameString(
diff --git a/snapshot/mac/process_reader_mac_test.cc b/snapshot/mac/process_reader_mac_test.cc
index e3f4df1..9325b2c 100644
--- a/snapshot/mac/process_reader_mac_test.cc
+++ b/snapshot/mac/process_reader_mac_test.cc
@@ -29,6 +29,7 @@
#include "base/logging.h"
#include "base/mac/mach_logging.h"
#include "base/posix/eintr_wrapper.h"
+#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "build/build_config.h"
#include "gtest/gtest.h"
@@ -41,7 +42,6 @@
#include "util/file/file_io.h"
#include "util/mac/mac_util.h"
#include "util/mach/mach_extensions.h"
-#include "util/misc/arraysize.h"
#include "util/misc/from_pointer_cast.h"
#include "util/synchronization/semaphore.h"
@@ -65,7 +65,7 @@
EXPECT_EQ(process_reader.ParentProcessID(), getppid());
static constexpr char kTestMemory[] = "Some test memory";
- char buffer[ArraySize(kTestMemory)];
+ char buffer[base::size(kTestMemory)];
ASSERT_TRUE(process_reader.Memory()->Read(
FromPointerCast<mach_vm_address_t>(kTestMemory),
sizeof(kTestMemory),
@@ -613,11 +613,11 @@
const size_t source_lengths[] = {
strlen(sources[0]),
};
- static_assert(ArraySize(sources) == ArraySize(source_lengths),
+ static_assert(base::size(sources) == base::size(source_lengths),
"arrays must be parallel");
program_ = clCreateProgramWithSource(
- context_, ArraySize(sources), sources, source_lengths, &rv);
+ context_, base::size(sources), sources, source_lengths, &rv);
ASSERT_EQ(rv, CL_SUCCESS) << "clCreateProgramWithSource";
rv = clBuildProgram(
diff --git a/snapshot/mac/process_types.cc b/snapshot/mac/process_types.cc
index 9ae8f7c..0a1b7f9 100644
--- a/snapshot/mac/process_types.cc
+++ b/snapshot/mac/process_types.cc
@@ -20,8 +20,8 @@
#include <memory>
+#include "base/stl_util.h"
#include "snapshot/mac/process_types/internal.h"
-#include "util/misc/arraysize.h"
#include "util/process/process_memory_mac.h"
namespace crashpad {
@@ -74,7 +74,7 @@
template <>
inline void Assign<UInt64Array4, UInt32Array4>(UInt64Array4* destination,
const UInt32Array4& source) {
- for (size_t index = 0; index < ArraySize(source); ++index) {
+ for (size_t index = 0; index < base::size(source); ++index) {
(*destination)[index] = source[index];
}
}
diff --git a/snapshot/mac/process_types/custom.cc b/snapshot/mac/process_types/custom.cc
index 3d5976c..3ca5646 100644
--- a/snapshot/mac/process_types/custom.cc
+++ b/snapshot/mac/process_types/custom.cc
@@ -23,9 +23,9 @@
#include "base/logging.h"
#include "base/numerics/safe_math.h"
+#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "snapshot/mac/process_types/internal.h"
-#include "util/misc/arraysize.h"
#include "util/process/process_memory_mac.h"
#if !DOXYGEN
@@ -145,8 +145,8 @@
sizeof(dyld_all_image_infos<Traits>), // 16
};
- if (version >= ArraySize(kSizeForVersion)) {
- return kSizeForVersion[ArraySize(kSizeForVersion) - 1];
+ if (version >= base::size(kSizeForVersion)) {
+ return kSizeForVersion[base::size(kSizeForVersion) - 1];
}
static_assert(std::is_unsigned<decltype(version)>::value,
diff --git a/snapshot/mac/process_types_test.cc b/snapshot/mac/process_types_test.cc
index 9a9dc9d..2ab3034 100644
--- a/snapshot/mac/process_types_test.cc
+++ b/snapshot/mac/process_types_test.cc
@@ -20,13 +20,13 @@
#include <vector>
+#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "build/build_config.h"
#include "gtest/gtest.h"
#include "snapshot/mac/process_types/internal.h"
#include "test/mac/dyld.h"
#include "util/mac/mac_util.h"
-#include "util/misc/arraysize.h"
#include "util/misc/from_pointer_cast.h"
#include "util/misc/implicit_cast.h"
@@ -147,7 +147,7 @@
{15, 164, 304},
{16, 176, 320},
};
- for (size_t index = 0; index < ArraySize(kVersionsAndSizes); ++index) {
+ for (size_t index = 0; index < base::size(kVersionsAndSizes); ++index) {
uint32_t version = kVersionsAndSizes[index].version;
SCOPED_TRACE(base::StringPrintf("index %zu, version %u", index, version));
@@ -268,7 +268,7 @@
self_image_infos->sharedCacheBaseAddress);
EXPECT_EQ(proctype_image_infos.dyldPath,
reinterpret_cast<uint64_t>(self_image_infos->dyldPath));
- for (size_t index = 0; index < ArraySize(self_image_infos->notifyPorts);
+ for (size_t index = 0; index < base::size(self_image_infos->notifyPorts);
++index) {
EXPECT_EQ(proctype_image_infos.notifyPorts[index],
self_image_infos->notifyPorts[index])
@@ -288,7 +288,7 @@
// process_types version. It’s difficult to compare the reserved fields in
// these older SDKs, so only do it where the declarations match.
if (proctype_image_infos.version >= 14) {
- for (size_t index = 0; index < ArraySize(proctype_image_infos.reserved);
+ for (size_t index = 0; index < base::size(proctype_image_infos.reserved);
++index) {
EXPECT_EQ(proctype_image_infos.reserved[index],
implicit_cast<uint64_t>(self_image_infos->reserved[index]))
diff --git a/snapshot/minidump/process_snapshot_minidump_test.cc b/snapshot/minidump/process_snapshot_minidump_test.cc
index 4787603..f4b611d 100644
--- a/snapshot/minidump/process_snapshot_minidump_test.cc
+++ b/snapshot/minidump/process_snapshot_minidump_test.cc
@@ -21,6 +21,7 @@
#include <memory>
#include "base/numerics/safe_math.h"
+#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
#include "gtest/gtest.h"
#include "minidump/minidump_context.h"
@@ -28,7 +29,6 @@
#include "snapshot/minidump/minidump_annotation_reader.h"
#include "snapshot/module_snapshot.h"
#include "util/file/string_file.h"
-#include "util/misc/arraysize.h"
#include "util/misc/pdb_structures.h"
namespace crashpad {
@@ -859,27 +859,27 @@
minidump_context.fxsave.fpu_ip_64 = 42;
minidump_context.fxsave.fpu_dp_64 = 43;
- for (size_t i = 0; i < ArraySize(minidump_context.vector_register); i++) {
+ for (size_t i = 0; i < base::size(minidump_context.vector_register); i++) {
minidump_context.vector_register[i].lo = i * 2 + 44;
minidump_context.vector_register[i].hi = i * 2 + 45;
}
- for (uint8_t i = 0; i < ArraySize(minidump_context.fxsave.reserved_4); i++) {
+ for (uint8_t i = 0; i < base::size(minidump_context.fxsave.reserved_4); i++) {
minidump_context.fxsave.reserved_4[i] = i * 2 + 115;
minidump_context.fxsave.available[i] = i * 2 + 116;
}
- for (size_t i = 0; i < ArraySize(minidump_context.fxsave.st_mm); i++) {
+ for (size_t i = 0; i < base::size(minidump_context.fxsave.st_mm); i++) {
for (uint8_t j = 0;
- j < ArraySize(minidump_context.fxsave.st_mm[0].mm_value);
+ j < base::size(minidump_context.fxsave.st_mm[0].mm_value);
j++) {
minidump_context.fxsave.st_mm[i].mm_value[j] = j + 1;
minidump_context.fxsave.st_mm[i].mm_reserved[j] = j + 1;
}
}
- for (size_t i = 0; i < ArraySize(minidump_context.fxsave.xmm); i++) {
- for (uint8_t j = 0; j < ArraySize(minidump_context.fxsave.xmm[0]); j++) {
+ for (size_t i = 0; i < base::size(minidump_context.fxsave.xmm); i++) {
+ for (uint8_t j = 0; j < base::size(minidump_context.fxsave.xmm[0]); j++) {
minidump_context.fxsave.xmm[i][j] = j + 1;
}
}
@@ -962,20 +962,20 @@
EXPECT_EQ(ctx->fxsave.fpu_ip_64, 42U);
EXPECT_EQ(ctx->fxsave.fpu_dp_64, 43U);
- for (uint8_t i = 0; i < ArraySize(ctx->fxsave.reserved_4); i++) {
+ for (uint8_t i = 0; i < base::size(ctx->fxsave.reserved_4); i++) {
EXPECT_EQ(ctx->fxsave.reserved_4[i], i * 2 + 115);
EXPECT_EQ(ctx->fxsave.available[i], i * 2 + 116);
}
- for (size_t i = 0; i < ArraySize(ctx->fxsave.st_mm); i++) {
- for (uint8_t j = 0; j < ArraySize(ctx->fxsave.st_mm[0].mm_value); j++) {
+ for (size_t i = 0; i < base::size(ctx->fxsave.st_mm); i++) {
+ for (uint8_t j = 0; j < base::size(ctx->fxsave.st_mm[0].mm_value); j++) {
EXPECT_EQ(ctx->fxsave.st_mm[i].mm_value[j], j + 1);
EXPECT_EQ(ctx->fxsave.st_mm[i].mm_reserved[j], j + 1);
}
}
- for (size_t i = 0; i < ArraySize(ctx->fxsave.xmm); i++) {
- for (uint8_t j = 0; j < ArraySize(ctx->fxsave.xmm[0]); j++) {
+ for (size_t i = 0; i < base::size(ctx->fxsave.xmm); i++) {
+ for (uint8_t j = 0; j < base::size(ctx->fxsave.xmm[0]); j++) {
EXPECT_EQ(ctx->fxsave.xmm[i][j], j + 1);
}
}
diff --git a/snapshot/minidump/thread_snapshot_minidump.cc b/snapshot/minidump/thread_snapshot_minidump.cc
index 46ae97a..e77bab8 100644
--- a/snapshot/minidump/thread_snapshot_minidump.cc
+++ b/snapshot/minidump/thread_snapshot_minidump.cc
@@ -17,8 +17,8 @@
#include <stddef.h>
#include <string.h>
+#include "base/stl_util.h"
#include "minidump/minidump_context.h"
-#include "util/misc/arraysize.h"
namespace crashpad {
namespace internal {
@@ -193,7 +193,7 @@
return false;
}
- for (size_t i = 0; i < ArraySize(src->regs); i++) {
+ for (size_t i = 0; i < base::size(src->regs); i++) {
context_.arm->regs[i] = src->regs[i];
}
@@ -205,7 +205,7 @@
context_.arm->cpsr = src->cpsr;
context_.arm->vfp_regs.fpscr = src->fpscr;
- for (size_t i = 0; i < ArraySize(src->vfp); i++) {
+ for (size_t i = 0; i < base::size(src->vfp); i++) {
context_.arm->vfp_regs.vfp[i] = src->vfp[i];
}
@@ -225,14 +225,14 @@
return false;
}
- for (size_t i = 0; i < ArraySize(src->regs); i++) {
+ for (size_t i = 0; i < base::size(src->regs); i++) {
context_.arm64->regs[i] = src->regs[i];
}
context_.arm64->regs[29] = src->fp;
context_.arm64->regs[30] = src->lr;
- for (size_t i = 0; i < ArraySize(src->fpsimd); i++) {
+ for (size_t i = 0; i < base::size(src->fpsimd); i++) {
context_.arm64->fpsimd[i] = src->fpsimd[i];
}
@@ -255,7 +255,7 @@
return false;
}
- for (size_t i = 0; i < ArraySize(src->regs); i++) {
+ for (size_t i = 0; i < base::size(src->regs); i++) {
context_.mipsel->regs[i] = src->regs[i];
}
@@ -263,7 +263,7 @@
context_.mipsel->mdlo = static_cast<uint32_t>(src->mdlo);
context_.mipsel->dsp_control = src->dsp_control;
- for (size_t i = 0; i < ArraySize(src->hi); i++) {
+ for (size_t i = 0; i < base::size(src->hi); i++) {
context_.mipsel->hi[i] = src->hi[i];
context_.mipsel->lo[i] = src->lo[i];
}
@@ -292,7 +292,7 @@
return false;
}
- for (size_t i = 0; i < ArraySize(src->regs); i++) {
+ for (size_t i = 0; i < base::size(src->regs); i++) {
context_.mips64->regs[i] = src->regs[i];
}
@@ -300,7 +300,7 @@
context_.mips64->mdlo = src->mdlo;
context_.mips64->dsp_control = src->dsp_control;
- for (size_t i = 0; i < ArraySize(src->hi); i++) {
+ for (size_t i = 0; i < base::size(src->hi); i++) {
context_.mips64->hi[i] = src->hi[i];
context_.mips64->lo[i] = src->lo[i];
}
diff --git a/snapshot/posix/timezone.cc b/snapshot/posix/timezone.cc
index 8b2b822..9451e11 100644
--- a/snapshot/posix/timezone.cc
+++ b/snapshot/posix/timezone.cc
@@ -18,8 +18,8 @@
#include <time.h>
#include "base/logging.h"
+#include "base/stl_util.h"
#include "build/build_config.h"
-#include "util/misc/arraysize.h"
namespace crashpad {
namespace internal {
@@ -60,7 +60,8 @@
static constexpr int kMonthDeltas[] =
{0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6,
7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12};
- for (size_t index = 0; index < ArraySize(kMonthDeltas) && !found_transition;
+ for (size_t index = 0;
+ index < base::size(kMonthDeltas) && !found_transition;
++index) {
// Look at a day of each month at local noon. Set tm_isdst to -1 to avoid
// giving mktime() any hints about whether to consider daylight saving
diff --git a/snapshot/posix/timezone_test.cc b/snapshot/posix/timezone_test.cc
index 1bb19c4..b4405ba 100644
--- a/snapshot/posix/timezone_test.cc
+++ b/snapshot/posix/timezone_test.cc
@@ -22,10 +22,10 @@
#include "base/logging.h"
#include "base/macros.h"
+#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "gtest/gtest.h"
#include "test/errors.h"
-#include "util/misc/arraysize.h"
namespace crashpad {
namespace test {
@@ -155,7 +155,7 @@
{"UTC", false, 0, 0, "UTC", "UTC"},
};
- for (size_t index = 0; index < ArraySize(kTestTimeZones); ++index) {
+ for (size_t index = 0; index < base::size(kTestTimeZones); ++index) {
const auto& test_time_zone = kTestTimeZones[index];
const char* tz = test_time_zone.tz;
SCOPED_TRACE(base::StringPrintf("index %zu, tz %s", index, tz));
diff --git a/snapshot/sanitized/sanitization_information_test.cc b/snapshot/sanitized/sanitization_information_test.cc
index c7d836a..e426f28 100644
--- a/snapshot/sanitized/sanitization_information_test.cc
+++ b/snapshot/sanitized/sanitization_information_test.cc
@@ -14,9 +14,9 @@
#include "snapshot/sanitized/sanitization_information.h"
+#include "base/stl_util.h"
#include "build/build_config.h"
#include "gtest/gtest.h"
-#include "util/misc/arraysize.h"
#include "util/misc/from_pointer_cast.h"
#include "util/process/process_memory_linux.h"
@@ -60,8 +60,8 @@
TEST_F(WhitelistTest, NonEmptyWhitelist) {
ASSERT_TRUE(ReadWhitelist(kNonEmptyWhitelist));
- ASSERT_EQ(whitelist_.size(), ArraySize(kNonEmptyWhitelist) - 1);
- for (size_t index = 0; index < ArraySize(kNonEmptyWhitelist) - 1; ++index) {
+ ASSERT_EQ(whitelist_.size(), base::size(kNonEmptyWhitelist) - 1);
+ for (size_t index = 0; index < base::size(kNonEmptyWhitelist) - 1; ++index) {
EXPECT_EQ(whitelist_[index], kNonEmptyWhitelist[index]);
}
}
diff --git a/snapshot/test/test_cpu_context.cc b/snapshot/test/test_cpu_context.cc
index 7694d7e..746e340 100644
--- a/snapshot/test/test_cpu_context.cc
+++ b/snapshot/test/test_cpu_context.cc
@@ -17,7 +17,7 @@
#include <string.h>
#include <sys/types.h>
-#include "util/misc/arraysize.h"
+#include "base/stl_util.h"
namespace crashpad {
namespace test {
@@ -44,28 +44,28 @@
fxsave->reserved_3 = static_cast<uint16_t>(value++);
fxsave->mxcsr = value++;
fxsave->mxcsr_mask = value++;
- for (size_t st_mm_index = 0; st_mm_index < ArraySize(fxsave->st_mm);
+ for (size_t st_mm_index = 0; st_mm_index < base::size(fxsave->st_mm);
++st_mm_index) {
- for (size_t byte = 0; byte < ArraySize(fxsave->st_mm[st_mm_index].st);
+ for (size_t byte = 0; byte < base::size(fxsave->st_mm[st_mm_index].st);
++byte) {
fxsave->st_mm[st_mm_index].st[byte] = static_cast<uint8_t>(value++);
}
for (size_t byte = 0;
- byte < ArraySize(fxsave->st_mm[st_mm_index].st_reserved);
+ byte < base::size(fxsave->st_mm[st_mm_index].st_reserved);
++byte) {
fxsave->st_mm[st_mm_index].st_reserved[byte] =
static_cast<uint8_t>(value);
}
}
- for (size_t xmm_index = 0; xmm_index < ArraySize(fxsave->xmm); ++xmm_index) {
- for (size_t byte = 0; byte < ArraySize(fxsave->xmm[xmm_index]); ++byte) {
+ for (size_t xmm_index = 0; xmm_index < base::size(fxsave->xmm); ++xmm_index) {
+ for (size_t byte = 0; byte < base::size(fxsave->xmm[xmm_index]); ++byte) {
fxsave->xmm[xmm_index][byte] = static_cast<uint8_t>(value++);
}
}
- for (size_t byte = 0; byte < ArraySize(fxsave->reserved_4); ++byte) {
+ for (size_t byte = 0; byte < base::size(fxsave->reserved_4); ++byte) {
fxsave->reserved_4[byte] = static_cast<uint8_t>(value++);
}
- for (size_t byte = 0; byte < ArraySize(fxsave->available); ++byte) {
+ for (size_t byte = 0; byte < base::size(fxsave->available); ++byte) {
fxsave->available[byte] = static_cast<uint8_t>(value++);
}
@@ -174,7 +174,7 @@
uint32_t value = seed;
- for (size_t index = 0; index < ArraySize(arm->regs); ++index) {
+ for (size_t index = 0; index < base::size(arm->regs); ++index) {
arm->regs[index] = value++;
}
arm->fp = value++;
@@ -185,7 +185,7 @@
arm->pc = value++;
arm->cpsr = value++;
- for (size_t index = 0; index < ArraySize(arm->vfp_regs.vfp); ++index) {
+ for (size_t index = 0; index < base::size(arm->vfp_regs.vfp); ++index) {
arm->vfp_regs.vfp[index] = value++;
}
arm->vfp_regs.fpscr = value++;
@@ -205,14 +205,14 @@
uint32_t value = seed;
- for (size_t index = 0; index < ArraySize(arm64->regs); ++index) {
+ for (size_t index = 0; index < base::size(arm64->regs); ++index) {
arm64->regs[index] = value++;
}
arm64->sp = value++;
arm64->pc = value++;
arm64->spsr = value++;
- for (size_t index = 0; index < ArraySize(arm64->fpsimd); ++index) {
+ for (size_t index = 0; index < base::size(arm64->fpsimd); ++index) {
arm64->fpsimd[index].lo = value++;
arm64->fpsimd[index].hi = value++;
}
@@ -231,7 +231,7 @@
uint32_t value = seed;
- for (size_t index = 0; index < ArraySize(mipsel->regs); ++index) {
+ for (size_t index = 0; index < base::size(mipsel->regs); ++index) {
mipsel->regs[index] = value++;
}
@@ -242,7 +242,7 @@
mipsel->cp0_status = value++;
mipsel->cp0_cause = value++;
- for (size_t index = 0; index < ArraySize(mipsel->fpregs.fregs); ++index) {
+ for (size_t index = 0; index < base::size(mipsel->fpregs.fregs); ++index) {
mipsel->fpregs.fregs[index]._fp_fregs = static_cast<float>(value++);
}
@@ -267,7 +267,7 @@
uint64_t value = seed;
- for (size_t index = 0; index < ArraySize(mips64->regs); ++index) {
+ for (size_t index = 0; index < base::size(mips64->regs); ++index) {
mips64->regs[index] = value++;
}
@@ -278,7 +278,7 @@
mips64->cp0_status = value++;
mips64->cp0_cause = value++;
- for (size_t index = 0; index < ArraySize(mips64->fpregs.dregs); ++index) {
+ for (size_t index = 0; index < base::size(mips64->fpregs.dregs); ++index) {
mips64->fpregs.dregs[index] = static_cast<double>(value++);
}
diff --git a/snapshot/win/cpu_context_win_test.cc b/snapshot/win/cpu_context_win_test.cc
index 7f66f9d..e63f04e 100644
--- a/snapshot/win/cpu_context_win_test.cc
+++ b/snapshot/win/cpu_context_win_test.cc
@@ -16,11 +16,11 @@
#include <windows.h>
+#include "base/stl_util.h"
#include "build/build_config.h"
#include "gtest/gtest.h"
#include "snapshot/cpu_context.h"
#include "test/hex_string.h"
-#include "util/misc/arraysize.h"
namespace crashpad {
namespace test {
@@ -87,13 +87,13 @@
for (size_t st_mm = 0; st_mm < 7; ++st_mm) {
EXPECT_EQ(
BytesToHexString(cpu_context_x86.fxsave.st_mm[st_mm].st,
- ArraySize(cpu_context_x86.fxsave.st_mm[st_mm].st)),
- std::string(ArraySize(cpu_context_x86.fxsave.st_mm[st_mm].st) * 2,
+ base::size(cpu_context_x86.fxsave.st_mm[st_mm].st)),
+ std::string(base::size(cpu_context_x86.fxsave.st_mm[st_mm].st) * 2,
'0'))
<< "st_mm " << st_mm;
}
EXPECT_EQ(BytesToHexString(cpu_context_x86.fxsave.st_mm[7].st,
- ArraySize(cpu_context_x86.fxsave.st_mm[7].st)),
+ base::size(cpu_context_x86.fxsave.st_mm[7].st)),
"0000000000000080ff7f");
EXPECT_EQ(cpu_context_x86.dr0, 3u);
diff --git a/snapshot/win/crashpad_snapshot_test_image_reader.cc b/snapshot/win/crashpad_snapshot_test_image_reader.cc
index e6a9e5d..8bccbd6 100644
--- a/snapshot/win/crashpad_snapshot_test_image_reader.cc
+++ b/snapshot/win/crashpad_snapshot_test_image_reader.cc
@@ -15,9 +15,9 @@
#include <windows.h>
#include "base/logging.h"
+#include "base/stl_util.h"
#include "client/crashpad_info.h"
#include "util/file/file_io.h"
-#include "util/misc/arraysize.h"
#include "util/synchronization/semaphore.h"
#include "util/win/scoped_handle.h"
@@ -29,7 +29,7 @@
// Allocate a bunch of pointers to things on the stack.
int* pointers[1000];
- for (size_t i = 0; i < ArraySize(pointers); ++i) {
+ for (size_t i = 0; i < base::size(pointers); ++i) {
pointers[i] = new int[2048];
}
@@ -53,7 +53,7 @@
// verify the cap on pointed-to memory.
crashpad::Semaphore semaphore(0);
crashpad::ScopedKernelHANDLE threads[100];
- for (size_t i = 0; i < ArraySize(threads); ++i) {
+ for (size_t i = 0; i < base::size(threads); ++i) {
threads[i].reset(CreateThread(nullptr,
0,
&LotsOfReferencesThreadProc,
@@ -66,7 +66,7 @@
}
}
- for (size_t i = 0; i < ArraySize(threads); ++i) {
+ for (size_t i = 0; i < base::size(threads); ++i) {
semaphore.Wait();
}
diff --git a/snapshot/win/pe_image_annotations_reader.cc b/snapshot/win/pe_image_annotations_reader.cc
index c5e5373..058342d 100644
--- a/snapshot/win/pe_image_annotations_reader.cc
+++ b/snapshot/win/pe_image_annotations_reader.cc
@@ -17,13 +17,13 @@
#include <string.h>
#include <sys/types.h>
+#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
#include "client/annotation.h"
#include "client/simple_string_dictionary.h"
#include "snapshot/snapshot_constants.h"
#include "snapshot/win/pe_image_reader.h"
#include "snapshot/win/process_reader_win.h"
-#include "util/misc/arraysize.h"
#include "util/win/process_structs.h"
namespace crashpad {
@@ -156,7 +156,8 @@
snapshot.type = current.type;
char name[Annotation::kNameMaxLength];
- if (!process_reader_->Memory()->Read(current.name, ArraySize(name), name)) {
+ if (!process_reader_->Memory()->Read(
+ current.name, base::size(name), name)) {
LOG(WARNING) << "could not read annotation name at index " << index
<< " in " << base::UTF16ToUTF8(name_);
continue;
diff --git a/snapshot/win/pe_image_reader.cc b/snapshot/win/pe_image_reader.cc
index b4b1d16..e69faef 100644
--- a/snapshot/win/pe_image_reader.cc
+++ b/snapshot/win/pe_image_reader.cc
@@ -21,10 +21,10 @@
#include <memory>
#include "base/logging.h"
+#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "client/crashpad_info.h"
#include "snapshot/win/pe_image_resource_reader.h"
-#include "util/misc/arraysize.h"
#include "util/misc/from_pointer_cast.h"
#include "util/misc/pdb_structures.h"
#include "util/win/process_structs.h"
@@ -288,7 +288,7 @@
version_info.wType != 0 ||
wcsncmp(version_info.szKey,
L"VS_VERSION_INFO",
- ArraySize(version_info.szKey)) != 0) {
+ base::size(version_info.szKey)) != 0) {
LOG(WARNING) << "unexpected VS_VERSIONINFO in "
<< module_subrange_reader_.name();
return false;
diff --git a/snapshot/win/process_reader_win_test.cc b/snapshot/win/process_reader_win_test.cc
index eca6f48..1880c87 100644
--- a/snapshot/win/process_reader_win_test.cc
+++ b/snapshot/win/process_reader_win_test.cc
@@ -17,9 +17,9 @@
#include <windows.h>
#include <string.h>
+#include "base/stl_util.h"
#include "gtest/gtest.h"
#include "test/win/win_multiprocess.h"
-#include "util/misc/arraysize.h"
#include "util/misc/from_pointer_cast.h"
#include "util/synchronization/semaphore.h"
#include "util/thread/thread.h"
@@ -44,7 +44,7 @@
EXPECT_EQ(process_reader.GetProcessInfo().ProcessID(), GetCurrentProcessId());
static constexpr char kTestMemory[] = "Some test memory";
- char buffer[ArraySize(kTestMemory)];
+ char buffer[base::size(kTestMemory)];
ASSERT_TRUE(process_reader.Memory()->Read(
reinterpret_cast<uintptr_t>(kTestMemory), sizeof(kTestMemory), &buffer));
EXPECT_STREQ(kTestMemory, buffer);
@@ -185,7 +185,7 @@
// the pipe.
CheckedReadFileAtEOF(ReadPipeHandle());
- for (size_t i = 0; i < ArraySize(threads); ++i)
+ for (size_t i = 0; i < base::size(threads); ++i)
done.Signal();
for (auto& thread : threads)
thread.Join();
diff --git a/snapshot/win/process_snapshot_win.cc b/snapshot/win/process_snapshot_win.cc
index 5d98a5f..f91ef29 100644
--- a/snapshot/win/process_snapshot_win.cc
+++ b/snapshot/win/process_snapshot_win.cc
@@ -22,9 +22,9 @@
#include "base/logging.h"
#include "base/numerics/safe_conversions.h"
+#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
-#include "util/misc/arraysize.h"
#include "util/misc/from_pointer_cast.h"
#include "util/misc/time.h"
#include "util/win/nt_internals.h"
@@ -335,7 +335,7 @@
uet.TimeDateStamp,
base::UTF16ToUTF8(base::StringPiece16(
uet.ImageName,
- wcsnlen(uet.ImageName, ArraySize(uet.ImageName))))));
+ wcsnlen(uet.ImageName, base::size(uet.ImageName))))));
}
}
}
@@ -535,9 +535,9 @@
env_block.resize(
static_cast<unsigned int>(bytes_read / sizeof(env_block[0])));
static constexpr wchar_t terminator[] = {0, 0};
- size_t at = env_block.find(std::wstring(terminator, ArraySize(terminator)));
+ size_t at = env_block.find(std::wstring(terminator, base::size(terminator)));
if (at != std::wstring::npos)
- env_block.resize(at + ArraySize(terminator));
+ env_block.resize(at + base::size(terminator));
return env_block.size() * sizeof(env_block[0]);
}
diff --git a/test/hex_string.h b/test/hex_string.h
index 2d7801b..b0d4453 100644
--- a/test/hex_string.h
+++ b/test/hex_string.h
@@ -29,8 +29,8 @@
//! uint8_t expected[10];
//! uint8_t observed[10];
//! // …
-//! EXPECT_EQ(BytesToHexString(observed, ArraySize(observed)),
-//! BytesToHexString(expected, ArraySize(expected)));
+//! EXPECT_EQ(BytesToHexString(observed, base::size(observed)),
+//! BytesToHexString(expected, base::size(expected)));
//! \endcode
std::string BytesToHexString(const void* bytes, size_t length);
diff --git a/test/hex_string_test.cc b/test/hex_string_test.cc
index 3d44cc9..3a09eb7 100644
--- a/test/hex_string_test.cc
+++ b/test/hex_string_test.cc
@@ -14,8 +14,8 @@
#include "test/hex_string.h"
+#include "base/stl_util.h"
#include "gtest/gtest.h"
-#include "util/misc/arraysize.h"
namespace crashpad {
namespace test {
@@ -25,7 +25,7 @@
EXPECT_EQ(BytesToHexString(nullptr, 0), "");
static constexpr char kBytes[] = "Abc123xyz \x0a\x7f\xf0\x9f\x92\xa9_";
- EXPECT_EQ(BytesToHexString(kBytes, ArraySize(kBytes)),
+ EXPECT_EQ(BytesToHexString(kBytes, base::size(kBytes)),
"41626331323378797a200a7ff09f92a95f00");
}
diff --git a/tools/crashpad_database_util.cc b/tools/crashpad_database_util.cc
index d8274c5..17a4771 100644
--- a/tools/crashpad_database_util.cc
+++ b/tools/crashpad_database_util.cc
@@ -29,6 +29,7 @@
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/numerics/safe_conversions.h"
+#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "client/crash_report_database.h"
@@ -36,7 +37,6 @@
#include "tools/tool_support.h"
#include "util/file/file_io.h"
#include "util/file/file_reader.h"
-#include "util/misc/arraysize.h"
#include "util/misc/uuid.h"
#include "util/stdlib/string_number_conversion.h"
@@ -109,14 +109,14 @@
"set",
};
- for (size_t index = 0; index < ArraySize(kFalseWords); ++index) {
+ for (size_t index = 0; index < base::size(kFalseWords); ++index) {
if (strcasecmp(string, kFalseWords[index]) == 0) {
*boolean = false;
return true;
}
}
- for (size_t index = 0; index < ArraySize(kTrueWords); ++index) {
+ for (size_t index = 0; index < base::size(kTrueWords); ++index) {
if (strcasecmp(string, kTrueWords[index]) == 0) {
*boolean = true;
return true;
@@ -159,7 +159,7 @@
"%+",
};
- for (size_t index = 0; index < ArraySize(kFormats); ++index) {
+ for (size_t index = 0; index < base::size(kFormats); ++index) {
tm time_tm;
const char* strptime_result = strptime(string, kFormats[index], &time_tm);
if (strptime_result == end) {
@@ -214,7 +214,7 @@
char string[64];
CHECK_NE(
- strftime(string, ArraySize(string), "%Y-%m-%d %H:%M:%S %Z", &time_tm),
+ strftime(string, base::size(string), "%Y-%m-%d %H:%M:%S %Z", &time_tm),
0u);
return std::string(string);
diff --git a/util/file/delimited_file_reader.cc b/util/file/delimited_file_reader.cc
index 2a8678f..2275ade 100644
--- a/util/file/delimited_file_reader.cc
+++ b/util/file/delimited_file_reader.cc
@@ -21,7 +21,7 @@
#include "base/logging.h"
#include "base/numerics/safe_conversions.h"
-#include "util/misc/arraysize.h"
+#include "base/stl_util.h"
namespace crashpad {
@@ -76,7 +76,7 @@
return Result::kEndOfFile;
}
- DCHECK_LE(static_cast<size_t>(read_result), ArraySize(buf_));
+ DCHECK_LE(static_cast<size_t>(read_result), base::size(buf_));
DCHECK(
base::IsValueInRangeForNumericType<decltype(buf_len_)>(read_result));
buf_len_ = static_cast<decltype(buf_len_)>(read_result);
diff --git a/util/file/delimited_file_reader_test.cc b/util/file/delimited_file_reader_test.cc
index b226f3d..a2fd7d5 100644
--- a/util/file/delimited_file_reader_test.cc
+++ b/util/file/delimited_file_reader_test.cc
@@ -17,10 +17,10 @@
#include <vector>
#include "base/format_macros.h"
+#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "gtest/gtest.h"
#include "util/file/string_file.h"
-#include "util/misc/arraysize.h"
namespace crashpad {
namespace test {
@@ -260,7 +260,7 @@
TEST(DelimitedFileReader, EmbeddedNUL) {
static constexpr char kString[] = "embedded\0NUL\n";
StringFile string_file;
- string_file.SetString(std::string(kString, ArraySize(kString) - 1));
+ string_file.SetString(std::string(kString, base::size(kString) - 1));
DelimitedFileReader delimited_file_reader(&string_file);
std::string line;
@@ -278,7 +278,7 @@
TEST(DelimitedFileReader, NULDelimiter) {
static constexpr char kString[] = "aa\0b\0ccc\0";
StringFile string_file;
- string_file.SetString(std::string(kString, ArraySize(kString) - 1));
+ string_file.SetString(std::string(kString, base::size(kString) - 1));
DelimitedFileReader delimited_file_reader(&string_file);
std::string field;
@@ -302,7 +302,7 @@
TEST(DelimitedFileReader, EdgeCases) {
static constexpr size_t kSizes[] =
{4094, 4095, 4096, 4097, 8190, 8191, 8192, 8193};
- for (size_t index = 0; index < ArraySize(kSizes); ++index) {
+ for (size_t index = 0; index < base::size(kSizes); ++index) {
size_t size = kSizes[index];
SCOPED_TRACE(
base::StringPrintf("index %" PRIuS ", size %" PRIuS, index, size));
diff --git a/util/file/file_io_test.cc b/util/file/file_io_test.cc
index d341a5d..0fdd25c 100644
--- a/util/file/file_io_test.cc
+++ b/util/file/file_io_test.cc
@@ -22,12 +22,12 @@
#include "base/atomicops.h"
#include "base/files/file_path.h"
#include "base/macros.h"
+#include "base/stl_util.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "test/errors.h"
#include "test/file.h"
#include "test/scoped_temp_dir.h"
-#include "util/misc/arraysize.h"
#include "util/misc/implicit_cast.h"
#include "util/thread/thread.h"
@@ -613,7 +613,7 @@
LockingTestThread threads[20];
int expected_iterations = 0;
- for (size_t index = 0; index < ArraySize(threads); ++index) {
+ for (size_t index = 0; index < base::size(threads); ++index) {
int iterations_for_this_thread = static_cast<int>(index * 10);
threads[index].Init(
(other_locks == FileLocking::kShared)
diff --git a/util/linux/direct_ptrace_connection.cc b/util/linux/direct_ptrace_connection.cc
index 371bed2..e757d8f 100644
--- a/util/linux/direct_ptrace_connection.cc
+++ b/util/linux/direct_ptrace_connection.cc
@@ -19,10 +19,10 @@
#include <utility>
#include "base/logging.h"
+#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
#include "util/file/directory_reader.h"
#include "util/file/file_io.h"
-#include "util/misc/arraysize.h"
#include "util/misc/as_underlying_type.h"
namespace crashpad {
@@ -93,7 +93,7 @@
DCHECK(threads->empty());
char path[32];
- snprintf(path, ArraySize(path), "/proc/%d/task", pid_);
+ snprintf(path, base::size(path), "/proc/%d/task", pid_);
DirectoryReader reader;
if (!reader.Open(base::FilePath(path))) {
return false;
diff --git a/util/linux/proc_stat_reader.cc b/util/linux/proc_stat_reader.cc
index 60f1054..88658f5 100644
--- a/util/linux/proc_stat_reader.cc
+++ b/util/linux/proc_stat_reader.cc
@@ -20,8 +20,8 @@
#include "base/files/file_path.h"
#include "base/logging.h"
+#include "base/stl_util.h"
#include "util/file/file_io.h"
-#include "util/misc/arraysize.h"
#include "util/misc/lexing.h"
#include "util/misc/time.h"
@@ -48,7 +48,7 @@
INITIALIZATION_STATE_SET_INITIALIZING(initialized_);
char path[32];
- snprintf(path, ArraySize(path), "/proc/%d/stat", tid);
+ snprintf(path, base::size(path), "/proc/%d/stat", tid);
if (!connection->ReadFileContents(base::FilePath(path), &contents_)) {
return false;
}
diff --git a/util/linux/ptrace_client.cc b/util/linux/ptrace_client.cc
index e8afaa4..d822d10 100644
--- a/util/linux/ptrace_client.cc
+++ b/util/linux/ptrace_client.cc
@@ -20,10 +20,10 @@
#include <string>
#include "base/logging.h"
+#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
#include "util/file/file_io.h"
#include "util/linux/ptrace_broker.h"
-#include "util/misc/arraysize.h"
#include "util/process/process_memory_linux.h"
namespace crashpad {
@@ -271,7 +271,7 @@
threads->push_back(pid_);
char path[32];
- snprintf(path, ArraySize(path), "/proc/%d/task", pid_);
+ snprintf(path, base::size(path), "/proc/%d/task", pid_);
PtraceBroker::Request request;
request.type = PtraceBroker::Request::kTypeListDirectory;
diff --git a/util/mac/checked_mach_address_range_test.cc b/util/mac/checked_mach_address_range_test.cc
index f2f8f54..8531379 100644
--- a/util/mac/checked_mach_address_range_test.cc
+++ b/util/mac/checked_mach_address_range_test.cc
@@ -19,10 +19,10 @@
#include <limits>
+#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "build/build_config.h"
#include "gtest/gtest.h"
-#include "util/misc/arraysize.h"
namespace crashpad {
namespace test {
@@ -116,7 +116,7 @@
{0xffffffffffffffff, 1, kInvalid},
};
- for (size_t index = 0; index < ArraySize(kTestData); ++index) {
+ for (size_t index = 0; index < base::size(kTestData); ++index) {
const auto& testcase = kTestData[index];
SCOPED_TRACE(base::StringPrintf("index %zu, base 0x%llx, size 0x%llx",
index,
@@ -166,7 +166,7 @@
CheckedMachAddressRange parent_range_32(false, 0x2000, 0x1000);
ASSERT_TRUE(parent_range_32.IsValid());
- for (size_t index = 0; index < ArraySize(kTestData); ++index) {
+ for (size_t index = 0; index < base::size(kTestData); ++index) {
const auto& testcase = kTestData[index];
SCOPED_TRACE(
base::StringPrintf("index %zu, value 0x%llx", index, testcase.value));
@@ -223,7 +223,7 @@
CheckedMachAddressRange parent_range_32(false, 0x2000, 0x1000);
ASSERT_TRUE(parent_range_32.IsValid());
- for (size_t index = 0; index < ArraySize(kTestData); ++index) {
+ for (size_t index = 0; index < base::size(kTestData); ++index) {
const auto& testcase = kTestData[index];
SCOPED_TRACE(base::StringPrintf("index %zu, base 0x%llx, size 0x%llx",
index,
diff --git a/util/mac/launchd_test.mm b/util/mac/launchd_test.mm
index 4a6402d..b793a9b 100644
--- a/util/mac/launchd_test.mm
+++ b/util/mac/launchd_test.mm
@@ -23,8 +23,8 @@
#include <limits>
#include "base/mac/scoped_launch_data.h"
+#include "base/stl_util.h"
#include "gtest/gtest.h"
-#include "util/misc/arraysize.h"
#include "util/stdlib/objc.h"
namespace crashpad {
@@ -58,7 +58,7 @@
@0xfedcba9876543210,
};
- for (size_t index = 0; index < ArraySize(integer_nses); ++index) {
+ for (size_t index = 0; index < base::size(integer_nses); ++index) {
NSNumber* integer_ns = integer_nses[index];
launch_data.reset(CFPropertyToLaunchData(integer_ns));
ASSERT_TRUE(launch_data.get());
@@ -88,7 +88,7 @@
[NSNumber numberWithDouble:std::numeric_limits<double>::signaling_NaN()],
};
- for (size_t index = 0; index < ArraySize(double_nses); ++index) {
+ for (size_t index = 0; index < base::size(double_nses); ++index) {
NSNumber* double_ns = double_nses[index];
launch_data.reset(CFPropertyToLaunchData(double_ns));
ASSERT_TRUE(launch_data.get());
@@ -114,7 +114,7 @@
@YES,
};
- for (size_t index = 0; index < ArraySize(bool_nses); ++index) {
+ for (size_t index = 0; index < base::size(bool_nses); ++index) {
NSNumber* bool_ns = bool_nses[index];
launch_data.reset(CFPropertyToLaunchData(bool_ns));
ASSERT_TRUE(launch_data.get());
@@ -138,7 +138,7 @@
@"Üñîçø∂é",
};
- for (size_t index = 0; index < ArraySize(string_nses); ++index) {
+ for (size_t index = 0; index < base::size(string_nses); ++index) {
NSString* string_ns = string_nses[index];
launch_data.reset(CFPropertyToLaunchData(string_ns));
ASSERT_TRUE(launch_data.get());
diff --git a/util/mach/child_port_handshake.cc b/util/mach/child_port_handshake.cc
index 721e560..a1918c0 100644
--- a/util/mach/child_port_handshake.cc
+++ b/util/mach/child_port_handshake.cc
@@ -31,6 +31,7 @@
#include "base/mac/scoped_mach_port.h"
#include "base/posix/eintr_wrapper.h"
#include "base/rand_util.h"
+#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "util/file/file_io.h"
#include "util/mach/child_port.h"
@@ -38,7 +39,6 @@
#include "util/mach/mach_extensions.h"
#include "util/mach/mach_message.h"
#include "util/mach/mach_message_server.h"
-#include "util/misc/arraysize.h"
#include "util/misc/implicit_cast.h"
#include "util/misc/random_string.h"
@@ -158,8 +158,8 @@
0,
0,
nullptr);
- int rv = HANDLE_EINTR(
- kevent(kq.get(), changelist, ArraySize(changelist), nullptr, 0, nullptr));
+ int rv = HANDLE_EINTR(kevent(
+ kq.get(), changelist, base::size(changelist), nullptr, 0, nullptr));
PCHECK(rv != -1) << "kevent";
ChildPortServer child_port_server(this);
diff --git a/util/mach/child_port_server.cc b/util/mach/child_port_server.cc
index 678d3b2..aa7a1b8 100644
--- a/util/mach/child_port_server.cc
+++ b/util/mach/child_port_server.cc
@@ -15,9 +15,9 @@
#include "util/mach/child_port_server.h"
#include "base/logging.h"
+#include "base/stl_util.h"
#include "util/mach/child_portServer.h"
#include "util/mach/mach_message.h"
-#include "util/misc/arraysize.h"
namespace {
@@ -91,7 +91,7 @@
static constexpr mach_msg_id_t request_ids[] =
{kMachMessageIDChildPortCheckIn};
return std::set<mach_msg_id_t>(&request_ids[0],
- &request_ids[ArraySize(request_ids)]);
+ &request_ids[base::size(request_ids)]);
}
mach_msg_size_t ChildPortServer::MachMessageServerRequestSize() {
diff --git a/util/mach/composite_mach_message_server_test.cc b/util/mach/composite_mach_message_server_test.cc
index c2ed5d7..87242be 100644
--- a/util/mach/composite_mach_message_server_test.cc
+++ b/util/mach/composite_mach_message_server_test.cc
@@ -16,11 +16,11 @@
#include <sys/types.h>
+#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "gtest/gtest.h"
#include "test/gtest_death.h"
#include "util/mach/mach_message.h"
-#include "util/misc/arraysize.h"
namespace crashpad {
namespace test {
@@ -197,7 +197,7 @@
TestMachMessageHandler handlers[3];
std::set<mach_msg_id_t> expect_request_ids;
- for (size_t index = 0; index < ArraySize(kRequestIDs0); ++index) {
+ for (size_t index = 0; index < base::size(kRequestIDs0); ++index) {
const mach_msg_id_t request_id = kRequestIDs0[index];
handlers[0].AddRequestID(request_id);
expect_request_ids.insert(request_id);
@@ -206,7 +206,7 @@
handlers[0].SetReplySize(sizeof(mig_reply_error_t));
handlers[0].SetReturnCodes(true, kReturnCode0, false);
- for (size_t index = 0; index < ArraySize(kRequestIDs1); ++index) {
+ for (size_t index = 0; index < base::size(kRequestIDs1); ++index) {
const mach_msg_id_t request_id = kRequestIDs1[index];
handlers[1].AddRequestID(request_id);
expect_request_ids.insert(request_id);
@@ -215,7 +215,7 @@
handlers[1].SetReplySize(200);
handlers[1].SetReturnCodes(false, kReturnCode1, true);
- for (size_t index = 0; index < ArraySize(kRequestIDs2); ++index) {
+ for (size_t index = 0; index < base::size(kRequestIDs2); ++index) {
const mach_msg_id_t request_id = kRequestIDs2[index];
handlers[2].AddRequestID(request_id);
expect_request_ids.insert(request_id);
@@ -253,7 +253,7 @@
// Send messages with known request IDs.
- for (size_t index = 0; index < ArraySize(kRequestIDs0); ++index) {
+ for (size_t index = 0; index < base::size(kRequestIDs0); ++index) {
request.header.msgh_id = kRequestIDs0[index];
SCOPED_TRACE(base::StringPrintf(
"handler 0, index %zu, id %d", index, request.header.msgh_id));
@@ -264,7 +264,7 @@
EXPECT_FALSE(destroy_complex_request);
}
- for (size_t index = 0; index < ArraySize(kRequestIDs1); ++index) {
+ for (size_t index = 0; index < base::size(kRequestIDs1); ++index) {
request.header.msgh_id = kRequestIDs1[index];
SCOPED_TRACE(base::StringPrintf(
"handler 1, index %zu, id %d", index, request.header.msgh_id));
@@ -275,7 +275,7 @@
EXPECT_TRUE(destroy_complex_request);
}
- for (size_t index = 0; index < ArraySize(kRequestIDs2); ++index) {
+ for (size_t index = 0; index < base::size(kRequestIDs2); ++index) {
request.header.msgh_id = kRequestIDs2[index];
SCOPED_TRACE(base::StringPrintf(
"handler 2, index %zu, id %d", index, request.header.msgh_id));
diff --git a/util/mach/exc_client_variants_test.cc b/util/mach/exc_client_variants_test.cc
index 7d1d00d..007442a 100644
--- a/util/mach/exc_client_variants_test.cc
+++ b/util/mach/exc_client_variants_test.cc
@@ -20,6 +20,7 @@
#include <sys/types.h>
#include "base/macros.h"
+#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "gtest/gtest.h"
#include "test/mac/mach_errors.h"
@@ -29,7 +30,6 @@
#include "util/mach/mach_extensions.h"
#include "util/mach/mach_message.h"
#include "util/mach/mach_message_server.h"
-#include "util/misc/arraysize.h"
#include "util/misc/implicit_cast.h"
namespace crashpad {
@@ -182,11 +182,11 @@
// These aren’t real flavors, it’s just for testing.
flavor = exception_ + 10;
flavor_p = &flavor;
- for (size_t index = 0; index < ArraySize(old_state); ++index) {
+ for (size_t index = 0; index < base::size(old_state); ++index) {
old_state[index] = index;
}
old_state_p = reinterpret_cast<thread_state_t>(&old_state);
- old_state_count = ArraySize(old_state);
+ old_state_count = base::size(old_state);
// new_state and new_state_count are out parameters that the server should
// never see or use, so set them to bogus values. The call to the server
@@ -203,7 +203,7 @@
task,
exception,
code,
- ArraySize(code),
+ base::size(code),
flavor_p,
old_state_p,
old_state_count,
@@ -274,7 +274,7 @@
kMachExceptionCodes | EXCEPTION_STATE_IDENTITY,
};
- for (size_t index = 0; index < ArraySize(kBehaviors); ++index) {
+ for (size_t index = 0; index < base::size(kBehaviors); ++index) {
exception_behavior_t behavior = kBehaviors[index];
SCOPED_TRACE(base::StringPrintf("index %zu, behavior %d", index, behavior));
diff --git a/util/mach/exc_server_variants.cc b/util/mach/exc_server_variants.cc
index f7b0b3d..6264cb3 100644
--- a/util/mach/exc_server_variants.cc
+++ b/util/mach/exc_server_variants.cc
@@ -21,6 +21,7 @@
#include <vector>
#include "base/logging.h"
+#include "base/stl_util.h"
#include "util/mac/mac_util.h"
#include "util/mach/composite_mach_message_server.h"
#include "util/mach/exc.h"
@@ -29,7 +30,6 @@
#include "util/mach/mach_exc.h"
#include "util/mach/mach_excServer.h"
#include "util/mach/mach_message.h"
-#include "util/misc/arraysize.h"
namespace crashpad {
@@ -243,7 +243,7 @@
Traits::kMachMessageIDExceptionRaiseStateIdentity,
};
return std::set<mach_msg_id_t>(&request_ids[0],
- &request_ids[ArraySize(request_ids)]);
+ &request_ids[base::size(request_ids)]);
}
mach_msg_size_t MachMessageServerRequestSize() override {
@@ -320,7 +320,7 @@
using Reply = typename Traits::ExceptionRaiseStateReply;
Reply* out_reply = reinterpret_cast<Reply*>(out_header);
out_reply->flavor = in_request_1->flavor;
- out_reply->new_stateCnt = ArraySize(out_reply->new_state);
+ out_reply->new_stateCnt = base::size(out_reply->new_state);
out_reply->RetCode =
interface_->CatchExceptionRaiseState(in_header->msgh_local_port,
in_request->exception,
@@ -363,7 +363,7 @@
using Reply = typename Traits::ExceptionRaiseStateIdentityReply;
Reply* out_reply = reinterpret_cast<Reply*>(out_header);
out_reply->flavor = in_request_1->flavor;
- out_reply->new_stateCnt = ArraySize(out_reply->new_state);
+ out_reply->new_stateCnt = base::size(out_reply->new_state);
out_reply->RetCode = interface_->CatchExceptionRaiseStateIdentity(
in_header->msgh_local_port,
in_request->thread.name,
diff --git a/util/mach/exc_server_variants_test.cc b/util/mach/exc_server_variants_test.cc
index b50ded1..078d4ae 100644
--- a/util/mach/exc_server_variants_test.cc
+++ b/util/mach/exc_server_variants_test.cc
@@ -19,6 +19,7 @@
#include <string.h>
#include <sys/types.h>
+#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "build/build_config.h"
#include "gmock/gmock.h"
@@ -29,7 +30,6 @@
#include "util/mach/exception_behaviors.h"
#include "util/mach/exception_types.h"
#include "util/mach/mach_message.h"
-#include "util/misc/arraysize.h"
#include "util/misc/implicit_cast.h"
namespace crashpad {
@@ -229,7 +229,7 @@
EXPECT_EQ(memcmp(&NDR, &NDR_record, sizeof(NDR)), 0);
EXPECT_EQ(RetCode, KERN_SUCCESS);
EXPECT_EQ(flavor, kThreadStateFlavor);
- EXPECT_EQ(new_stateCnt, ArraySize(new_state));
+ EXPECT_EQ(new_stateCnt, base::size(new_state));
}
mach_msg_header_t Head;
@@ -660,7 +660,7 @@
AreExceptionCodes(kTestExceptonCodes[0], kTestExceptonCodes[1]),
Pointee(Eq(kThreadStateFlavor)),
IsThreadStateAndCount(kThreadStateFlavorCount),
- IsThreadStateAndCount(ArraySize(reply.new_state)),
+ IsThreadStateAndCount(base::size(reply.new_state)),
Eq(request.Trailer())))
.WillOnce(Return(KERN_SUCCESS))
.RetiresOnSaturation();
@@ -709,7 +709,7 @@
AreExceptionCodes(kTestExceptonCodes[0], kTestExceptonCodes[1]),
Pointee(Eq(kThreadStateFlavor)),
IsThreadStateAndCount(kThreadStateFlavorCount),
- IsThreadStateAndCount(ArraySize(reply.new_state)),
+ IsThreadStateAndCount(base::size(reply.new_state)),
Eq(request.Trailer())))
.WillOnce(Return(KERN_SUCCESS))
.RetiresOnSaturation();
@@ -803,7 +803,7 @@
kTestMachExceptionCodes[1]),
Pointee(Eq(kThreadStateFlavor)),
IsThreadStateAndCount(kThreadStateFlavorCount),
- IsThreadStateAndCount(ArraySize(reply.new_state)),
+ IsThreadStateAndCount(base::size(reply.new_state)),
Eq(request.Trailer())))
.WillOnce(Return(KERN_SUCCESS))
.RetiresOnSaturation();
@@ -853,7 +853,7 @@
kTestMachExceptionCodes[1]),
Pointee(Eq(kThreadStateFlavor)),
IsThreadStateAndCount(kThreadStateFlavorCount),
- IsThreadStateAndCount(ArraySize(reply.new_state)),
+ IsThreadStateAndCount(base::size(reply.new_state)),
Eq(request.Trailer())))
.WillOnce(Return(KERN_SUCCESS))
.RetiresOnSaturation();
@@ -907,7 +907,7 @@
2508,
};
- for (size_t index = 0; index < ArraySize(unknown_ids); ++index) {
+ for (size_t index = 0; index < base::size(unknown_ids); ++index) {
mach_msg_id_t id = unknown_ids[index];
SCOPED_TRACE(base::StringPrintf("unknown id %d", id));
@@ -1180,7 +1180,7 @@
#endif
};
- for (size_t index = 0; index < ArraySize(test_data); ++index) {
+ for (size_t index = 0; index < base::size(test_data); ++index) {
const auto& test = test_data[index];
SCOPED_TRACE(
base::StringPrintf("index %zu, flavor %d", index, test.flavor));
@@ -1253,7 +1253,7 @@
KERN_SUCCESS},
};
- for (size_t index = 0; index < ArraySize(kTestData); ++index) {
+ for (size_t index = 0; index < base::size(kTestData); ++index) {
const auto& test_data = kTestData[index];
SCOPED_TRACE(
base::StringPrintf("index %zu, behavior %d, set_thread_state %s",
@@ -1272,8 +1272,8 @@
static constexpr natural_t old_state[] = {1, 2, 3, 4, 5};
natural_t new_state[10] = {};
- constexpr mach_msg_type_number_t old_state_count = ArraySize(old_state);
- mach_msg_type_number_t new_state_count = ArraySize(new_state);
+ constexpr mach_msg_type_number_t old_state_count = base::size(old_state);
+ mach_msg_type_number_t new_state_count = base::size(new_state);
// EXCEPTION_DEFAULT (with or without MACH_EXCEPTION_CODES) is not
// state-carrying. new_state and new_state_count should be untouched.
@@ -1282,8 +1282,8 @@
old_state_count,
new_state,
&new_state_count);
- EXPECT_EQ(new_state_count, ArraySize(new_state));
- for (size_t i = 0; i < ArraySize(new_state); ++i) {
+ EXPECT_EQ(new_state_count, base::size(new_state));
+ for (size_t i = 0; i < base::size(new_state); ++i) {
EXPECT_EQ(new_state[i], 0u) << "i " << i;
}
@@ -1292,8 +1292,8 @@
old_state_count,
new_state,
&new_state_count);
- EXPECT_EQ(new_state_count, ArraySize(new_state));
- for (size_t i = 0; i < ArraySize(new_state); ++i) {
+ EXPECT_EQ(new_state_count, base::size(new_state));
+ for (size_t i = 0; i < base::size(new_state); ++i) {
EXPECT_EQ(new_state[i], 0u) << "i " << i;
}
@@ -1305,7 +1305,7 @@
for (size_t i = 0; i < copy_limit; ++i) {
EXPECT_EQ(new_state[i], old_state[i]) << "i " << i;
}
- for (size_t i = copy_limit; i < ArraySize(new_state); ++i) {
+ for (size_t i = copy_limit; i < base::size(new_state); ++i) {
EXPECT_EQ(new_state[i], 0u) << "i " << i;
}
@@ -1321,23 +1321,23 @@
for (size_t i = 0; i < copy_limit; ++i) {
EXPECT_EQ(new_state[i], old_state[i]) << "i " << i;
}
- for (size_t i = copy_limit; i < ArraySize(new_state); ++i) {
+ for (size_t i = copy_limit; i < base::size(new_state); ++i) {
EXPECT_EQ(new_state[i], 0u) << "i " << i;
}
// This is a state-carrying exception where all of old_state is copied to
// new_state, which is large enough to receive it and then some.
- new_state_count = ArraySize(new_state);
+ new_state_count = base::size(new_state);
ExcServerCopyState(MACH_EXCEPTION_CODES | EXCEPTION_STATE_IDENTITY,
old_state,
old_state_count,
new_state,
&new_state_count);
EXPECT_EQ(new_state_count, old_state_count);
- for (size_t i = 0; i < ArraySize(old_state); ++i) {
+ for (size_t i = 0; i < base::size(old_state); ++i) {
EXPECT_EQ(new_state[i], old_state[i]) << "i " << i;
}
- for (size_t i = ArraySize(old_state); i < ArraySize(new_state); ++i) {
+ for (size_t i = base::size(old_state); i < base::size(new_state); ++i) {
EXPECT_EQ(new_state[i], 0u) << "i " << i;
}
}
diff --git a/util/mach/exception_behaviors_test.cc b/util/mach/exception_behaviors_test.cc
index fd74d22..bdbf673 100644
--- a/util/mach/exception_behaviors_test.cc
+++ b/util/mach/exception_behaviors_test.cc
@@ -16,10 +16,10 @@
#include <sys/types.h>
+#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "gtest/gtest.h"
#include "util/mach/mach_extensions.h"
-#include "util/misc/arraysize.h"
namespace crashpad {
namespace test {
@@ -53,7 +53,7 @@
EXCEPTION_STATE_IDENTITY},
};
- for (size_t index = 0; index < ArraySize(kTestData); ++index) {
+ for (size_t index = 0; index < base::size(kTestData); ++index) {
const auto& test_data = kTestData[index];
SCOPED_TRACE(base::StringPrintf(
"index %zu, behavior %d", index, test_data.behavior));
diff --git a/util/mach/exception_types_test.cc b/util/mach/exception_types_test.cc
index 030c7f3..da2c822 100644
--- a/util/mach/exception_types_test.cc
+++ b/util/mach/exception_types_test.cc
@@ -20,11 +20,11 @@
#include <sys/types.h>
#include <unistd.h>
+#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "gtest/gtest.h"
#include "util/mac/mac_util.h"
#include "util/mach/mach_extensions.h"
-#include "util/misc/arraysize.h"
namespace crashpad {
namespace test {
@@ -67,7 +67,7 @@
{0, 0, 0, 0},
};
- for (size_t index = 0; index < ArraySize(kTestData); ++index) {
+ for (size_t index = 0; index < base::size(kTestData); ++index) {
const auto& test_data = kTestData[index];
SCOPED_TRACE(base::StringPrintf(
"index %zu, code_0 0x%llx", index, test_data.code_0));
@@ -84,7 +84,7 @@
// Now make sure that ExcCrashRecoverOriginalException() properly ignores
// optional arguments.
- static_assert(ArraySize(kTestData) >= 1, "must have something to test");
+ static_assert(base::size(kTestData) >= 1, "must have something to test");
const auto& test_data = kTestData[0];
EXPECT_EQ(
ExcCrashRecoverOriginalException(test_data.code_0, nullptr, nullptr),
@@ -238,7 +238,7 @@
{0x00010000, 0x00010000, static_cast<int32_t>(0xffffffff)},
};
- for (size_t index = 0; index < ArraySize(kTestData); ++index) {
+ for (size_t index = 0; index < base::size(kTestData); ++index) {
const auto& test_data = kTestData[index];
SCOPED_TRACE(base::StringPrintf("index %zu, exception 0x%x, code_0 0x%llx",
index,
diff --git a/util/mach/mach_message_server_test.cc b/util/mach/mach_message_server_test.cc
index 724d84e..e3a3f94 100644
--- a/util/mach/mach_message_server_test.cc
+++ b/util/mach/mach_message_server_test.cc
@@ -23,13 +23,13 @@
#include "base/mac/scoped_mach_port.h"
#include "base/macros.h"
+#include "base/stl_util.h"
#include "gtest/gtest.h"
#include "test/mac/mach_errors.h"
#include "test/mac/mach_multiprocess.h"
#include "util/file/file_io.h"
#include "util/mach/mach_extensions.h"
#include "util/mach/mach_message.h"
-#include "util/misc/arraysize.h"
#include "util/misc/implicit_cast.h"
namespace crashpad {
@@ -282,7 +282,7 @@
std::set<mach_msg_id_t> MachMessageServerRequestIDs() override {
static constexpr mach_msg_id_t request_ids[] = {kRequestMessageID};
return std::set<mach_msg_id_t>(&request_ids[0],
- &request_ids[ArraySize(request_ids)]);
+ &request_ids[base::size(request_ids)]);
}
mach_msg_size_t MachMessageServerRequestSize() override {
diff --git a/util/mach/notify_server.cc b/util/mach/notify_server.cc
index 5d0b3c0..b9da795 100644
--- a/util/mach/notify_server.cc
+++ b/util/mach/notify_server.cc
@@ -15,9 +15,9 @@
#include "util/mach/notify_server.h"
#include "base/logging.h"
+#include "base/stl_util.h"
#include "util/mach/mach_message.h"
#include "util/mach/notifyServer.h"
-#include "util/misc/arraysize.h"
namespace {
@@ -228,7 +228,7 @@
MACH_NOTIFY_DEAD_NAME,
};
return std::set<mach_msg_id_t>(&request_ids[0],
- &request_ids[ArraySize(request_ids)]);
+ &request_ids[base::size(request_ids)]);
}
mach_msg_size_t NotifyServer::MachMessageServerRequestSize() {
diff --git a/util/mach/symbolic_constants_mach.cc b/util/mach/symbolic_constants_mach.cc
index fa6eefb..71fe115 100644
--- a/util/mach/symbolic_constants_mach.cc
+++ b/util/mach/symbolic_constants_mach.cc
@@ -17,10 +17,10 @@
#include <string.h>
#include <sys/types.h>
+#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "util/mach/exception_behaviors.h"
#include "util/mach/mach_extensions.h"
-#include "util/misc/arraysize.h"
#include "util/misc/implicit_cast.h"
#include "util/stdlib/string_number_conversion.h"
@@ -45,7 +45,7 @@
"GUARD",
"CORPSE_NOTIFY",
};
-static_assert(ArraySize(kExceptionNames) == EXC_TYPES_COUNT,
+static_assert(base::size(kExceptionNames) == EXC_TYPES_COUNT,
"kExceptionNames length");
constexpr char kExcPrefix[] = "EXC_";
@@ -170,7 +170,7 @@
{"_STATE32", "32"},
{"_STATE64", "64"},
};
- for (size_t suffix_index = 0; suffix_index < ArraySize(kStateSuffixes);
+ for (size_t suffix_index = 0; suffix_index < base::size(kStateSuffixes);
++suffix_index) {
const char* suffix = kStateSuffixes[suffix_index].orig;
size_t suffix_len = strlen(suffix);
@@ -194,7 +194,7 @@
std::string ExceptionToString(exception_type_t exception,
SymbolicConstantToStringOptions options) {
const char* exception_name =
- implicit_cast<size_t>(exception) < ArraySize(kExceptionNames)
+ implicit_cast<size_t>(exception) < base::size(kExceptionNames)
? kExceptionNames[exception]
: nullptr;
if (!exception_name) {
@@ -220,7 +220,7 @@
base::StringPiece short_string =
can_match_full ? string.substr(strlen(kExcPrefix)) : string;
for (exception_type_t index = 0;
- index < implicit_cast<exception_type_t>(ArraySize(kExceptionNames));
+ index < implicit_cast<exception_type_t>(base::size(kExceptionNames));
++index) {
const char* exception_name = kExceptionNames[index];
if (!exception_name) {
@@ -250,7 +250,7 @@
exception_mask_t local_exception_mask = exception_mask;
std::string mask_string;
bool has_forbidden_or = false;
- for (size_t exception = 0; exception < ArraySize(kExceptionNames);
+ for (size_t exception = 0; exception < base::size(kExceptionNames);
++exception) {
const char* exception_name = kExceptionNames[exception];
exception_mask_t exception_mask_value = 1 << exception;
@@ -324,7 +324,7 @@
base::StringPiece short_string =
can_match_full ? string.substr(strlen(kExcMaskPrefix)) : string;
for (exception_type_t index = 0;
- index < implicit_cast<exception_type_t>(ArraySize(kExceptionNames));
+ index < implicit_cast<exception_type_t>(base::size(kExceptionNames));
++index) {
const char* exception_name = kExceptionNames[index];
if (!exception_name) {
@@ -363,7 +363,7 @@
const exception_behavior_t basic_behavior = ExceptionBehaviorBasic(behavior);
const char* behavior_name =
- implicit_cast<size_t>(basic_behavior) < ArraySize(kBehaviorNames)
+ implicit_cast<size_t>(basic_behavior) < base::size(kBehaviorNames)
? kBehaviorNames[basic_behavior]
: nullptr;
if (!behavior_name) {
@@ -430,7 +430,8 @@
base::StringPiece short_string =
can_match_full ? sp.substr(strlen(kBehaviorPrefix)) : sp;
for (exception_behavior_t index = 0;
- index < implicit_cast<exception_behavior_t>(ArraySize(kBehaviorNames));
+ index <
+ implicit_cast<exception_behavior_t>(base::size(kBehaviorNames));
++index) {
const char* behavior_name = kBehaviorNames[index];
if (!behavior_name) {
@@ -466,13 +467,13 @@
std::string ThreadStateFlavorToString(thread_state_flavor_t flavor,
SymbolicConstantToStringOptions options) {
const char* flavor_name =
- implicit_cast<size_t>(flavor) < ArraySize(kFlavorNames)
+ implicit_cast<size_t>(flavor) < base::size(kFlavorNames)
? kFlavorNames[flavor]
: nullptr;
if (!flavor_name) {
for (size_t generic_flavor_index = 0;
- generic_flavor_index < ArraySize(kGenericFlavorNames);
+ generic_flavor_index < base::size(kGenericFlavorNames);
++generic_flavor_index) {
if (flavor == kGenericFlavorNames[generic_flavor_index].flavor) {
flavor_name = kGenericFlavorNames[generic_flavor_index].name;
@@ -499,7 +500,7 @@
thread_state_flavor_t* flavor) {
if ((options & kAllowFullName) || (options & kAllowShortName)) {
for (thread_state_flavor_t index = 0;
- index < implicit_cast<thread_state_flavor_t>(ArraySize(kFlavorNames));
+ index < implicit_cast<thread_state_flavor_t>(base::size(kFlavorNames));
++index) {
const char* flavor_name = kFlavorNames[index];
if (!flavor_name) {
@@ -519,7 +520,7 @@
}
for (size_t generic_flavor_index = 0;
- generic_flavor_index < ArraySize(kGenericFlavorNames);
+ generic_flavor_index < base::size(kGenericFlavorNames);
++generic_flavor_index) {
const char* flavor_name = kGenericFlavorNames[generic_flavor_index].name;
thread_state_flavor_t flavor_number =
diff --git a/util/mach/symbolic_constants_mach_test.cc b/util/mach/symbolic_constants_mach_test.cc
index 4856f0a..e58a9c5 100644
--- a/util/mach/symbolic_constants_mach_test.cc
+++ b/util/mach/symbolic_constants_mach_test.cc
@@ -18,15 +18,15 @@
#include <string.h>
#include <sys/types.h>
+#include "base/stl_util.h"
#include "base/strings/string_piece.h"
#include "base/strings/stringprintf.h"
#include "gtest/gtest.h"
#include "util/mach/mach_extensions.h"
-#include "util/misc/arraysize.h"
#include "util/misc/implicit_cast.h"
#define NUL_TEST_DATA(string) \
- { string, ArraySize(string) - 1 }
+ { string, base::size(string) - 1 }
namespace crashpad {
namespace test {
@@ -160,7 +160,7 @@
}
TEST(SymbolicConstantsMach, ExceptionToString) {
- for (size_t index = 0; index < ArraySize(kExceptionTestData); ++index) {
+ for (size_t index = 0; index < base::size(kExceptionTestData); ++index) {
SCOPED_TRACE(base::StringPrintf("index %zu", index));
TestExceptionToString(kExceptionTestData[index].exception,
kExceptionTestData[index].full_name,
@@ -188,11 +188,11 @@
}
TEST(SymbolicConstantsMach, StringToException) {
- for (size_t option_index = 0; option_index < ArraySize(kNormalOptions);
+ for (size_t option_index = 0; option_index < base::size(kNormalOptions);
++option_index) {
SCOPED_TRACE(base::StringPrintf("option_index %zu", option_index));
StringToSymbolicConstantOptions options = kNormalOptions[option_index];
- for (size_t index = 0; index < ArraySize(kExceptionTestData); ++index) {
+ for (size_t index = 0; index < base::size(kExceptionTestData); ++index) {
SCOPED_TRACE(base::StringPrintf("index %zu", index));
exception_type_t exception = kExceptionTestData[index].exception;
{
@@ -230,7 +230,7 @@
"",
};
- for (size_t index = 0; index < ArraySize(kNegativeTestData); ++index) {
+ for (size_t index = 0; index < base::size(kNegativeTestData); ++index) {
SCOPED_TRACE(base::StringPrintf("index %zu", index));
TestStringToException(kNegativeTestData[index], options, false, 0);
}
@@ -251,7 +251,7 @@
NUL_TEST_DATA("1\0002"),
};
- for (size_t index = 0; index < ArraySize(kNULTestData); ++index) {
+ for (size_t index = 0; index < base::size(kNULTestData); ++index) {
SCOPED_TRACE(base::StringPrintf("index %zu", index));
base::StringPiece string(kNULTestData[index].string,
kNULTestData[index].length);
@@ -334,7 +334,7 @@
}
TEST(SymbolicConstantsMach, ExceptionMaskToString) {
- for (size_t index = 0; index < ArraySize(kExceptionMaskTestData); ++index) {
+ for (size_t index = 0; index < base::size(kExceptionMaskTestData); ++index) {
SCOPED_TRACE(base::StringPrintf("index %zu", index));
TestExceptionMaskToString(kExceptionMaskTestData[index].exception_mask,
kExceptionMaskTestData[index].full_name,
@@ -389,11 +389,12 @@
kAllowFullName | kAllowShortName | kAllowNumber | kAllowOr,
};
- for (size_t option_index = 0; option_index < ArraySize(kOptions);
+ for (size_t option_index = 0; option_index < base::size(kOptions);
++option_index) {
SCOPED_TRACE(base::StringPrintf("option_index %zu", option_index));
StringToSymbolicConstantOptions options = kOptions[option_index];
- for (size_t index = 0; index < ArraySize(kExceptionMaskTestData); ++index) {
+ for (size_t index = 0; index < base::size(kExceptionMaskTestData);
+ ++index) {
SCOPED_TRACE(base::StringPrintf("index %zu", index));
exception_mask_t exception_mask =
kExceptionMaskTestData[index].exception_mask;
@@ -444,7 +445,7 @@
"",
};
- for (size_t index = 0; index < ArraySize(kNegativeTestData); ++index) {
+ for (size_t index = 0; index < base::size(kNegativeTestData); ++index) {
SCOPED_TRACE(base::StringPrintf("index %zu", index));
TestStringToExceptionMask(kNegativeTestData[index], options, false, 0);
}
@@ -470,7 +471,7 @@
NUL_TEST_DATA("ARITHMETIC|\0EMULATION"),
};
- for (size_t index = 0; index < ArraySize(kNULTestData); ++index) {
+ for (size_t index = 0; index < base::size(kNULTestData); ++index) {
SCOPED_TRACE(base::StringPrintf("index %zu", index));
base::StringPiece string(kNULTestData[index].string,
kNULTestData[index].length);
@@ -505,7 +506,7 @@
EXC_MASK_SYSCALL | 0x100},
};
- for (size_t index = 0; index < ArraySize(kNonCanonicalTestData); ++index) {
+ for (size_t index = 0; index < base::size(kNonCanonicalTestData); ++index) {
SCOPED_TRACE(base::StringPrintf("index %zu", index));
TestStringToExceptionMask(kNonCanonicalTestData[index].string,
kNonCanonicalTestData[index].options,
@@ -576,7 +577,7 @@
}
TEST(SymbolicConstantsMach, ExceptionBehaviorToString) {
- for (size_t index = 0; index < ArraySize(kExceptionBehaviorTestData);
+ for (size_t index = 0; index < base::size(kExceptionBehaviorTestData);
++index) {
SCOPED_TRACE(base::StringPrintf("index %zu", index));
TestExceptionBehaviorToString(kExceptionBehaviorTestData[index].behavior,
@@ -606,11 +607,11 @@
}
TEST(SymbolicConstantsMach, StringToExceptionBehavior) {
- for (size_t option_index = 0; option_index < ArraySize(kNormalOptions);
+ for (size_t option_index = 0; option_index < base::size(kNormalOptions);
++option_index) {
SCOPED_TRACE(base::StringPrintf("option_index %zu", option_index));
StringToSymbolicConstantOptions options = kNormalOptions[option_index];
- for (size_t index = 0; index < ArraySize(kExceptionBehaviorTestData);
+ for (size_t index = 0; index < base::size(kExceptionBehaviorTestData);
++index) {
SCOPED_TRACE(base::StringPrintf("index %zu", index));
exception_behavior_t behavior =
@@ -656,7 +657,7 @@
"",
};
- for (size_t index = 0; index < ArraySize(kNegativeTestData); ++index) {
+ for (size_t index = 0; index < base::size(kNegativeTestData); ++index) {
SCOPED_TRACE(base::StringPrintf("index %zu", index));
TestStringToExceptionBehavior(
kNegativeTestData[index], options, false, 0);
@@ -682,7 +683,7 @@
NUL_TEST_DATA("STATE_IDENTITY|\0MACH"),
};
- for (size_t index = 0; index < ArraySize(kNULTestData); ++index) {
+ for (size_t index = 0; index < base::size(kNULTestData); ++index) {
SCOPED_TRACE(base::StringPrintf("index %zu", index));
base::StringPiece string(kNULTestData[index].string,
kNULTestData[index].length);
@@ -719,7 +720,7 @@
implicit_cast<exception_behavior_t>(MACH_EXCEPTION_CODES | 0x2)},
};
- for (size_t index = 0; index < ArraySize(kNonCanonicalTestData); ++index) {
+ for (size_t index = 0; index < base::size(kNonCanonicalTestData); ++index) {
SCOPED_TRACE(base::StringPrintf("index %zu", index));
TestStringToExceptionBehavior(kNonCanonicalTestData[index].string,
kNonCanonicalTestData[index].options,
@@ -836,7 +837,7 @@
}
TEST(SymbolicConstantsMach, ThreadStateFlavorToString) {
- for (size_t index = 0; index < ArraySize(kThreadStateFlavorTestData);
+ for (size_t index = 0; index < base::size(kThreadStateFlavorTestData);
++index) {
SCOPED_TRACE(base::StringPrintf("index %zu", index));
TestThreadStateFlavorToString(kThreadStateFlavorTestData[index].flavor,
@@ -878,11 +879,11 @@
}
TEST(SymbolicConstantsMach, StringToThreadStateFlavor) {
- for (size_t option_index = 0; option_index < ArraySize(kNormalOptions);
+ for (size_t option_index = 0; option_index < base::size(kNormalOptions);
++option_index) {
SCOPED_TRACE(base::StringPrintf("option_index %zu", option_index));
StringToSymbolicConstantOptions options = kNormalOptions[option_index];
- for (size_t index = 0; index < ArraySize(kThreadStateFlavorTestData);
+ for (size_t index = 0; index < base::size(kThreadStateFlavorTestData);
++index) {
SCOPED_TRACE(base::StringPrintf("index %zu", index));
thread_state_flavor_t flavor = kThreadStateFlavorTestData[index].flavor;
@@ -952,7 +953,7 @@
#endif
};
- for (size_t index = 0; index < ArraySize(kNegativeTestData); ++index) {
+ for (size_t index = 0; index < base::size(kNegativeTestData); ++index) {
SCOPED_TRACE(base::StringPrintf("index %zu", index));
TestStringToThreadStateFlavor(
kNegativeTestData[index], options, false, 0);
@@ -1018,7 +1019,7 @@
#endif
};
- for (size_t index = 0; index < ArraySize(kNULTestData); ++index) {
+ for (size_t index = 0; index < base::size(kNULTestData); ++index) {
SCOPED_TRACE(base::StringPrintf("index %zu", index));
base::StringPiece string(kNULTestData[index].string,
kNULTestData[index].length);
diff --git a/util/misc/arraysize.h b/util/misc/arraysize.h
index d476edb..93a6388 100644
--- a/util/misc/arraysize.h
+++ b/util/misc/arraysize.h
@@ -34,6 +34,10 @@
} // namespace crashpad
//! \brief A way of computing an array’s size.
+//!
+//! Use this only where `base::size()` or `std::size()` won’t work, such as in
+//! constant expressions (including `static_assert` expressions) that consider
+//! the sizes of non-static data members.
#define ArraySize(array) crashpad::internal::ArraySizeHelper<decltype(array)>()
#endif // CRASHPAD_UTIL_MISC_ARRAYSIZE_H_
diff --git a/util/misc/capture_context_test_util_win.cc b/util/misc/capture_context_test_util_win.cc
index d8abd37..16d81b7 100644
--- a/util/misc/capture_context_test_util_win.cc
+++ b/util/misc/capture_context_test_util_win.cc
@@ -15,8 +15,8 @@
#include "util/misc/capture_context_test_util.h"
#include "util/win/context_wrappers.h"
+#include "base/stl_util.h"
#include "gtest/gtest.h"
-#include "util/misc/arraysize.h"
namespace crashpad {
namespace test {
@@ -59,7 +59,7 @@
#if defined(ARCH_CPU_X86)
// fxsave doesn’t write these bytes.
- for (size_t i = 464; i < ArraySize(context.ExtendedRegisters); ++i) {
+ for (size_t i = 464; i < base::size(context.ExtendedRegisters); ++i) {
SCOPED_TRACE(i);
EXPECT_EQ(context.ExtendedRegisters[i], 0);
}
@@ -69,7 +69,7 @@
EXPECT_EQ(context.FltSave.MxCsr, context.MxCsr);
// fxsave doesn’t write these bytes.
- for (size_t i = 0; i < ArraySize(context.FltSave.Reserved4); ++i) {
+ for (size_t i = 0; i < base::size(context.FltSave.Reserved4); ++i) {
SCOPED_TRACE(i);
EXPECT_EQ(context.FltSave.Reserved4[i], 0);
}
@@ -81,7 +81,7 @@
EXPECT_EQ(context.P4Home, 0u);
EXPECT_EQ(context.P5Home, 0u);
EXPECT_EQ(context.P6Home, 0u);
- for (size_t i = 0; i < ArraySize(context.VectorRegister); ++i) {
+ for (size_t i = 0; i < base::size(context.VectorRegister); ++i) {
SCOPED_TRACE(i);
EXPECT_EQ(context.VectorRegister[i].Low, 0u);
EXPECT_EQ(context.VectorRegister[i].High, 0u);
diff --git a/util/misc/clock_test.cc b/util/misc/clock_test.cc
index ca4bf00..6bfb87b 100644
--- a/util/misc/clock_test.cc
+++ b/util/misc/clock_test.cc
@@ -20,9 +20,9 @@
#include "base/format_macros.h"
#include "base/logging.h"
+#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "gtest/gtest.h"
-#include "util/misc/arraysize.h"
namespace crashpad {
namespace test {
@@ -83,7 +83,7 @@
static_cast<uint64_t>(5E7), // 50 milliseconds
};
- for (size_t index = 0; index < ArraySize(kTestData); ++index) {
+ for (size_t index = 0; index < base::size(kTestData); ++index) {
const uint64_t nanoseconds = kTestData[index];
SCOPED_TRACE(base::StringPrintf(
"index %zu, nanoseconds %" PRIu64, index, nanoseconds));
diff --git a/util/misc/paths_win.cc b/util/misc/paths_win.cc
index aa5c786..f05bdcf 100644
--- a/util/misc/paths_win.cc
+++ b/util/misc/paths_win.cc
@@ -17,19 +17,21 @@
#include <windows.h>
#include "base/logging.h"
-#include "util/misc/arraysize.h"
+#include "base/stl_util.h"
namespace crashpad {
// static
bool Paths::Executable(base::FilePath* path) {
wchar_t executable_path[_MAX_PATH];
- unsigned int len = GetModuleFileName(
- nullptr, executable_path, static_cast<DWORD>(ArraySize(executable_path)));
+ unsigned int len =
+ GetModuleFileName(nullptr,
+ executable_path,
+ static_cast<DWORD>(base::size(executable_path)));
if (len == 0) {
PLOG(ERROR) << "GetModuleFileName";
return false;
- } else if (len >= ArraySize(executable_path)) {
+ } else if (len >= base::size(executable_path)) {
LOG(ERROR) << "GetModuleFileName";
return false;
}
diff --git a/util/misc/random_string_test.cc b/util/misc/random_string_test.cc
index 5d9fad6..f5f0f32 100644
--- a/util/misc/random_string_test.cc
+++ b/util/misc/random_string_test.cc
@@ -18,8 +18,8 @@
#include <set>
+#include "base/stl_util.h"
#include "gtest/gtest.h"
-#include "util/misc/arraysize.h"
namespace crashpad {
namespace test {
@@ -33,7 +33,7 @@
const std::string allowed_characters("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
size_t character_counts[26] = {};
- ASSERT_EQ(allowed_characters.size(), ArraySize(character_counts));
+ ASSERT_EQ(allowed_characters.size(), base::size(character_counts));
std::set<std::string> strings;
@@ -61,7 +61,7 @@
// Make sure every character appears at least once. It is possible, but
// extremely unlikely, for a character to not appear at all.
for (size_t character_index = 0;
- character_index < ArraySize(character_counts);
+ character_index < base::size(character_counts);
++character_index) {
EXPECT_GT(character_counts[character_index], 0u)
<< allowed_characters[character_index];
diff --git a/util/misc/uuid_test.cc b/util/misc/uuid_test.cc
index b851919..35f9ecd 100644
--- a/util/misc/uuid_test.cc
+++ b/util/misc/uuid_test.cc
@@ -21,9 +21,9 @@
#include "base/format_macros.h"
#include "base/scoped_generic.h"
+#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "gtest/gtest.h"
-#include "util/misc/arraysize.h"
namespace crashpad {
namespace test {
@@ -95,12 +95,12 @@
++uuid.data_3;
EXPECT_NE(uuid, uuid_2);
--uuid.data_3;
- for (size_t index = 0; index < ArraySize(uuid.data_4); ++index) {
+ for (size_t index = 0; index < base::size(uuid.data_4); ++index) {
++uuid.data_4[index];
EXPECT_NE(uuid, uuid_2);
--uuid.data_4[index];
}
- for (size_t index = 0; index < ArraySize(uuid.data_5); ++index) {
+ for (size_t index = 0; index < base::size(uuid.data_5); ++index) {
++uuid.data_5[index];
EXPECT_NE(uuid, uuid_2);
--uuid.data_5[index];
@@ -190,7 +190,7 @@
uuid_zero.InitializeToZero();
const std::string empty_uuid = uuid_zero.ToString();
- for (size_t index = 0; index < ArraySize(kCases); ++index) {
+ for (size_t index = 0; index < base::size(kCases); ++index) {
const TestCase& test_case = kCases[index];
SCOPED_TRACE(base::StringPrintf(
"index %" PRIuS ": %s", index, test_case.uuid_string));
@@ -226,7 +226,7 @@
};
// clang-format on
EXPECT_TRUE(uuid.InitializeFromString(
- base::StringPiece16(kChar16UUID, ArraySize(kChar16UUID))));
+ base::StringPiece16(kChar16UUID, base::size(kChar16UUID))));
EXPECT_EQ(uuid.ToString(), "f32e5bdc-2681-4c73-a4e6-333ffd33b333");
#if defined(OS_WIN)
diff --git a/util/net/http_transport_socket.cc b/util/net/http_transport_socket.cc
index b390238..f2dd681 100644
--- a/util/net/http_transport_socket.cc
+++ b/util/net/http_transport_socket.cc
@@ -24,10 +24,10 @@
#include "base/numerics/safe_conversions.h"
#include "base/posix/eintr_wrapper.h"
#include "base/scoped_generic.h"
+#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "util/file/file_io.h"
-#include "util/misc/arraysize.h"
#include "util/net/http_body.h"
#include "util/net/url.h"
#include "util/stdlib/string_number_conversion.h"
@@ -366,7 +366,7 @@
FileOperationResult data_bytes;
do {
- constexpr size_t kCRLFSize = ArraySize(kCRLFTerminator) - 1;
+ constexpr size_t kCRLFSize = base::size(kCRLFTerminator) - 1;
struct __attribute__((packed)) {
char size[8];
char crlf[2];
diff --git a/util/net/http_transport_win.cc b/util/net/http_transport_win.cc
index 06d0b7b..0987688 100644
--- a/util/net/http_transport_win.cc
+++ b/util/net/http_transport_win.cc
@@ -25,13 +25,13 @@
#include "base/logging.h"
#include "base/numerics/safe_conversions.h"
#include "base/scoped_generic.h"
+#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "package.h"
#include "util/file/file_io.h"
-#include "util/misc/arraysize.h"
#include "util/net/http_body.h"
#include "util/numeric/safe_assignment.h"
#include "util/win/module_version.h"
@@ -96,7 +96,7 @@
error_code,
0,
msgbuf,
- static_cast<DWORD>(ArraySize(msgbuf)),
+ static_cast<DWORD>(base::size(msgbuf)),
NULL);
if (!len) {
return base::StringPrintf("%s: error 0x%lx while retrieving error 0x%lx",
diff --git a/util/numeric/checked_address_range_test.cc b/util/numeric/checked_address_range_test.cc
index f5dc8ad..08bc551 100644
--- a/util/numeric/checked_address_range_test.cc
+++ b/util/numeric/checked_address_range_test.cc
@@ -19,10 +19,10 @@
#include <limits>
#include "base/format_macros.h"
+#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "build/build_config.h"
#include "gtest/gtest.h"
-#include "util/misc/arraysize.h"
namespace crashpad {
namespace test {
@@ -119,7 +119,7 @@
{0xffffffffffffffff, 1, kInvalid},
};
- for (size_t index = 0; index < ArraySize(kTestData); ++index) {
+ for (size_t index = 0; index < base::size(kTestData); ++index) {
const auto& testcase = kTestData[index];
SCOPED_TRACE(base::StringPrintf("index %" PRIuS
", base 0x%" PRIx64 ", size 0x%" PRIx64,
@@ -170,7 +170,7 @@
CheckedAddressRange parent_range_32(false, 0x2000, 0x1000);
ASSERT_TRUE(parent_range_32.IsValid());
- for (size_t index = 0; index < ArraySize(kTestData); ++index) {
+ for (size_t index = 0; index < base::size(kTestData); ++index) {
const auto& testcase = kTestData[index];
SCOPED_TRACE(base::StringPrintf(
"index %" PRIuS ", value 0x%" PRIx64, index, testcase.value));
@@ -227,7 +227,7 @@
CheckedAddressRange parent_range_32(false, 0x2000, 0x1000);
ASSERT_TRUE(parent_range_32.IsValid());
- for (size_t index = 0; index < ArraySize(kTestData); ++index) {
+ for (size_t index = 0; index < base::size(kTestData); ++index) {
const auto& testcase = kTestData[index];
SCOPED_TRACE(base::StringPrintf("index %" PRIuS
", base 0x%" PRIx64 ", size 0x%" PRIx64,
diff --git a/util/numeric/checked_range_test.cc b/util/numeric/checked_range_test.cc
index 2977b42..9d611e8 100644
--- a/util/numeric/checked_range_test.cc
+++ b/util/numeric/checked_range_test.cc
@@ -20,9 +20,9 @@
#include <limits>
#include "base/format_macros.h"
+#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "gtest/gtest.h"
-#include "util/misc/arraysize.h"
namespace crashpad {
namespace test {
@@ -78,7 +78,7 @@
{0xffffffff, 0xffffffff, false},
};
- for (size_t index = 0; index < ArraySize(kUnsignedTestData); ++index) {
+ for (size_t index = 0; index < base::size(kUnsignedTestData); ++index) {
const auto& testcase = kUnsignedTestData[index];
SCOPED_TRACE(base::StringPrintf("unsigned index %" PRIuS
", base 0x%x, size 0x%x",
@@ -140,7 +140,7 @@
{-1, 0xffffffff, false},
};
- for (size_t index = 0; index < ArraySize(kSignedTestData); ++index) {
+ for (size_t index = 0; index < base::size(kSignedTestData); ++index) {
const auto& testcase = kSignedTestData[index];
SCOPED_TRACE(base::StringPrintf("signed index %" PRIuS
", base 0x%x, size 0x%x",
@@ -186,7 +186,7 @@
CheckedRange<uint32_t> parent_range(0x2000, 0x1000);
ASSERT_TRUE(parent_range.IsValid());
- for (size_t index = 0; index < ArraySize(kTestData); ++index) {
+ for (size_t index = 0; index < base::size(kTestData); ++index) {
const auto& testcase = kTestData[index];
SCOPED_TRACE(base::StringPrintf(
"index %" PRIuS ", value 0x%x", index, testcase.value));
@@ -234,7 +234,7 @@
CheckedRange<uint32_t> parent_range(0x2000, 0x1000);
ASSERT_TRUE(parent_range.IsValid());
- for (size_t index = 0; index < ArraySize(kTestData); ++index) {
+ for (size_t index = 0; index < base::size(kTestData); ++index) {
const auto& testcase = kTestData[index];
SCOPED_TRACE(base::StringPrintf("index %" PRIuS ", base 0x%x, size 0x%x",
index,
@@ -287,7 +287,7 @@
CheckedRange<uint32_t> first_range(0x2000, 0x1000);
ASSERT_TRUE(first_range.IsValid());
- for (size_t index = 0; index < ArraySize(kTestData); ++index) {
+ for (size_t index = 0; index < base::size(kTestData); ++index) {
const auto& testcase = kTestData[index];
SCOPED_TRACE(base::StringPrintf("index %" PRIuS ", base 0x%x, size 0x%x",
index,
diff --git a/util/posix/close_multiple.cc b/util/posix/close_multiple.cc
index 22f89f5..238f158 100644
--- a/util/posix/close_multiple.cc
+++ b/util/posix/close_multiple.cc
@@ -25,10 +25,10 @@
#include "base/files/scoped_file.h"
#include "base/logging.h"
#include "base/posix/eintr_wrapper.h"
+#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
#include "build/build_config.h"
#include "util/file/directory_reader.h"
-#include "util/misc/arraysize.h"
#include "util/misc/implicit_cast.h"
#if defined(OS_MACOSX)
@@ -153,7 +153,7 @@
int maxfilesperproc;
size_t maxfilesperproc_size = sizeof(maxfilesperproc);
if (sysctl(oid,
- ArraySize(oid),
+ base::size(oid),
&maxfilesperproc,
&maxfilesperproc_size,
nullptr,
diff --git a/util/posix/process_info_mac.cc b/util/posix/process_info_mac.cc
index 8b9a6ec..9e86e08 100644
--- a/util/posix/process_info_mac.cc
+++ b/util/posix/process_info_mac.cc
@@ -18,7 +18,7 @@
#include "base/logging.h"
#include "base/mac/mach_logging.h"
-#include "util/misc/arraysize.h"
+#include "base/stl_util.h"
namespace crashpad {
@@ -33,7 +33,7 @@
int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, pid};
size_t len = sizeof(kern_proc_info_);
- if (sysctl(mib, ArraySize(mib), &kern_proc_info_, &len, nullptr, 0) != 0) {
+ if (sysctl(mib, base::size(mib), &kern_proc_info_, &len, nullptr, 0) != 0) {
PLOG(ERROR) << "sysctl for pid " << pid;
return false;
}
@@ -112,7 +112,7 @@
const short ngroups = kern_proc_info_.kp_eproc.e_ucred.cr_ngroups;
DCHECK_GE(ngroups, 0);
DCHECK_LE(static_cast<size_t>(ngroups),
- ArraySize(kern_proc_info_.kp_eproc.e_ucred.cr_groups));
+ base::size(kern_proc_info_.kp_eproc.e_ucred.cr_groups));
const gid_t* groups = kern_proc_info_.kp_eproc.e_ucred.cr_groups;
return std::set<gid_t>(&groups[0], &groups[ngroups]);
@@ -169,7 +169,7 @@
do {
int mib[] = {CTL_KERN, KERN_PROCARGS2, pid};
int rv =
- sysctl(mib, ArraySize(mib), nullptr, &args_size_estimate, nullptr, 0);
+ sysctl(mib, base::size(mib), nullptr, &args_size_estimate, nullptr, 0);
if (rv != 0) {
PLOG(ERROR) << "sysctl (size) for pid " << pid;
return false;
@@ -177,7 +177,7 @@
args_size = args_size_estimate + 1;
args.resize(args_size);
- rv = sysctl(mib, ArraySize(mib), &args[0], &args_size, nullptr, 0);
+ rv = sysctl(mib, base::size(mib), &args[0], &args_size, nullptr, 0);
if (rv != 0) {
PLOG(ERROR) << "sysctl (data) for pid " << pid;
return false;
diff --git a/util/posix/scoped_mmap_test.cc b/util/posix/scoped_mmap_test.cc
index 0a6a1fa..5c69e7e 100644
--- a/util/posix/scoped_mmap_test.cc
+++ b/util/posix/scoped_mmap_test.cc
@@ -20,10 +20,10 @@
#include "base/numerics/safe_conversions.h"
#include "base/rand_util.h"
+#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "gtest/gtest.h"
#include "test/gtest_death.h"
-#include "util/misc/arraysize.h"
namespace crashpad {
namespace test {
@@ -151,7 +151,7 @@
EXPECT_EQ(mapping.len(), 3 * kPageSize);
TestCookie cookies[3];
- for (size_t index = 0; index < ArraySize(cookies); ++index) {
+ for (size_t index = 0; index < base::size(cookies); ++index) {
cookies[index].SetUp(reinterpret_cast<uint64_t*>(
mapping.addr_as<uintptr_t>() + index * kPageSize));
}
@@ -186,7 +186,7 @@
EXPECT_EQ(mapping.len(), kPageSize);
TestCookie cookies[3];
- for (size_t index = 0; index < ArraySize(cookies); ++index) {
+ for (size_t index = 0; index < base::size(cookies); ++index) {
cookies[index].SetUp(reinterpret_cast<uint64_t*>(
reinterpret_cast<uintptr_t>(pages) + index * kPageSize));
}
@@ -197,7 +197,7 @@
EXPECT_EQ(mapping.addr(), pages);
EXPECT_EQ(mapping.len(), 3 * kPageSize);
- for (size_t index = 0; index < ArraySize(cookies); ++index) {
+ for (size_t index = 0; index < base::size(cookies); ++index) {
SCOPED_TRACE(base::StringPrintf("index %zu", index));
EXPECT_EQ(cookies[index].Observed(), cookies[index].Expected());
}
@@ -218,7 +218,7 @@
EXPECT_EQ(mapping.len(), kPageSize);
TestCookie cookies[3];
- for (size_t index = 0; index < ArraySize(cookies); ++index) {
+ for (size_t index = 0; index < base::size(cookies); ++index) {
cookies[index].SetUp(reinterpret_cast<uint64_t*>(
reinterpret_cast<uintptr_t>(pages) + index * kPageSize));
}
@@ -249,7 +249,7 @@
EXPECT_EQ(mapping.len(), 2 * kPageSize);
TestCookie cookies[3];
- for (size_t index = 0; index < ArraySize(cookies); ++index) {
+ for (size_t index = 0; index < base::size(cookies); ++index) {
cookies[index].SetUp(reinterpret_cast<uint64_t*>(
reinterpret_cast<uintptr_t>(pages) + index * kPageSize));
}
diff --git a/util/posix/signals.cc b/util/posix/signals.cc
index 69cdfca..1384de1 100644
--- a/util/posix/signals.cc
+++ b/util/posix/signals.cc
@@ -19,7 +19,7 @@
#include <vector>
#include "base/logging.h"
-#include "util/misc/arraysize.h"
+#include "base/stl_util.h"
namespace crashpad {
@@ -119,7 +119,7 @@
struct sigaction* Signals::OldActions::ActionForSignal(int sig) {
DCHECK_GT(sig, 0);
const size_t slot = sig - 1;
- DCHECK_LT(slot, ArraySize(actions_));
+ DCHECK_LT(slot, base::size(actions_));
return &actions_[slot];
}
@@ -153,7 +153,8 @@
int flags,
OldActions* old_actions) {
return InstallHandlers(
- std::vector<int>(kCrashSignals, kCrashSignals + ArraySize(kCrashSignals)),
+ std::vector<int>(kCrashSignals,
+ kCrashSignals + base::size(kCrashSignals)),
handler,
flags,
old_actions);
@@ -165,7 +166,7 @@
OldActions* old_actions) {
return InstallHandlers(
std::vector<int>(kTerminateSignals,
- kTerminateSignals + ArraySize(kTerminateSignals)),
+ kTerminateSignals + base::size(kTerminateSignals)),
handler,
flags,
old_actions);
@@ -280,12 +281,12 @@
// static
bool Signals::IsCrashSignal(int sig) {
- return IsSignalInSet(sig, kCrashSignals, ArraySize(kCrashSignals));
+ return IsSignalInSet(sig, kCrashSignals, base::size(kCrashSignals));
}
// static
bool Signals::IsTerminateSignal(int sig) {
- return IsSignalInSet(sig, kTerminateSignals, ArraySize(kTerminateSignals));
+ return IsSignalInSet(sig, kTerminateSignals, base::size(kTerminateSignals));
}
} // namespace crashpad
diff --git a/util/posix/signals_test.cc b/util/posix/signals_test.cc
index b0c8407..d91e3cc 100644
--- a/util/posix/signals_test.cc
+++ b/util/posix/signals_test.cc
@@ -26,13 +26,13 @@
#include "base/compiler_specific.h"
#include "base/files/scoped_file.h"
#include "base/logging.h"
+#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "build/build_config.h"
#include "gtest/gtest.h"
#include "test/errors.h"
#include "test/multiprocess.h"
#include "test/scoped_temp_dir.h"
-#include "util/misc/arraysize.h"
#include "util/posix/scoped_mmap.h"
namespace crashpad {
@@ -341,7 +341,7 @@
{SIGHUP, SEGV_MAPERR, false},
{SIGINT, SI_USER, false},
};
- for (size_t index = 0; index < ArraySize(kTestData); ++index) {
+ for (size_t index = 0; index < base::size(kTestData); ++index) {
const auto test_data = kTestData[index];
SCOPED_TRACE(base::StringPrintf(
"index %zu, sig %d, code %d", index, test_data.sig, test_data.code));
diff --git a/util/posix/symbolic_constants_posix.cc b/util/posix/symbolic_constants_posix.cc
index f1fa87f..5937c57 100644
--- a/util/posix/symbolic_constants_posix.cc
+++ b/util/posix/symbolic_constants_posix.cc
@@ -18,9 +18,9 @@
#include <string.h>
#include <sys/types.h>
+#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "build/build_config.h"
-#include "util/misc/arraysize.h"
#include "util/misc/implicit_cast.h"
#include "util/stdlib/string_number_conversion.h"
@@ -137,9 +137,9 @@
};
#if defined(OS_LINUX) || defined(OS_ANDROID)
// NSIG is 64 to account for real-time signals.
-static_assert(ArraySize(kSignalNames) == 32, "kSignalNames length");
+static_assert(base::size(kSignalNames) == 32, "kSignalNames length");
#else
-static_assert(ArraySize(kSignalNames) == NSIG, "kSignalNames length");
+static_assert(base::size(kSignalNames) == NSIG, "kSignalNames length");
#endif
constexpr char kSigPrefix[] = "SIG";
@@ -151,7 +151,7 @@
std::string SignalToString(int signal,
SymbolicConstantToStringOptions options) {
const char* signal_name =
- implicit_cast<size_t>(signal) < ArraySize(kSignalNames)
+ implicit_cast<size_t>(signal) < base::size(kSignalNames)
? kSignalNames[signal]
: nullptr;
if (!signal_name) {
@@ -176,7 +176,7 @@
string.substr(0, strlen(kSigPrefix)).compare(kSigPrefix) == 0;
base::StringPiece short_string =
can_match_full ? string.substr(strlen(kSigPrefix)) : string;
- for (int index = 0; index < implicit_cast<int>(ArraySize(kSignalNames));
+ for (int index = 0; index < implicit_cast<int>(base::size(kSignalNames));
++index) {
const char* signal_name = kSignalNames[index];
if (!signal_name) {
diff --git a/util/posix/symbolic_constants_posix_test.cc b/util/posix/symbolic_constants_posix_test.cc
index 1a6e0b9..c7d62ee 100644
--- a/util/posix/symbolic_constants_posix_test.cc
+++ b/util/posix/symbolic_constants_posix_test.cc
@@ -17,14 +17,14 @@
#include <signal.h>
#include <sys/types.h>
+#include "base/stl_util.h"
#include "base/strings/string_piece.h"
#include "base/strings/stringprintf.h"
#include "build/build_config.h"
#include "gtest/gtest.h"
-#include "util/misc/arraysize.h"
#define NUL_TEST_DATA(string) \
- { string, ArraySize(string) - 1 }
+ { string, base::size(string) - 1 }
namespace crashpad {
namespace test {
@@ -116,7 +116,7 @@
}
TEST(SymbolicConstantsPOSIX, SignalToString) {
- for (size_t index = 0; index < ArraySize(kSignalTestData); ++index) {
+ for (size_t index = 0; index < base::size(kSignalTestData); ++index) {
SCOPED_TRACE(base::StringPrintf("index %zu", index));
TestSignalToString(kSignalTestData[index].signal,
kSignalTestData[index].full_name,
@@ -171,11 +171,11 @@
kAllowFullName | kAllowShortName | kAllowNumber,
};
- for (size_t option_index = 0; option_index < ArraySize(kOptions);
+ for (size_t option_index = 0; option_index < base::size(kOptions);
++option_index) {
SCOPED_TRACE(base::StringPrintf("option_index %zu", option_index));
StringToSymbolicConstantOptions options = kOptions[option_index];
- for (size_t index = 0; index < ArraySize(kSignalTestData); ++index) {
+ for (size_t index = 0; index < base::size(kSignalTestData); ++index) {
SCOPED_TRACE(base::StringPrintf("index %zu", index));
int signal = kSignalTestData[index].signal;
{
@@ -213,7 +213,7 @@
"",
};
- for (size_t index = 0; index < ArraySize(kNegativeTestData); ++index) {
+ for (size_t index = 0; index < base::size(kNegativeTestData); ++index) {
SCOPED_TRACE(base::StringPrintf("index %zu", index));
TestStringToSignal(kNegativeTestData[index], options, false, 0);
}
@@ -234,7 +234,7 @@
NUL_TEST_DATA("1\0002"),
};
- for (size_t index = 0; index < ArraySize(kNULTestData); ++index) {
+ for (size_t index = 0; index < base::size(kNULTestData); ++index) {
SCOPED_TRACE(base::StringPrintf("index %zu", index));
base::StringPiece string(kNULTestData[index].string,
kNULTestData[index].length);
diff --git a/util/process/process_memory_range_test.cc b/util/process/process_memory_range_test.cc
index 9431d44..2df2b5c 100644
--- a/util/process/process_memory_range_test.cc
+++ b/util/process/process_memory_range_test.cc
@@ -17,10 +17,10 @@
#include <limits>
#include "base/logging.h"
+#include "base/stl_util.h"
#include "build/build_config.h"
#include "gtest/gtest.h"
#include "test/process_type.h"
-#include "util/misc/arraysize.h"
#include "util/misc/from_pointer_cast.h"
#include "util/process/process_memory_native.h"
@@ -59,28 +59,28 @@
auto string1_addr = FromPointerCast<VMAddress>(kTestObject.string1);
auto string2_addr = FromPointerCast<VMAddress>(kTestObject.string2);
ASSERT_TRUE(range.ReadCStringSizeLimited(
- string1_addr, ArraySize(kTestObject.string1), &string));
+ string1_addr, base::size(kTestObject.string1), &string));
EXPECT_STREQ(string.c_str(), kTestObject.string1);
ASSERT_TRUE(range.ReadCStringSizeLimited(
- string2_addr, ArraySize(kTestObject.string2), &string));
+ string2_addr, base::size(kTestObject.string2), &string));
EXPECT_STREQ(string.c_str(), kTestObject.string2);
// Limit the range to remove access to string2.
ProcessMemoryRange range2;
ASSERT_TRUE(range2.Initialize(range));
ASSERT_TRUE(
- range2.RestrictRange(string1_addr, ArraySize(kTestObject.string1)));
+ range2.RestrictRange(string1_addr, base::size(kTestObject.string1)));
EXPECT_TRUE(range2.ReadCStringSizeLimited(
- string1_addr, ArraySize(kTestObject.string1), &string));
+ string1_addr, base::size(kTestObject.string1), &string));
EXPECT_FALSE(range2.ReadCStringSizeLimited(
- string2_addr, ArraySize(kTestObject.string2), &string));
+ string2_addr, base::size(kTestObject.string2), &string));
EXPECT_FALSE(range2.Read(object_addr, sizeof(object), &object));
// String reads fail if the NUL terminator is outside the range.
ASSERT_TRUE(range2.RestrictRange(string1_addr, strlen(kTestObject.string1)));
EXPECT_FALSE(range2.ReadCStringSizeLimited(
- string1_addr, ArraySize(kTestObject.string1), &string));
+ string1_addr, base::size(kTestObject.string1), &string));
// New range outside the old range.
EXPECT_FALSE(range2.RestrictRange(string1_addr - 1, 1));
diff --git a/util/stdlib/string_number_conversion_test.cc b/util/stdlib/string_number_conversion_test.cc
index ee19429..689b4ad 100644
--- a/util/stdlib/string_number_conversion_test.cc
+++ b/util/stdlib/string_number_conversion_test.cc
@@ -18,8 +18,8 @@
#include <limits>
+#include "base/stl_util.h"
#include "gtest/gtest.h"
-#include "util/misc/arraysize.h"
namespace crashpad {
namespace test {
@@ -94,7 +94,7 @@
{"18446744073709551616", false, 0},
};
- for (size_t index = 0; index < ArraySize(kTestData); ++index) {
+ for (size_t index = 0; index < base::size(kTestData); ++index) {
int value;
bool valid = StringToNumber(kTestData[index].string, &value);
if (kTestData[index].valid) {
@@ -114,7 +114,7 @@
// is split to avoid MSVC warning:
// "decimal digit terminates octal escape sequence".
static constexpr char input[] = "6\000" "6";
- std::string input_string(input, ArraySize(input) - 1);
+ std::string input_string(input, base::size(input) - 1);
int output;
EXPECT_FALSE(StringToNumber(input_string, &output));
}
@@ -188,7 +188,7 @@
{"18446744073709551616", false, 0},
};
- for (size_t index = 0; index < ArraySize(kTestData); ++index) {
+ for (size_t index = 0; index < base::size(kTestData); ++index) {
unsigned int value;
bool valid = StringToNumber(kTestData[index].string, &value);
if (kTestData[index].valid) {
@@ -208,7 +208,7 @@
// is split to avoid MSVC warning:
// "decimal digit terminates octal escape sequence".
static constexpr char input[] = "6\000" "6";
- std::string input_string(input, ArraySize(input) - 1);
+ std::string input_string(input, base::size(input) - 1);
unsigned int output;
EXPECT_FALSE(StringToNumber(input_string, &output));
}
@@ -245,7 +245,7 @@
{"0x7Fffffffffffffff", true, std::numeric_limits<int64_t>::max()},
};
- for (size_t index = 0; index < ArraySize(kTestData); ++index) {
+ for (size_t index = 0; index < base::size(kTestData); ++index) {
int64_t value;
bool valid = StringToNumber(kTestData[index].string, &value);
if (kTestData[index].valid) {
@@ -295,7 +295,7 @@
{"0xFfffffffffffffff", true, std::numeric_limits<uint64_t>::max()},
};
- for (size_t index = 0; index < ArraySize(kTestData); ++index) {
+ for (size_t index = 0; index < base::size(kTestData); ++index) {
uint64_t value;
bool valid = StringToNumber(kTestData[index].string, &value);
if (kTestData[index].valid) {
diff --git a/util/stdlib/strlcpy_test.cc b/util/stdlib/strlcpy_test.cc
index 172a09a..bfb00fe 100644
--- a/util/stdlib/strlcpy_test.cc
+++ b/util/stdlib/strlcpy_test.cc
@@ -20,10 +20,10 @@
#include <algorithm>
#include "base/format_macros.h"
+#include "base/stl_util.h"
#include "base/strings/string16.h"
#include "base/strings/stringprintf.h"
#include "gtest/gtest.h"
-#include "util/misc/arraysize.h"
namespace crashpad {
namespace test {
@@ -64,7 +64,7 @@
static constexpr base::char16 test_characters[] =
{0x4d, 0xe9, 0x100, 0x151, 0x1e18};
- for (size_t index = 0; index < ArraySize(test_characters); ++index) {
+ for (size_t index = 0; index < base::size(test_characters); ++index) {
base::char16 test_character = test_characters[index];
SCOPED_TRACE(base::StringPrintf(
"character index %" PRIuS ", character 0x%x", index, test_character));
@@ -78,13 +78,13 @@
EXPECT_EQ(c16lcpy(destination.data,
test_string.c_str(),
- ArraySize(destination.data)),
+ base::size(destination.data)),
length);
// Make sure that the destination buffer is NUL-terminated, and that as
// much of the test string was copied as could fit.
size_t expected_destination_length =
- std::min(length, ArraySize(destination.data) - 1);
+ std::min(length, base::size(destination.data) - 1);
EXPECT_EQ(destination.data[expected_destination_length], '\0');
EXPECT_EQ(C16Len(destination.data), expected_destination_length);
@@ -97,15 +97,15 @@
// of the buffer passed to c16lcpy.
EXPECT_TRUE(C16Memcmp(expected_untouched.lead_guard,
destination.lead_guard,
- ArraySize(destination.lead_guard)) == 0);
+ base::size(destination.lead_guard)) == 0);
size_t expected_untouched_length =
- ArraySize(destination.data) - expected_destination_length - 1;
+ base::size(destination.data) - expected_destination_length - 1;
EXPECT_TRUE(C16Memcmp(expected_untouched.data,
&destination.data[expected_destination_length + 1],
expected_untouched_length) == 0);
EXPECT_TRUE(C16Memcmp(expected_untouched.trail_guard,
destination.trail_guard,
- ArraySize(destination.trail_guard)) == 0);
+ base::size(destination.trail_guard)) == 0);
}
}
}
diff --git a/util/stdlib/thread_safe_vector_test.cc b/util/stdlib/thread_safe_vector_test.cc
index 183c636..1d26b09 100644
--- a/util/stdlib/thread_safe_vector_test.cc
+++ b/util/stdlib/thread_safe_vector_test.cc
@@ -14,8 +14,8 @@
#include "util/stdlib/thread_safe_vector.h"
+#include "base/stl_util.h"
#include "gtest/gtest.h"
-#include "util/misc/arraysize.h"
#include "util/thread/thread.h"
namespace crashpad {
@@ -54,12 +54,12 @@
EXPECT_TRUE(vector.empty());
ThreadSafeVectorTestThread threads[100];
- for (size_t index = 0; index < ArraySize(threads); ++index) {
+ for (size_t index = 0; index < base::size(threads); ++index) {
threads[index].SetTestParameters(
&thread_safe_vector, static_cast<int>(index * kElementsPerThread));
}
- for (size_t index = 0; index < ArraySize(threads); ++index) {
+ for (size_t index = 0; index < base::size(threads); ++index) {
threads[index].Start();
if (index % 10 == 0) {
@@ -76,8 +76,8 @@
std::vector<int> drained = thread_safe_vector.Drain();
vector.insert(vector.end(), drained.begin(), drained.end());
- bool found[ArraySize(threads) * kElementsPerThread] = {};
- EXPECT_EQ(vector.size(), ArraySize(found));
+ bool found[base::size(threads) * kElementsPerThread] = {};
+ EXPECT_EQ(vector.size(), base::size(found));
for (int element : vector) {
EXPECT_FALSE(found[element]) << element;
found[element] = true;
diff --git a/util/synchronization/semaphore_test.cc b/util/synchronization/semaphore_test.cc
index fedead1..4f1c1cd 100644
--- a/util/synchronization/semaphore_test.cc
+++ b/util/synchronization/semaphore_test.cc
@@ -16,8 +16,8 @@
#include <sys/types.h>
+#include "base/stl_util.h"
#include "gtest/gtest.h"
-#include "util/misc/arraysize.h"
#if defined(OS_POSIX)
#include <pthread.h>
@@ -126,7 +126,7 @@
Semaphore semaphore(5);
ThreadMainInfo info[10];
size_t iterations = 0;
- for (size_t index = 0; index < ArraySize(info); ++index) {
+ for (size_t index = 0; index < base::size(info); ++index) {
info[index].semaphore = &semaphore;
info[index].iterations = index;
iterations += info[index].iterations;
@@ -138,7 +138,7 @@
semaphore.Signal();
}
- for (size_t index = 0; index < ArraySize(info); ++index) {
+ for (size_t index = 0; index < base::size(info); ++index) {
JoinThread(&info[index]);
}
}
diff --git a/util/thread/thread_log_messages_test.cc b/util/thread/thread_log_messages_test.cc
index f186ed2..94920e7 100644
--- a/util/thread/thread_log_messages_test.cc
+++ b/util/thread/thread_log_messages_test.cc
@@ -18,9 +18,9 @@
#include <sys/types.h>
#include "base/logging.h"
+#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "gtest/gtest.h"
-#include "util/misc/arraysize.h"
#include "util/thread/thread.h"
namespace crashpad {
@@ -94,8 +94,8 @@
const std::vector<std::string>& log_messages =
thread_log_messages.log_messages();
- EXPECT_EQ(log_messages.size(), ArraySize(kMessages));
- for (size_t index = 0; index < ArraySize(kMessages); ++index) {
+ EXPECT_EQ(log_messages.size(), base::size(kMessages));
+ for (size_t index = 0; index < base::size(kMessages); ++index) {
EXPECT_EQ(MessageString(log_messages[index]), kMessages[index])
<< "index " << index;
}
@@ -174,7 +174,7 @@
LoggingTestThread threads[20];
int start = 0;
- for (size_t index = 0; index < ArraySize(threads); ++index) {
+ for (size_t index = 0; index < base::size(threads); ++index) {
threads[index].Initialize(
index, static_cast<int>(start), static_cast<int>(index));
start += static_cast<int>(index);
diff --git a/util/win/command_line_test.cc b/util/win/command_line_test.cc
index e5ceef8..032d555 100644
--- a/util/win/command_line_test.cc
+++ b/util/win/command_line_test.cc
@@ -20,9 +20,9 @@
#include "base/logging.h"
#include "base/scoped_generic.h"
+#include "base/stl_util.h"
#include "gtest/gtest.h"
#include "test/errors.h"
-#include "util/misc/arraysize.h"
#include "util/win/scoped_local_alloc.h"
namespace crashpad {
@@ -65,7 +65,7 @@
L"argument 1",
L"argument 2",
};
- AppendCommandLineArgumentTest(ArraySize(kArguments), kArguments);
+ AppendCommandLineArgumentTest(base::size(kArguments), kArguments);
}
{
@@ -77,7 +77,7 @@
L"argument 2",
L"\\some\\path with\\spaces",
};
- AppendCommandLineArgumentTest(ArraySize(kArguments), kArguments);
+ AppendCommandLineArgumentTest(base::size(kArguments), kArguments);
}
{
@@ -89,7 +89,7 @@
L"she said, \"you had me at hello\"",
L"\\some\\path with\\spaces",
};
- AppendCommandLineArgumentTest(ArraySize(kArguments), kArguments);
+ AppendCommandLineArgumentTest(base::size(kArguments), kArguments);
}
{
@@ -102,7 +102,7 @@
L"argument3",
L"argument4",
};
- AppendCommandLineArgumentTest(ArraySize(kArguments), kArguments);
+ AppendCommandLineArgumentTest(base::size(kArguments), kArguments);
}
{
@@ -113,7 +113,7 @@
L"\\some\\directory with\\spaces\\",
L"argument2",
};
- AppendCommandLineArgumentTest(ArraySize(kArguments), kArguments);
+ AppendCommandLineArgumentTest(base::size(kArguments), kArguments);
}
{
@@ -124,7 +124,7 @@
L"",
L"argument2",
};
- AppendCommandLineArgumentTest(ArraySize(kArguments), kArguments);
+ AppendCommandLineArgumentTest(base::size(kArguments), kArguments);
}
{
@@ -159,7 +159,7 @@
L"\"\"",
L" \t\n\v\"",
};
- AppendCommandLineArgumentTest(ArraySize(kArguments), kArguments);
+ AppendCommandLineArgumentTest(base::size(kArguments), kArguments);
}
}
diff --git a/util/win/exception_handler_server.cc b/util/win/exception_handler_server.cc
index 8ca3d25..2593ff2 100644
--- a/util/win/exception_handler_server.cc
+++ b/util/win/exception_handler_server.cc
@@ -23,13 +23,13 @@
#include "base/logging.h"
#include "base/numerics/safe_conversions.h"
#include "base/rand_util.h"
+#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "minidump/minidump_file_writer.h"
#include "snapshot/crashpad_info_client_options.h"
#include "snapshot/win/process_snapshot_win.h"
#include "util/file/file_writer.h"
-#include "util/misc/arraysize.h"
#include "util/misc/tri_state.h"
#include "util/misc/uuid.h"
#include "util/win/get_function.h"
@@ -308,7 +308,7 @@
void ExceptionHandlerServer::Run(Delegate* delegate) {
uint64_t shutdown_token = base::RandUint64();
ScopedKernelHANDLE thread_handles[kPipeInstances];
- for (size_t i = 0; i < ArraySize(thread_handles); ++i) {
+ for (size_t i = 0; i < base::size(thread_handles); ++i) {
HANDLE pipe;
if (first_pipe_instance_.is_valid()) {
pipe = first_pipe_instance_.release();
@@ -360,7 +360,7 @@
}
// Signal to the named pipe instances that they should terminate.
- for (size_t i = 0; i < ArraySize(thread_handles); ++i) {
+ for (size_t i = 0; i < base::size(thread_handles); ++i) {
ClientToServerMessage message;
memset(&message, 0, sizeof(message));
message.type = ClientToServerMessage::kShutdown;
diff --git a/util/win/ntstatus_logging.cc b/util/win/ntstatus_logging.cc
index 118bfef..e9a9b61 100644
--- a/util/win/ntstatus_logging.cc
+++ b/util/win/ntstatus_logging.cc
@@ -16,8 +16,8 @@
#include <string>
+#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
-#include "util/misc/arraysize.h"
namespace {
@@ -30,7 +30,7 @@
ntstatus,
0,
msgbuf,
- static_cast<DWORD>(ArraySize(msgbuf)),
+ static_cast<DWORD>(base::size(msgbuf)),
nullptr);
if (len) {
// Most system messages end in a period and a space. Remove the space if
diff --git a/util/win/registration_protocol_win.cc b/util/win/registration_protocol_win.cc
index 412f8da..359e330 100644
--- a/util/win/registration_protocol_win.cc
+++ b/util/win/registration_protocol_win.cc
@@ -18,7 +18,7 @@
#include <windows.h>
#include "base/logging.h"
-#include "util/misc/arraysize.h"
+#include "base/stl_util.h"
#include "util/win/exception_handler_server.h"
#include "util/win/scoped_handle.h"
@@ -168,7 +168,8 @@
ACL_REVISION, // AclRevision.
0, // Sbz1.
sizeof(kSecDescBlob.sacl), // AclSize.
- static_cast<WORD>(ArraySize(kSecDescBlob.sacl.ace)), // AceCount.
+ static_cast<WORD>(
+ base::size(kSecDescBlob.sacl.ace)), // AceCount.
0, // Sbz2.
},
@@ -189,8 +190,8 @@
{
SID_REVISION, // Revision.
// SubAuthorityCount.
- static_cast<BYTE>(
- ArraySize(kSecDescBlob.sacl.ace[0].sid.SubAuthority)),
+ static_cast<BYTE>(base::size(
+ kSecDescBlob.sacl.ace[0].sid.SubAuthority)),
// IdentifierAuthority.
{SECURITY_MANDATORY_LABEL_AUTHORITY},
{SECURITY_MANDATORY_UNTRUSTED_RID}, // SubAuthority.
diff --git a/util/win/safe_terminate_process_test.cc b/util/win/safe_terminate_process_test.cc
index a62fb14..d2e4b6d 100644
--- a/util/win/safe_terminate_process_test.cc
+++ b/util/win/safe_terminate_process_test.cc
@@ -22,12 +22,12 @@
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/macros.h"
+#include "base/stl_util.h"
#include "build/build_config.h"
#include "gtest/gtest.h"
#include "test/errors.h"
#include "test/test_paths.h"
#include "test/win/child_launcher.h"
-#include "util/misc/arraysize.h"
#include "util/win/scoped_handle.h"
namespace crashpad {
@@ -149,7 +149,7 @@
};
void* target = reinterpret_cast<void*>(TerminateProcess);
- ScopedExecutablePatch executable_patch(target, patch, ArraySize(patch));
+ ScopedExecutablePatch executable_patch(target, patch, base::size(patch));
// Make sure that SafeTerminateProcess() can be called. Since it’s been
// patched with a no-op stub, GetLastError() shouldn’t be modified.