Fix -Wshorten-64-to-32 error in metrics code

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

This patch fixes code that would trigger -Wshorten-64-to-32 by
implicitly narrowing a variable from 64 to 32 bits. The caclulation is
now done at size_t resolution instead of downcasting to 32 bits.

Bug: 194971260
Test: x86-64 tests
Change-Id: I2fd0a3a3ec67f697d58d1ba00dba66452603c753
This commit is contained in:
John W. Bruce
2021-10-27 12:43:23 -07:00
parent 71aaf870c8
commit ba452b3f91

View File

@@ -375,9 +375,9 @@ void EngineMetrics::ConsolidateSessions() {
// TODO(b/118664842): Add support to merge older metrics into one
// consolidated metric.
int excess_completed = completed_session_metrics_list_.size()
- kMaxCompletedSessions;
if (excess_completed > 0) {
if (completed_session_metrics_list_.size() > kMaxCompletedSessions) {
const size_t excess_completed =
completed_session_metrics_list_.size() - kMaxCompletedSessions;
completed_session_metrics_list_.erase(
completed_session_metrics_list_.begin(),
completed_session_metrics_list_.begin() + excess_completed);