Fix places that trigger no-unused-lambda-capture

no-unused-lambda-capture was suppressed, but it's been decided as desireable to stop suppressing it. This CL fixes places in the code that trigger it.

1. Some unnecessary captures removed.
2. s/constexpr/const when capturing a float by value - this is good enough to stop the error.
3. Complete removal of the constexpr/const-modifier for int-types as a workaround.

BUG=webrtc:7133

Review-Url: https://codereview.webrtc.org/3005433002
Cr-Commit-Position: refs/heads/master@{#19462}
This commit is contained in:
eladalon 2017-08-23 04:15:18 -07:00 committed by Commit Bot
parent 3df87523aa
commit 1cc5fc3ebf
8 changed files with 31 additions and 23 deletions

View File

@ -507,7 +507,7 @@ void AdaptiveFirFilter::Constrain() {
std::array<float, kFftLength> h;
fft_.Ifft(H_[partition_to_constrain_], &h);
constexpr float kScale = 1.0f / kFftLengthBy2;
const float kScale = 1.0f / kFftLengthBy2;
std::for_each(h.begin(), h.begin() + kFftLengthBy2,
[kScale](float& a) { a *= kScale; });
std::fill(h.begin() + kFftLengthBy2, h.end(), 0.f);

View File

@ -337,7 +337,7 @@ TEST(AdaptiveFirFilter, FilterAndAdapt) {
delay_buffer.Delay(x[0], y);
RandomizeSampleVector(&random_generator, n);
constexpr float kNoiseScaling = 1.f / 100.f;
const float kNoiseScaling = 1.f / 100.f;
std::transform(
y.begin(), y.end(), n.begin(), y.begin(),
[kNoiseScaling](float a, float b) { return a + b * kNoiseScaling; });

View File

@ -32,7 +32,7 @@ void EchoGeneratingPower(const RenderBuffer& render_buffer,
}
// Apply soft noise gate of -78 dBFS.
constexpr float kNoiseGatePower = 27509.42f;
const float kNoiseGatePower = 27509.42f;
std::for_each(X2->begin(), X2->end(), [kNoiseGatePower](float& a) {
if (kNoiseGatePower > a) {
a = std::max(0.f, a - 0.3f * (kNoiseGatePower - a));

View File

@ -1205,9 +1205,13 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
// Tests that when the transport channel signals a candidate pair change
// event, the media channel will receive a call on the network route change.
void TestNetworkRouteChanges() {
constexpr uint16_t kLocalNetId = 1;
constexpr uint16_t kRemoteNetId = 2;
constexpr int kLastPacketId = 100;
// These would have been declared as constexpr, but then some compilers
// require them to be captured in the lambda, and other compilers complain
// about no-ununused-lambda-capture. Keeping them as normal variables was
// the easiest work-around.
uint16_t kLocalNetId = 1;
uint16_t kRemoteNetId = 2;
int kLastPacketId = 100;
CreateChannels(0, 0);
@ -1227,7 +1231,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
EXPECT_FALSE(media_channel1->last_network_route().connected);
media_channel1->set_num_network_route_changes(0);
network_thread_->Invoke<void>(RTC_FROM_HERE, [this, media_channel1,
network_thread_->Invoke<void>(RTC_FROM_HERE, [this,
kLocalNetId, kRemoteNetId,
kLastPacketId] {
// The transport channel becomes connected.

View File

@ -721,13 +721,13 @@ TEST_F(RTCStatsCollectorTest, CollectRTCCertificateStatsSingle) {
// Mock the session to return the local and remote certificates.
EXPECT_CALL(test_->session(), GetStats(_)).WillRepeatedly(Invoke(
[this](const ChannelNamePairs&) {
[](const ChannelNamePairs&) {
std::unique_ptr<SessionStats> stats(new SessionStats());
stats->transport_stats["transport"].transport_name = "transport";
return stats;
}));
EXPECT_CALL(test_->session(), GetLocalCertificate(_, _)).WillRepeatedly(
Invoke([this, &local_certinfo](const std::string& transport_name,
Invoke([&local_certinfo](const std::string& transport_name,
rtc::scoped_refptr<rtc::RTCCertificate>* certificate) {
if (transport_name == "transport") {
*certificate = local_certinfo->certificate;
@ -737,7 +737,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCCertificateStatsSingle) {
}));
EXPECT_CALL(test_->session(),
GetRemoteSSLCertificate_ReturnsRawPointer(_)).WillRepeatedly(Invoke(
[this, &remote_certinfo](const std::string& transport_name) {
[&remote_certinfo](const std::string& transport_name) {
if (transport_name == "transport")
return remote_certinfo->certificate->ssl_certificate().GetReference();
return static_cast<rtc::SSLCertificate*>(nullptr);
@ -892,14 +892,14 @@ TEST_F(RTCStatsCollectorTest, CollectRTCCertificateStatsMultiple) {
// Mock the session to return the local and remote certificates.
EXPECT_CALL(test_->session(), GetStats(_)).WillRepeatedly(Invoke(
[this](const ChannelNamePairs&) {
[](const ChannelNamePairs&) {
std::unique_ptr<SessionStats> stats(new SessionStats());
stats->transport_stats["audio"].transport_name = "audio";
stats->transport_stats["video"].transport_name = "video";
return stats;
}));
EXPECT_CALL(test_->session(), GetLocalCertificate(_, _)).WillRepeatedly(
Invoke([this, &audio_local_certinfo, &video_local_certinfo](
Invoke([&audio_local_certinfo, &video_local_certinfo](
const std::string& transport_name,
rtc::scoped_refptr<rtc::RTCCertificate>* certificate) {
if (transport_name == "audio") {
@ -914,7 +914,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCCertificateStatsMultiple) {
}));
EXPECT_CALL(test_->session(),
GetRemoteSSLCertificate_ReturnsRawPointer(_)).WillRepeatedly(Invoke(
[this, &audio_remote_certinfo, &video_remote_certinfo](
[&audio_remote_certinfo, &video_remote_certinfo](
const std::string& transport_name) {
if (transport_name == "audio") {
return audio_remote_certinfo->certificate->ssl_certificate()
@ -952,13 +952,13 @@ TEST_F(RTCStatsCollectorTest, CollectRTCCertificateStatsChain) {
// Mock the session to return the local and remote certificates.
EXPECT_CALL(test_->session(), GetStats(_)).WillRepeatedly(Invoke(
[this](const ChannelNamePairs&) {
[](const ChannelNamePairs&) {
std::unique_ptr<SessionStats> stats(new SessionStats());
stats->transport_stats["transport"].transport_name = "transport";
return stats;
}));
EXPECT_CALL(test_->session(), GetLocalCertificate(_, _)).WillRepeatedly(
Invoke([this, &local_certinfo](const std::string& transport_name,
Invoke([&local_certinfo](const std::string& transport_name,
rtc::scoped_refptr<rtc::RTCCertificate>* certificate) {
if (transport_name == "transport") {
*certificate = local_certinfo->certificate;
@ -968,7 +968,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCCertificateStatsChain) {
}));
EXPECT_CALL(test_->session(),
GetRemoteSSLCertificate_ReturnsRawPointer(_)).WillRepeatedly(Invoke(
[this, &remote_certinfo](const std::string& transport_name) {
[&remote_certinfo](const std::string& transport_name) {
if (transport_name == "transport")
return remote_certinfo->certificate->ssl_certificate().GetReference();
return static_cast<rtc::SSLCertificate*>(nullptr);
@ -2278,7 +2278,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCTransportStats) {
CreateFakeCertificateAndInfoFromDers(
std::vector<std::string>({ "(remote) local", "(remote) chain" }));
EXPECT_CALL(test_->session(), GetLocalCertificate(_, _)).WillRepeatedly(
Invoke([this, &local_certinfo](const std::string& transport_name,
Invoke([&local_certinfo](const std::string& transport_name,
rtc::scoped_refptr<rtc::RTCCertificate>* certificate) {
if (transport_name == "transport") {
*certificate = local_certinfo->certificate;
@ -2288,7 +2288,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCTransportStats) {
}));
EXPECT_CALL(test_->session(),
GetRemoteSSLCertificate_ReturnsRawPointer(_)).WillRepeatedly(Invoke(
[this, &remote_certinfo](const std::string& transport_name) {
[&remote_certinfo](const std::string& transport_name) {
if (transport_name == "transport")
return remote_certinfo->certificate->ssl_certificate().GetReference();
return static_cast<rtc::SSLCertificate*>(nullptr);

View File

@ -3264,7 +3264,7 @@ TEST_F(WebRtcSessionTest, TestIgnoreCandidatesForUnusedTransportWhenBundling) {
// Checks if one of the transport channels contains a connection using a given
// port.
auto connection_with_remote_port = [this, voice_channel](int port) {
auto connection_with_remote_port = [this](int port) {
std::unique_ptr<webrtc::SessionStats> stats = session_->GetStats_s();
for (auto& kv : stats->transport_stats) {
for (auto& chan_stat : kv.second.channel_stats) {

View File

@ -4278,9 +4278,13 @@ TEST_F(EndToEndTest, MAYBE_TestFlexfecRtpStatePreservation) {
rtc::CriticalSection crit_;
} observer;
constexpr int kFrameMaxWidth = 320;
constexpr int kFrameMaxHeight = 180;
constexpr int kFrameRate = 15;
// These would have been declared as constexpr, but then some compilers
// require them to be captured in the lambda, and other compilers complain
// about no-ununused-lambda-capture. Keeping them as normal variables was
// the easiest work-around.
int kFrameMaxWidth = 320;
int kFrameMaxHeight = 180;
int kFrameRate = 15;
Call::Config config(event_log_.get());

View File

@ -357,7 +357,7 @@ TEST_F(OveruseFrameDetectorTest, RunOnTqNormalUsage) {
event.Set();
}));
queue.PostTask([this, &event] {
queue.PostTask([this] {
const int kDelayUs1 = 5 * rtc::kNumMicrosecsPerMillisec;
const int kDelayUs2 = 6 * rtc::kNumMicrosecsPerMillisec;
InsertAndSendFramesWithInterval(1300, kFrameIntervalUs, kWidth, kHeight,