From 837b39e8f4ce59ff5896c8a5a7bdd7c934f36312 Mon Sep 17 00:00:00 2001 From: Stefan Holmer Date: Wed, 24 Feb 2016 14:03:01 +0100 Subject: [PATCH] Fix ubsan warnings in BWE tests. BUG=webrtc:5490 R=pbos@webrtc.org Review URL: https://codereview.webrtc.org/1734583002 . Cr-Commit-Position: refs/heads/master@{#11741} --- .../remote_bitrate_estimator_unittest_helper.cc | 15 ++++++++------- .../test/estimators/nada.cc | 3 ++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.cc b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.cc index d67c538a5b..41576516db 100644 --- a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.cc +++ b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.cc @@ -446,13 +446,14 @@ void RemoteBitrateEstimatorTest::CapacityDropTestHelper( if (i > 0) { bitrate = (kStartBitrate * i + kBitrateDenom / 2) / kBitrateDenom; } - stream_generator_->AddStream(new testing::RtpStream( - kFramerate, // Frames per second. - bitrate, // Bitrate. - kDefaultSsrc + i, // SSRC. - 90000, // RTP frequency. - 0xFFFFF000 ^ (~0 << (32 - i)), // Timestamp offset. - 0)); // RTCP receive time. + uint32_t mask = ~0ull << (32 - i); + stream_generator_->AddStream( + new testing::RtpStream(kFramerate, // Frames per second. + bitrate, // Bitrate. + kDefaultSsrc + i, // SSRC. + 90000, // RTP frequency. + 0xFFFFF000u ^ mask, // Timestamp offset. + 0)); // RTCP receive time. bitrate_sum += bitrate; } ASSERT_EQ(bitrate_sum, kStartBitrate); diff --git a/webrtc/modules/remote_bitrate_estimator/test/estimators/nada.cc b/webrtc/modules/remote_bitrate_estimator/test/estimators/nada.cc index 6166ff8c2d..066b4b5e35 100644 --- a/webrtc/modules/remote_bitrate_estimator/test/estimators/nada.cc +++ b/webrtc/modules/remote_bitrate_estimator/test/estimators/nada.cc @@ -178,7 +178,8 @@ void NadaBweSender::GiveFeedback(const FeedbackPacket& feedback) { // Following parameters might be optimized. const int64_t kQueuingDelayUpperBoundMs = 10; - const float kDerivativeUpperBound = 10.0f / min_feedback_delay_ms_; + const float kDerivativeUpperBound = + 10.0f / std::max(1, min_feedback_delay_ms_); // In the modified version, a higher kMinUpperBound allows a higher d_hat // upper bound for calling AcceleratedRampUp. const float kProportionalityDelayBits = 20.0f;