Skip to content

Commit

Permalink
compare Optional<unsigned> only to unsigned integers
Browse files Browse the repository at this point in the history
more standard optional<T> inlines compares instead of converting second argument to T.
that leads to warnings about comparing unsigned to signed integers.

Bug: webrtc:9078
Change-Id: I43cc729d3b85d789b0c394064dc7e11dc27a37aa
Reviewed-on: https://webrtc-review.googlesource.com/66782
Commit-Queue: Danil Chapovalov <[email protected]>
Reviewed-by: Karl Wiberg <[email protected]>
Cr-Commit-Position: refs/heads/master@{#22779}
  • Loading branch information
DanilChapovalov authored and Commit Bot committed Apr 7, 2018
1 parent 96a0e60 commit 4da18e8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventProbeResultFailure) {

TEST_P(RtcEventLogEncoderTest, RtcEventProbeResultSuccess) {
const int id = RandomPositiveInt();
const int bitrate_bps = RandomBitrate();
const uint64_t bitrate_bps = rtc::checked_cast<uint64_t>(RandomBitrate());

auto event = rtc::MakeUnique<RtcEventProbeResultSuccess>(id, bitrate_bps);
const int64_t timestamp_us = event->timestamp_us_;
Expand All @@ -433,7 +433,6 @@ TEST_P(RtcEventLogEncoderTest, RtcEventProbeResultSuccess) {

EXPECT_EQ(parsed_log_.GetTimestamp(0), timestamp_us);
EXPECT_EQ(rtc::dchecked_cast<int>(parsed_event.id), id);
ASSERT_TRUE(parsed_event.bitrate_bps);
EXPECT_EQ(parsed_event.bitrate_bps, bitrate_bps);
ASSERT_FALSE(parsed_event.failure_reason);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,12 +314,12 @@ TEST(AudioNetworkAdaptorImplTest, TestANAStats) {

auto ana_stats = states.audio_network_adaptor->GetStats();

EXPECT_EQ(ana_stats.bitrate_action_counter, 2);
EXPECT_EQ(ana_stats.channel_action_counter, 2);
EXPECT_EQ(ana_stats.dtx_action_counter, 2);
EXPECT_EQ(ana_stats.fec_action_counter, 2);
EXPECT_EQ(ana_stats.frame_length_increase_counter, 1);
EXPECT_EQ(ana_stats.frame_length_decrease_counter, 1);
EXPECT_EQ(ana_stats.bitrate_action_counter, 2u);
EXPECT_EQ(ana_stats.channel_action_counter, 2u);
EXPECT_EQ(ana_stats.dtx_action_counter, 2u);
EXPECT_EQ(ana_stats.fec_action_counter, 2u);
EXPECT_EQ(ana_stats.frame_length_increase_counter, 1u);
EXPECT_EQ(ana_stats.frame_length_decrease_counter, 1u);
EXPECT_EQ(ana_stats.uplink_packet_loss_fraction, 0.1f);
}

Expand Down
2 changes: 1 addition & 1 deletion modules/video_coding/video_codec_initializer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ VideoCodec VideoCodecInitializer::VideoEncoderConfigToVideoCodec(
break;
case VideoEncoderConfig::ContentType::kScreen:
video_codec.mode = kScreensharing;
if (!streams.empty() && streams[0].num_temporal_layers == 2) {
if (!streams.empty() && streams[0].num_temporal_layers == 2u) {
video_codec.targetBitrate = streams[0].target_bitrate_bps / 1000;
}
break;
Expand Down
7 changes: 4 additions & 3 deletions rtc_base/string_to_number_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,16 @@ TYPED_TEST_P(BasicNumberTest, TestValidNumbers) {
using T = TypeParam;
constexpr T min_value = std::numeric_limits<T>::lowest();
constexpr T max_value = std::numeric_limits<T>::max();
constexpr T zero_value = 0;
const std::string min_string = std::to_string(min_value);
const std::string max_string = std::to_string(max_value);
EXPECT_EQ(min_value, StringToNumber<T>(min_string));
EXPECT_EQ(min_value, StringToNumber<T>(min_string.c_str()));
EXPECT_EQ(max_value, StringToNumber<T>(max_string));
EXPECT_EQ(max_value, StringToNumber<T>(max_string.c_str()));
EXPECT_EQ(0, StringToNumber<T>("0"));
EXPECT_EQ(0, StringToNumber<T>("-0"));
EXPECT_EQ(0, StringToNumber<T>(std::string("-0000000000000")));
EXPECT_EQ(zero_value, StringToNumber<T>("0"));
EXPECT_EQ(zero_value, StringToNumber<T>("-0"));
EXPECT_EQ(zero_value, StringToNumber<T>(std::string("-0000000000000")));
}

TYPED_TEST_P(BasicNumberTest, TestInvalidNumbers) {
Expand Down

0 comments on commit 4da18e8

Please sign in to comment.