From ea7a3f82256fc2e7cc0b8f4244e74f502d9c54bd Mon Sep 17 00:00:00 2001 From: Mirko Bonadei Date: Thu, 19 Oct 2017 11:40:55 +0200 Subject: [PATCH] Fixing unsafe conversion The bot "Win (more_configs)" has spotted another unsafe type conversion. This CL is a follow-up of: - https://webrtc-review.googlesource.com/c/src/+/12921 - https://webrtc-review.googlesource.com/c/src/+/13122 Bug: chromium:759980 Change-Id: I3634c3e20fcd9f4e106914399ac40ca87d4c6137 No-Try: True Reviewed-on: https://webrtc-review.googlesource.com/13622 Commit-Queue: Mirko Bonadei Reviewed-by: Karl Wiberg Cr-Commit-Position: refs/heads/master@{#20349} --- modules/audio_coding/neteq/neteq_impl_unittest.cc | 2 +- modules/audio_processing/aec/system_delay_unittest.cc | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/audio_coding/neteq/neteq_impl_unittest.cc b/modules/audio_coding/neteq/neteq_impl_unittest.cc index 45d7f26c52..e8d9b10dd8 100644 --- a/modules/audio_coding/neteq/neteq_impl_unittest.cc +++ b/modules/audio_coding/neteq/neteq_impl_unittest.cc @@ -569,7 +569,7 @@ TEST_F(NetEqImplTest, ReorderedPacket) { EXPECT_CALL(mock_decoder, IncomingPacket(_, kPayloadLengthBytes, _, _, _)) .WillRepeatedly(Return(0)); EXPECT_CALL(mock_decoder, PacketDuration(_, kPayloadLengthBytes)) - .WillRepeatedly(Return(kPayloadLengthSamples)); + .WillRepeatedly(Return(rtc::checked_cast(kPayloadLengthSamples))); int16_t dummy_output[kPayloadLengthSamples] = {0}; // The below expectation will make the mock decoder write // |kPayloadLengthSamples| zeros to the output array, and mark it as speech. diff --git a/modules/audio_processing/aec/system_delay_unittest.cc b/modules/audio_processing/aec/system_delay_unittest.cc index db73d7e183..87b76afcd2 100644 --- a/modules/audio_processing/aec/system_delay_unittest.cc +++ b/modules/audio_processing/aec/system_delay_unittest.cc @@ -10,6 +10,7 @@ #include "modules/audio_processing/aec/aec_core.h" #include "modules/audio_processing/aec/echo_cancellation.h" +#include "rtc_base/safe_conversions.h" #include "test/gtest.h" #include "typedefs.h" // NOLINT(build/include) namespace webrtc { @@ -240,8 +241,9 @@ TEST_F(SystemDelayTest, CorrectDelayAfterStableStartup) { static_cast(kDeviceBufMs * samples_per_frame_ / 10); EXPECT_GE(average_reported_delay, WebRtcAec_system_delay(self_->aec)); int lower_bound = WebRtcAec_extended_filter_enabled(self_->aec) - ? average_reported_delay / 2 - samples_per_frame_ - : average_reported_delay * 3 / 4; + ? (average_reported_delay / 2 - + rtc::checked_cast(samples_per_frame_)) + : average_reported_delay * 3 / 4; EXPECT_LE(lower_bound, WebRtcAec_system_delay(self_->aec)); } }