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}
This commit is contained in:
Mirko Bonadei
2021-07-08 20:08:20 +02:00
committed by WebRTC LUCI CQ
parent 9b5d570ae0
commit 25ab3228f3
82 changed files with 407 additions and 392 deletions

View File

@ -77,9 +77,9 @@ double MseInputOutput(const std::vector<int16_t>& input,
size_t num_samples,
size_t channels,
int delay) {
assert(delay < static_cast<int>(num_samples));
assert(num_samples <= input.size());
assert(num_samples * channels <= output.size());
RTC_DCHECK_LT(delay, static_cast<int>(num_samples));
RTC_DCHECK_LE(num_samples, input.size());
RTC_DCHECK_LE(num_samples * channels, output.size());
if (num_samples == 0)
return 0.0;
double squared_sum = 0.0;
@ -303,7 +303,7 @@ class AudioDecoderPcm16BTest : public AudioDecoderTest {
frame_size_ = 20 * codec_input_rate_hz_ / 1000;
data_length_ = 10 * frame_size_;
decoder_ = new AudioDecoderPcm16B(codec_input_rate_hz_, 1);
assert(decoder_);
RTC_DCHECK(decoder_);
AudioEncoderPcm16B::Config config;
config.sample_rate_hz = codec_input_rate_hz_;
config.frame_size_ms =
@ -320,7 +320,7 @@ class AudioDecoderIlbcTest : public AudioDecoderTest {
frame_size_ = 240;
data_length_ = 10 * frame_size_;
decoder_ = new AudioDecoderIlbcImpl;
assert(decoder_);
RTC_DCHECK(decoder_);
AudioEncoderIlbcConfig config;
config.frame_size_ms = 30;
audio_encoder_.reset(new AudioEncoderIlbcImpl(config, payload_type_));
@ -414,7 +414,7 @@ class AudioDecoderG722Test : public AudioDecoderTest {
frame_size_ = 160;
data_length_ = 10 * frame_size_;
decoder_ = new AudioDecoderG722Impl;
assert(decoder_);
RTC_DCHECK(decoder_);
AudioEncoderG722Config config;
config.frame_size_ms = 10;
config.num_channels = 1;
@ -430,7 +430,7 @@ class AudioDecoderG722StereoTest : public AudioDecoderTest {
frame_size_ = 160;
data_length_ = 10 * frame_size_;
decoder_ = new AudioDecoderG722StereoImpl;
assert(decoder_);
RTC_DCHECK(decoder_);
AudioEncoderG722Config config;
config.frame_size_ms = 10;
config.num_channels = 2;