diff options
| author | Andreas Gampe <agampe@google.com> | 2018-12-04 09:09:12 -0800 |
|---|---|---|
| committer | Andreas Gampe <agampe@google.com> | 2018-12-06 11:37:19 -0800 |
| commit | 97b281129e556e6f3a91e9893f71ca45e7715e3f (patch) | |
| tree | 3e90f0148f3f6d073a29b0bfcd774e0689fb9fb4 /libartbase | |
| parent | 0bbac3089b5637103585b04774eea3d959c4f24d (diff) | |
| download | art-97b281129e556e6f3a91e9893f71ca45e7715e3f.tar.gz art-97b281129e556e6f3a91e9893f71ca45e7715e3f.tar.bz2 art-97b281129e556e6f3a91e9893f71ca45e7715e3f.zip | |
ART: Clean up base/utils.h
Remove dead code. Remove unnecessary includes.
Bug: 115837065
Bug: 119869270
Test: m
Change-Id: Ieb07546e9ebd476b7b1459fb8dd6cf5545d0af20
Diffstat (limited to 'libartbase')
| -rw-r--r-- | libartbase/base/utils.h | 24 | ||||
| -rw-r--r-- | libartbase/base/utils_test.cc | 19 |
2 files changed, 0 insertions, 43 deletions
diff --git a/libartbase/base/utils.h b/libartbase/base/utils.h index 9c7105599c..11472a8017 100644 --- a/libartbase/base/utils.h +++ b/libartbase/base/utils.h @@ -172,30 +172,6 @@ constexpr PointerSize ConvertToPointerSize(T any) { } } -// Returns a type cast pointer if object pointed to is within the provided bounds. -// Otherwise returns nullptr. -template <typename T> -inline static T BoundsCheckedCast(const void* pointer, - const void* lower, - const void* upper) { - const uint8_t* bound_begin = static_cast<const uint8_t*>(lower); - const uint8_t* bound_end = static_cast<const uint8_t*>(upper); - DCHECK(bound_begin <= bound_end); - - T result = reinterpret_cast<T>(pointer); - const uint8_t* begin = static_cast<const uint8_t*>(pointer); - const uint8_t* end = begin + sizeof(*result); - if (begin < bound_begin || end > bound_end || begin > end) { - return nullptr; - } - return result; -} - -template <typename T, size_t size> -constexpr size_t ArrayCount(const T (&)[size]) { - return size; -} - // Return -1 if <, 0 if ==, 1 if >. template <typename T> inline static int32_t Compare(T lhs, T rhs) { diff --git a/libartbase/base/utils_test.cc b/libartbase/base/utils_test.cc index 9bd50c309a..c3b61cefde 100644 --- a/libartbase/base/utils_test.cc +++ b/libartbase/base/utils_test.cc @@ -107,25 +107,6 @@ TEST_F(UtilsTest, Split) { EXPECT_EQ(expected, actual); } -TEST_F(UtilsTest, ArrayCount) { - int i[64]; - EXPECT_EQ(ArrayCount(i), 64u); - char c[7]; - EXPECT_EQ(ArrayCount(c), 7u); -} - -TEST_F(UtilsTest, BoundsCheckedCast) { - char buffer[64]; - const char* buffer_end = buffer + ArrayCount(buffer); - EXPECT_EQ(BoundsCheckedCast<const uint64_t*>(nullptr, buffer, buffer_end), nullptr); - EXPECT_EQ(BoundsCheckedCast<const uint64_t*>(buffer, buffer, buffer_end), - reinterpret_cast<const uint64_t*>(buffer)); - EXPECT_EQ(BoundsCheckedCast<const uint64_t*>(buffer + 56, buffer, buffer_end), - reinterpret_cast<const uint64_t*>(buffer + 56)); - EXPECT_EQ(BoundsCheckedCast<const uint64_t*>(buffer - 1, buffer, buffer_end), nullptr); - EXPECT_EQ(BoundsCheckedCast<const uint64_t*>(buffer + 57, buffer, buffer_end), nullptr); -} - TEST_F(UtilsTest, GetProcessStatus) { EXPECT_EQ("utils_test", GetProcessStatus("Name")); EXPECT_EQ("R (running)", GetProcessStatus("State")); |
