Fix -Wshorten-64-to-32 errors in usage table code

(This is a merge of http://go/wvgerrit/134312.)

This patch fixes code that would trigger -Wshorten-64-to-32 by
implicitly narrowing a variable from 64 to 32 bits. Most of the time, it
does this by making the implicit conversion explicit. There are a lot of
these places in the usage table code because we always use uint32_t as
the type of a usage entry index, but much of the code that interacts
with the usage table system naturally wants to use size_t.

Bug: 194971260
Test: OEMCrypto unit tests
Test: x86-64 platform tests
Change-Id: I3923af40715efe367955a194a9e33be3e9cb014c
This commit is contained in:
John W. Bruce
2021-10-20 13:54:26 -07:00
committed by John Bruce
parent ef792a4aca
commit 1447eba7bc
5 changed files with 127 additions and 91 deletions

View File

@@ -8646,7 +8646,7 @@ TEST_P(OEMCryptoUsageTableDefragTest, ManyUsageEntries) {
// Shrink the table a little.
constexpr size_t small_number = 5;
size_t smaller_size = successful_count - small_number;
ASSERT_NO_FATAL_FAILURE(ShrinkHeader(smaller_size));
ASSERT_NO_FATAL_FAILURE(ShrinkHeader(static_cast<uint32_t>(smaller_size)));
// Throw out the last license if it was in the part of the table that was
// shrunk.
if (entries.back()->session().usage_entry_number() >= smaller_size) {