From a811027990e7eb674f1c89e09c524530947c26d2 Mon Sep 17 00:00:00 2001 From: Mirko Bonadei Date: Wed, 18 Oct 2017 14:22:50 +0200 Subject: [PATCH] Fixing warning C4267 on Win (more_configs). We added a new bot to client.webrtc.fyi (https://build.chromium.org/p/client.webrtc.fyi/builders/Win%20%28more%20configs%29). It seems it is spotting some unsafe conversions and this CL is a test to see if we can use rtc::dchecked_cast to fix them: ../../modules/audio_coding/neteq/neteq_unittest.cc(547): error C2220: warning treated as error - no 'object' file generated ../../modules/audio_coding/neteq/neteq_unittest.cc(547): warning C4267: '=': conversion from 'size_t' to 'uint16_t', possible loss of data ../../modules/audio_coding/neteq/neteq_unittest.cc(548): warning C4267: '=': conversion from 'size_t' to 'uint32_t', possible loss of data ../../modules/audio_coding/neteq/neteq_unittest.cc(977): warning C4267: '+=': conversion from 'size_t' to 'uint32_t', possible loss of data ../../modules/audio_coding/neteq/neteq_unittest.cc(979): warning C4267: '+=': conversion from 'size_t' to 'uint32_t', possible loss Bug: chromium:759980 Change-Id: Icd0f32ccf620c7c6642fadff797dc2482918648d No-Try: True Reviewed-on: https://webrtc-review.googlesource.com/12921 Commit-Queue: Mirko Bonadei Reviewed-by: Karl Wiberg Cr-Commit-Position: refs/heads/master@{#20335} --- modules/audio_coding/neteq/neteq_unittest.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/modules/audio_coding/neteq/neteq_unittest.cc b/modules/audio_coding/neteq/neteq_unittest.cc index 8b3f28f546..592323e9a5 100644 --- a/modules/audio_coding/neteq/neteq_unittest.cc +++ b/modules/audio_coding/neteq/neteq_unittest.cc @@ -29,6 +29,7 @@ #include "rtc_base/flags.h" #include "rtc_base/ignore_wundef.h" #include "rtc_base/protobuf_utils.h" +#include "rtc_base/safe_conversions.h" #include "rtc_base/sha1digest.h" #include "rtc_base/stringencode.h" #include "test/gtest.h" @@ -544,8 +545,8 @@ TEST_F(NetEqDecodingTestFaxMode, TestFrameWaitingTimeStatistics) { for (size_t i = 0; i < num_frames; ++i) { const uint8_t payload[kPayloadBytes] = {0}; RTPHeader rtp_info; - rtp_info.sequenceNumber = i; - rtp_info.timestamp = i * kSamples; + rtp_info.sequenceNumber = rtc::checked_cast(i); + rtp_info.timestamp = rtc::checked_cast(i * kSamples); rtp_info.ssrc = 0x1234; // Just an arbitrary SSRC. rtp_info.payloadType = 94; // PCM16b WB codec. rtp_info.markerBit = 0; @@ -974,9 +975,11 @@ class NetEqBgnTest : public NetEqDecodingTest { ASSERT_EQ(AudioFrame::kNormalSpeech, output.speech_type_); // Next packet. - rtp_info.timestamp += expected_samples_per_channel; + rtp_info.timestamp += rtc::checked_cast( + expected_samples_per_channel); rtp_info.sequenceNumber++; - receive_timestamp += expected_samples_per_channel; + receive_timestamp += rtc::checked_cast( + expected_samples_per_channel); } output.Reset();