Replace assert() with RTC_DCHECK().
CL partially auto-generated with:
git grep -l "\bassert(" | grep "\.[c|h]" | \
xargs sed -i 's/\bassert(/RTC_DCHECK(/g'
And with:
git grep -l "RTC_DCHECK(false)" | \
xargs sed -i 's/RTC_DCHECK(false)/RTC_NOTREACHED()/g'
With some manual changes to include "rtc_base/checks.h" where
needed.
A follow-up CL will remove assert() from Obj-C code as well
and remove the #include of <assert.h>.
The choice to replace with RTC_DCHECK is because assert()
is because RTC_DCHECK has similar behavior as assert()
based on NDEBUG.
This CL also contains manual changes to switch from
basic RTC_DCHECK to other (preferred) versions like
RTC_DCHECK_GT (and similar).
Bug: webrtc:6779
Change-Id: I00bed8886e03d685a2f42324e34aef2c9b7a63b0
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/224846
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34442}
diff --git a/modules/audio_coding/acm2/acm_send_test.cc b/modules/audio_coding/acm2/acm_send_test.cc
index 6f395d6..cda668d 100644
--- a/modules/audio_coding/acm2/acm_send_test.cc
+++ b/modules/audio_coding/acm2/acm_send_test.cc
@@ -51,8 +51,8 @@
input_frame_.sample_rate_hz_ = source_rate_hz_;
input_frame_.num_channels_ = 1;
input_frame_.samples_per_channel_ = input_block_size_samples_;
- assert(input_block_size_samples_ * input_frame_.num_channels_ <=
- AudioFrame::kMaxDataSizeSamples);
+ RTC_DCHECK_LE(input_block_size_samples_ * input_frame_.num_channels_,
+ AudioFrame::kMaxDataSizeSamples);
acm_->RegisterTransportCallback(this);
}
@@ -81,8 +81,8 @@
factory->MakeAudioEncoder(payload_type, format, absl::nullopt));
codec_registered_ = true;
input_frame_.num_channels_ = num_channels;
- assert(input_block_size_samples_ * input_frame_.num_channels_ <=
- AudioFrame::kMaxDataSizeSamples);
+ RTC_DCHECK_LE(input_block_size_samples_ * input_frame_.num_channels_,
+ AudioFrame::kMaxDataSizeSamples);
return codec_registered_;
}
@@ -90,13 +90,13 @@
std::unique_ptr<AudioEncoder> external_speech_encoder) {
input_frame_.num_channels_ = external_speech_encoder->NumChannels();
acm_->SetEncoder(std::move(external_speech_encoder));
- assert(input_block_size_samples_ * input_frame_.num_channels_ <=
- AudioFrame::kMaxDataSizeSamples);
+ RTC_DCHECK_LE(input_block_size_samples_ * input_frame_.num_channels_,
+ AudioFrame::kMaxDataSizeSamples);
codec_registered_ = true;
}
std::unique_ptr<Packet> AcmSendTestOldApi::NextPacket() {
- assert(codec_registered_);
+ RTC_DCHECK(codec_registered_);
if (filter_.test(static_cast<size_t>(payload_type_))) {
// This payload type should be filtered out. Since the payload type is the
// same throughout the whole test run, no packet at all will be delivered.
@@ -133,7 +133,7 @@
payload_type_ = payload_type;
timestamp_ = timestamp;
last_payload_vec_.assign(payload_data, payload_data + payload_len_bytes);
- assert(last_payload_vec_.size() == payload_len_bytes);
+ RTC_DCHECK_EQ(last_payload_vec_.size(), payload_len_bytes);
data_to_send_ = true;
return 0;
}