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

@@ -2141,7 +2141,7 @@ bool CryptoSession::GetMaximumUsageTableEntries(SecurityLevel security_level,
});
// Record the number of entries into the metrics.
metrics_->oemcrypto_maximum_usage_table_header_size_.Record(
*number_of_entries);
static_cast<uint32_t>(*number_of_entries));
if (*number_of_entries == 0) {
// Special value, indicating that the table size is not directly