From 59e1464fcd51ea5367f1c8dfdedea84f6271fe52 Mon Sep 17 00:00:00 2001 From: Danil Chapovalov Date: Tue, 3 Sep 2019 12:41:41 +0200 Subject: [PATCH] Fix 28 ClangTidy - Readability findings in modules/rtp_rtcp/ These fixes are automatically created by various analysis tools, but have been manually triggered to be applied. * the 'empty' method should be used to check for emptiness instead of 'size' (3 times) * using decl 'Return' is unused (4 times) * using decl '_' is unused (3 times) * using decl 'DoAll' is unused (2 times) * using decl 'SetArgPointee' is unused * using decl 'Dlrr' is unused * using decl 'IsEmpty' is unused * redundant get() call on smart pointer * using decl 'Invoke' is unused (2 times) * using decl 'SizeIs' is unused (3 times) * using decl 'make_tuple' is unused * using decl 'NiceMock' is unused * using decl 'SaveArg' is unused (2 times) * using decl 'AtLeast' is unused * using decl 'ElementsAre' is unused * using decl 'Gt' is unused Bug: None Change-Id: I97658fb0e94620b8319d7c3da29b15e27ec23188 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/151133 Reviewed-by: Niels Moller Commit-Queue: Danil Chapovalov Cr-Commit-Position: refs/heads/master@{#29056} --- modules/rtp_rtcp/include/rtp_rtcp_defines.cc | 4 ++-- modules/rtp_rtcp/source/flexfec_receiver_unittest.cc | 1 - .../rtp_rtcp/source/remote_ntp_time_estimator_unittest.cc | 5 ----- .../source/rtcp_packet/extended_reports_unittest.cc | 1 - modules/rtp_rtcp/source/rtcp_packet/tmmbr_unittest.cc | 1 - modules/rtp_rtcp/source/rtcp_sender.cc | 2 +- modules/rtp_rtcp/source/rtcp_transceiver_impl_unittest.cc | 1 - .../rtp_rtcp/source/rtp_format_video_generic_unittest.cc | 1 - modules/rtp_rtcp/source/rtp_packet_unittest.cc | 1 - modules/rtp_rtcp/source/rtp_rtcp_impl.cc | 2 +- modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc | 4 ---- modules/rtp_rtcp/source/rtp_sender_audio_unittest.cc | 1 - modules/rtp_rtcp/source/rtp_sender_unittest.cc | 7 ------- modules/rtp_rtcp/source/source_tracker_unittest.cc | 1 - modules/rtp_rtcp/source/ulpfec_receiver_unittest.cc | 1 - 15 files changed, 4 insertions(+), 29 deletions(-) diff --git a/modules/rtp_rtcp/include/rtp_rtcp_defines.cc b/modules/rtp_rtcp/include/rtp_rtcp_defines.cc index 7f8efca27e..16f571f5ed 100644 --- a/modules/rtp_rtcp/include/rtp_rtcp_defines.cc +++ b/modules/rtp_rtcp/include/rtp_rtcp_defines.cc @@ -33,12 +33,12 @@ bool IsTokenChar(char ch) { } // namespace bool IsLegalMidName(absl::string_view name) { - return (name.size() <= kMidRsidMaxSize && name.size() > 0 && + return (name.size() <= kMidRsidMaxSize && !name.empty() && absl::c_all_of(name, IsTokenChar)); } bool IsLegalRsidName(absl::string_view name) { - return (name.size() <= kMidRsidMaxSize && name.size() > 0 && + return (name.size() <= kMidRsidMaxSize && !name.empty() && absl::c_all_of(name, isalnum)); } diff --git a/modules/rtp_rtcp/source/flexfec_receiver_unittest.cc b/modules/rtp_rtcp/source/flexfec_receiver_unittest.cc index 3d77d7bf54..be64bacbbb 100644 --- a/modules/rtp_rtcp/source/flexfec_receiver_unittest.cc +++ b/modules/rtp_rtcp/source/flexfec_receiver_unittest.cc @@ -27,7 +27,6 @@ namespace { using ::testing::_; using ::testing::Args; using ::testing::ElementsAreArray; -using ::testing::Return; using test::fec::FlexfecPacketGenerator; using Packet = ForwardErrorCorrection::Packet; diff --git a/modules/rtp_rtcp/source/remote_ntp_time_estimator_unittest.cc b/modules/rtp_rtcp/source/remote_ntp_time_estimator_unittest.cc index 9f42f5732e..c9b9434db4 100644 --- a/modules/rtp_rtcp/source/remote_ntp_time_estimator_unittest.cc +++ b/modules/rtp_rtcp/source/remote_ntp_time_estimator_unittest.cc @@ -14,11 +14,6 @@ #include "test/gmock.h" #include "test/gtest.h" -using ::testing::_; -using ::testing::DoAll; -using ::testing::Return; -using ::testing::SetArgPointee; - namespace webrtc { static const int64_t kTestRtt = 10; diff --git a/modules/rtp_rtcp/source/rtcp_packet/extended_reports_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/extended_reports_unittest.cc index a302a5b552..7c50c01c43 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/extended_reports_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_packet/extended_reports_unittest.cc @@ -19,7 +19,6 @@ using ::testing::ElementsAre; using ::testing::ElementsAreArray; using ::testing::make_tuple; using ::testing::SizeIs; -using webrtc::rtcp::Dlrr; using webrtc::rtcp::ExtendedReports; using webrtc::rtcp::ReceiveTimeInfo; using webrtc::rtcp::Rrtr; diff --git a/modules/rtp_rtcp/source/rtcp_packet/tmmbr_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/tmmbr_unittest.cc index a320f2367a..1bac808aa9 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/tmmbr_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_packet/tmmbr_unittest.cc @@ -15,7 +15,6 @@ #include "test/rtcp_packet_parser.h" using ::testing::ElementsAreArray; -using ::testing::IsEmpty; using ::testing::make_tuple; using webrtc::rtcp::TmmbItem; using webrtc::rtcp::Tmmbr; diff --git a/modules/rtp_rtcp/source/rtcp_sender.cc b/modules/rtp_rtcp/source/rtcp_sender.cc index c06a428ea6..4c1a2410bb 100644 --- a/modules/rtp_rtcp/source/rtcp_sender.cc +++ b/modules/rtp_rtcp/source/rtcp_sender.cc @@ -743,7 +743,7 @@ int32_t RTCPSender::SendCompoundRTCP( BuilderFunc func = builder_it->second; std::unique_ptr packet = (this->*func)(context); - if (packet.get() == nullptr) + if (packet == nullptr) return -1; // If there is a BYE, don't append now - save it and append it // at the end later. diff --git a/modules/rtp_rtcp/source/rtcp_transceiver_impl_unittest.cc b/modules/rtp_rtcp/source/rtcp_transceiver_impl_unittest.cc index fac173522d..ebfb068f7e 100644 --- a/modules/rtp_rtcp/source/rtcp_transceiver_impl_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_transceiver_impl_unittest.cc @@ -32,7 +32,6 @@ namespace { using ::testing::_; using ::testing::ElementsAre; -using ::testing::Invoke; using ::testing::Return; using ::testing::SizeIs; using ::testing::StrictMock; diff --git a/modules/rtp_rtcp/source/rtp_format_video_generic_unittest.cc b/modules/rtp_rtcp/source/rtp_format_video_generic_unittest.cc index 9ba0573951..67b7cba185 100644 --- a/modules/rtp_rtcp/source/rtp_format_video_generic_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_format_video_generic_unittest.cc @@ -30,7 +30,6 @@ using ::testing::Contains; using ::testing::Each; using ::testing::ElementsAreArray; using ::testing::Le; -using ::testing::SizeIs; constexpr RtpPacketizer::PayloadSizeLimits kNoSizeLimits; diff --git a/modules/rtp_rtcp/source/rtp_packet_unittest.cc b/modules/rtp_rtcp/source/rtp_packet_unittest.cc index b5834778d5..150dba7f5f 100644 --- a/modules/rtp_rtcp/source/rtp_packet_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_packet_unittest.cc @@ -23,7 +23,6 @@ using ::testing::Each; using ::testing::ElementsAre; using ::testing::ElementsAreArray; using ::testing::IsEmpty; -using ::testing::make_tuple; constexpr int8_t kPayloadType = 100; constexpr uint32_t kSsrc = 0x12345678; diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc index d8ffd22fe7..eaba788c88 100644 --- a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc +++ b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc @@ -694,7 +694,7 @@ void ModuleRtpRtcpImpl::OnReceivedNack( if (!rtp_sender_) return; - if (!rtp_sender_->StorePackets() || nack_sequence_numbers.size() == 0) { + if (!rtp_sender_->StorePackets() || nack_sequence_numbers.empty()) { return; } // Use RTT from RtcpRttStats class if provided. diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc index f55e4f81d2..3cec171676 100644 --- a/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc @@ -29,11 +29,7 @@ #include "test/rtcp_packet_parser.h" #include "test/rtp_header_parser.h" -using ::testing::_; using ::testing::ElementsAre; -using ::testing::NiceMock; -using ::testing::Return; -using ::testing::SaveArg; namespace webrtc { namespace { diff --git a/modules/rtp_rtcp/source/rtp_sender_audio_unittest.cc b/modules/rtp_rtcp/source/rtp_sender_audio_unittest.cc index 1dad5b71ed..1e5b38be78 100644 --- a/modules/rtp_rtcp/source/rtp_sender_audio_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_sender_audio_unittest.cc @@ -33,7 +33,6 @@ const uint32_t kSsrc = 725242; const uint8_t kAudioLevel = 0x5a; const uint64_t kStartTime = 123456789; -using ::testing::_; using ::testing::ElementsAreArray; class LoopbackTransportTest : public webrtc::Transport { diff --git a/modules/rtp_rtcp/source/rtp_sender_unittest.cc b/modules/rtp_rtcp/source/rtp_sender_unittest.cc index ad501df57e..7c4c374fc2 100644 --- a/modules/rtp_rtcp/source/rtp_sender_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_sender_unittest.cc @@ -74,19 +74,12 @@ const char kNoMid[] = ""; using ::testing::_; using ::testing::AllOf; -using ::testing::AtLeast; -using ::testing::DoAll; -using ::testing::ElementsAre; using ::testing::ElementsAreArray; using ::testing::Field; -using ::testing::Gt; -using ::testing::Invoke; using ::testing::NiceMock; using ::testing::Pointee; using ::testing::Property; using ::testing::Return; -using ::testing::SaveArg; -using ::testing::SizeIs; using ::testing::StrictMock; uint64_t ConvertMsToAbsSendTime(int64_t time_ms) { diff --git a/modules/rtp_rtcp/source/source_tracker_unittest.cc b/modules/rtp_rtcp/source/source_tracker_unittest.cc index 55ae4d1a35..99e037280d 100644 --- a/modules/rtp_rtcp/source/source_tracker_unittest.cc +++ b/modules/rtp_rtcp/source/source_tracker_unittest.cc @@ -31,7 +31,6 @@ using ::testing::Combine; using ::testing::ElementsAre; using ::testing::ElementsAreArray; using ::testing::IsEmpty; -using ::testing::SizeIs; using ::testing::TestWithParam; using ::testing::Values; diff --git a/modules/rtp_rtcp/source/ulpfec_receiver_unittest.cc b/modules/rtp_rtcp/source/ulpfec_receiver_unittest.cc index 32f3bbb2e2..8e41c1cbd5 100644 --- a/modules/rtp_rtcp/source/ulpfec_receiver_unittest.cc +++ b/modules/rtp_rtcp/source/ulpfec_receiver_unittest.cc @@ -30,7 +30,6 @@ namespace { using ::testing::_; using ::testing::Args; using ::testing::ElementsAreArray; -using ::testing::Return; using test::fec::AugmentedPacket; using Packet = ForwardErrorCorrection::Packet;