Replace CHECK(x && y) with two separate CHECK() calls
That way, the debug printout will tell us which of x and y that was false.
BUG=none
Review-Url: https://codereview.webrtc.org/2988153003
Cr-Commit-Position: refs/heads/master@{#19297}
diff --git a/webrtc/modules/audio_coding/codecs/cng/webrtc_cng.cc b/webrtc/modules/audio_coding/codecs/cng/webrtc_cng.cc
index 9461cd0..b891d84 100644
--- a/webrtc/modules/audio_coding/codecs/cng/webrtc_cng.cc
+++ b/webrtc/modules/audio_coding/codecs/cng/webrtc_cng.cc
@@ -218,13 +218,15 @@
enc_reflCoefs_{0},
enc_corrVector_{0},
enc_seed_(7777) /* For debugging only. */ {
- RTC_CHECK(quality <= WEBRTC_CNG_MAX_LPC_ORDER && quality > 0);
+ RTC_CHECK_GT(quality, 0);
+ RTC_CHECK_LE(quality, WEBRTC_CNG_MAX_LPC_ORDER);
/* Needed to get the right function pointers in SPLIB. */
WebRtcSpl_Init();
}
void ComfortNoiseEncoder::Reset(int fs, int interval, int quality) {
- RTC_CHECK(quality <= WEBRTC_CNG_MAX_LPC_ORDER && quality > 0);
+ RTC_CHECK_GT(quality, 0);
+ RTC_CHECK_LE(quality, WEBRTC_CNG_MAX_LPC_ORDER);
enc_nrOfCoefs_ = quality;
enc_sampfreq_ = fs;
enc_interval_ = interval;
diff --git a/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc b/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc
index 5b9a895..e94ea65 100644
--- a/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc
+++ b/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc
@@ -391,7 +391,8 @@
? std::move(bitrate_smoother) : std::unique_ptr<SmoothingFilter>(
// We choose 5sec as initial time constant due to empirical data.
new SmoothingFilterImpl(5000))) {
- RTC_DCHECK(0 <= payload_type && payload_type <= 127);
+ RTC_DCHECK_GE(payload_type, 0);
+ RTC_DCHECK_LE(payload_type, 127);
// Sanity check of the redundant payload type field that we want to get rid
// of. See https://bugs.chromium.org/p/webrtc/issues/detail?id=7847
diff --git a/webrtc/modules/audio_device/dummy/file_audio_device_factory.cc b/webrtc/modules/audio_device/dummy/file_audio_device_factory.cc
index bce6be4..9aeba20 100644
--- a/webrtc/modules/audio_device/dummy/file_audio_device_factory.cc
+++ b/webrtc/modules/audio_device/dummy/file_audio_device_factory.cc
@@ -39,8 +39,8 @@
void FileAudioDeviceFactory::SetFilenamesToUse(
const char* inputAudioFilename, const char* outputAudioFilename) {
#ifdef WEBRTC_DUMMY_FILE_DEVICES
- RTC_DCHECK(strlen(inputAudioFilename) < MAX_FILENAME_LEN &&
- strlen(outputAudioFilename) < MAX_FILENAME_LEN);
+ RTC_DCHECK_LT(strlen(inputAudioFilename), MAX_FILENAME_LEN);
+ RTC_DCHECK_LT(strlen(outputAudioFilename), MAX_FILENAME_LEN);
// Copy the strings since we don't know the lifetime of the input pointers.
strncpy(_inputAudioFilename, inputAudioFilename, MAX_FILENAME_LEN);
diff --git a/webrtc/modules/audio_device/dummy/file_audio_device_factory.h b/webrtc/modules/audio_device/dummy/file_audio_device_factory.h
index 250b7f6..6763e02 100644
--- a/webrtc/modules/audio_device/dummy/file_audio_device_factory.h
+++ b/webrtc/modules/audio_device/dummy/file_audio_device_factory.h
@@ -31,7 +31,7 @@
const char* outputAudioFilename);
private:
- static const uint32_t MAX_FILENAME_LEN = 512;
+ enum : uint32_t { MAX_FILENAME_LEN = 512 };
static bool _isConfigured;
static char _inputAudioFilename[MAX_FILENAME_LEN];
static char _outputAudioFilename[MAX_FILENAME_LEN];
diff --git a/webrtc/modules/audio_processing/transient/moving_moments.cc b/webrtc/modules/audio_processing/transient/moving_moments.cc
index 5701a00..bca987f 100644
--- a/webrtc/modules/audio_processing/transient/moving_moments.cc
+++ b/webrtc/modules/audio_processing/transient/moving_moments.cc
@@ -32,7 +32,10 @@
void MovingMoments::CalculateMoments(const float* in, size_t in_length,
float* first, float* second) {
- RTC_DCHECK(in && in_length > 0 && first && second);
+ RTC_DCHECK(in);
+ RTC_DCHECK_GT(in_length, 0);
+ RTC_DCHECK(first);
+ RTC_DCHECK(second);
for (size_t i = 0; i < in_length; ++i) {
const float old_value = queue_.front();
diff --git a/webrtc/modules/desktop_capture/desktop_capturer_differ_wrapper.cc b/webrtc/modules/desktop_capture/desktop_capturer_differ_wrapper.cc
index 9dbcd68..f3a846c 100644
--- a/webrtc/modules/desktop_capture/desktop_capturer_differ_wrapper.cc
+++ b/webrtc/modules/desktop_capture/desktop_capturer_differ_wrapper.cc
@@ -61,7 +61,8 @@
const int height = bottom - top;
const int block_count = (width - 1) / kBlockSize;
const int last_block_width = width - block_count * kBlockSize;
- RTC_DCHECK(last_block_width <= kBlockSize && last_block_width > 0);
+ RTC_DCHECK_GT(last_block_width, 0);
+ RTC_DCHECK_LE(last_block_width, kBlockSize);
// The first block-column in a continuous dirty area in current block-row.
int first_dirty_x_block = -1;
diff --git a/webrtc/modules/desktop_capture/desktop_frame_generator.cc b/webrtc/modules/desktop_capture/desktop_frame_generator.cc
index 30a08f2..7bb5897 100644
--- a/webrtc/modules/desktop_capture/desktop_frame_generator.cc
+++ b/webrtc/modules/desktop_capture/desktop_frame_generator.cc
@@ -64,8 +64,8 @@
void PaintRect(DesktopFrame* frame, DesktopRect rect, RgbaColor rgba_color) {
static_assert(DesktopFrame::kBytesPerPixel == sizeof(uint32_t),
"kBytesPerPixel should be 4.");
- RTC_DCHECK(frame->size().width() >= rect.right() &&
- frame->size().height() >= rect.bottom());
+ RTC_DCHECK_GE(frame->size().width(), rect.right());
+ RTC_DCHECK_GE(frame->size().height(), rect.bottom());
uint32_t color = rgba_color.ToUInt32();
uint8_t* row = frame->GetFrameDataAtPos(rect.top_left());
for (int i = 0; i < rect.height(); i++) {
diff --git a/webrtc/modules/desktop_capture/win/dxgi_adapter_duplicator.cc b/webrtc/modules/desktop_capture/win/dxgi_adapter_duplicator.cc
index c2a0794..4174dc9 100644
--- a/webrtc/modules/desktop_capture/win/dxgi_adapter_duplicator.cc
+++ b/webrtc/modules/desktop_capture/win/dxgi_adapter_duplicator.cc
@@ -134,20 +134,22 @@
bool DxgiAdapterDuplicator::DuplicateMonitor(Context* context,
int monitor_id,
SharedDesktopFrame* target) {
- RTC_DCHECK(monitor_id >= 0 &&
- monitor_id < static_cast<int>(duplicators_.size()) &&
- context->contexts.size() == duplicators_.size());
+ RTC_DCHECK_GE(monitor_id, 0);
+ RTC_DCHECK_LT(monitor_id, duplicators_.size());
+ RTC_DCHECK_EQ(context->contexts.size(), duplicators_.size());
return duplicators_[monitor_id].Duplicate(&context->contexts[monitor_id],
DesktopVector(), target);
}
DesktopRect DxgiAdapterDuplicator::ScreenRect(int id) const {
- RTC_DCHECK(id >= 0 && id < static_cast<int>(duplicators_.size()));
+ RTC_DCHECK_GE(id, 0);
+ RTC_DCHECK_LT(id, duplicators_.size());
return duplicators_[id].desktop_rect();
}
const std::string& DxgiAdapterDuplicator::GetDeviceName(int id) const {
- RTC_DCHECK(id >= 0 && id < static_cast<int>(duplicators_.size()));
+ RTC_DCHECK_GE(id, 0);
+ RTC_DCHECK_LT(id, duplicators_.size());
return duplicators_[id].device_name();
}
@@ -166,7 +168,8 @@
void DxgiAdapterDuplicator::TranslateRect(const DesktopVector& position) {
desktop_rect_.Translate(position);
- RTC_DCHECK(desktop_rect_.left() >= 0 && desktop_rect_.top() >= 0);
+ RTC_DCHECK_GE(desktop_rect_.left(), 0);
+ RTC_DCHECK_GE(desktop_rect_.top(), 0);
for (auto& duplicator : duplicators_) {
duplicator.TranslateRect(position);
}
diff --git a/webrtc/modules/desktop_capture/win/dxgi_output_duplicator.cc b/webrtc/modules/desktop_capture/win/dxgi_output_duplicator.cc
index 21453b2..acb9c9d 100644
--- a/webrtc/modules/desktop_capture/win/dxgi_output_duplicator.cc
+++ b/webrtc/modules/desktop_capture/win/dxgi_output_duplicator.cc
@@ -69,7 +69,8 @@
desktop_rect_(RECTToDesktopRect(desc.DesktopCoordinates)) {
RTC_DCHECK(output_);
RTC_DCHECK(!desktop_rect_.is_empty());
- RTC_DCHECK(desktop_rect_.width() > 0 && desktop_rect_.height() > 0);
+ RTC_DCHECK_GT(desktop_rect_.width(), 0);
+ RTC_DCHECK_GT(desktop_rect_.height(), 0);
}
DxgiOutputDuplicator::DxgiOutputDuplicator(DxgiOutputDuplicator&& other) =
@@ -385,7 +386,8 @@
void DxgiOutputDuplicator::TranslateRect(const DesktopVector& position) {
desktop_rect_.Translate(position);
- RTC_DCHECK(desktop_rect_.left() >= 0 && desktop_rect_.top() >= 0);
+ RTC_DCHECK_GE(desktop_rect_.left(), 0);
+ RTC_DCHECK_GE(desktop_rect_.top(), 0);
}
} // namespace webrtc
diff --git a/webrtc/modules/desktop_capture/win/dxgi_texture.cc b/webrtc/modules/desktop_capture/win/dxgi_texture.cc
index 964e00f..f9cfd82 100644
--- a/webrtc/modules/desktop_capture/win/dxgi_texture.cc
+++ b/webrtc/modules/desktop_capture/win/dxgi_texture.cc
@@ -42,7 +42,8 @@
bool DxgiTexture::CopyFrom(const DXGI_OUTDUPL_FRAME_INFO& frame_info,
IDXGIResource* resource) {
- RTC_DCHECK(resource && frame_info.AccumulatedFrames > 0);
+ RTC_DCHECK_GT(frame_info.AccumulatedFrames, 0);
+ RTC_DCHECK(resource);
ComPtr<ID3D11Texture2D> texture;
_com_error error = resource->QueryInterface(
__uuidof(ID3D11Texture2D),
diff --git a/webrtc/modules/desktop_capture/win/dxgi_texture_mapping.cc b/webrtc/modules/desktop_capture/win/dxgi_texture_mapping.cc
index 90d8e89..66e5e75 100644
--- a/webrtc/modules/desktop_capture/win/dxgi_texture_mapping.cc
+++ b/webrtc/modules/desktop_capture/win/dxgi_texture_mapping.cc
@@ -29,7 +29,8 @@
bool DxgiTextureMapping::CopyFromTexture(
const DXGI_OUTDUPL_FRAME_INFO& frame_info,
ID3D11Texture2D* texture) {
- RTC_DCHECK(texture && frame_info.AccumulatedFrames > 0);
+ RTC_DCHECK_GT(frame_info.AccumulatedFrames, 0);
+ RTC_DCHECK(texture);
*rect() = {0};
_com_error error = duplication_->MapDesktopSurface(rect());
if (error.Error() != S_OK) {
diff --git a/webrtc/modules/desktop_capture/win/dxgi_texture_staging.cc b/webrtc/modules/desktop_capture/win/dxgi_texture_staging.cc
index 48dc027..c4415ca 100644
--- a/webrtc/modules/desktop_capture/win/dxgi_texture_staging.cc
+++ b/webrtc/modules/desktop_capture/win/dxgi_texture_staging.cc
@@ -87,7 +87,8 @@
bool DxgiTextureStaging::CopyFromTexture(
const DXGI_OUTDUPL_FRAME_INFO& frame_info,
ID3D11Texture2D* texture) {
- RTC_DCHECK(texture && frame_info.AccumulatedFrames > 0);
+ RTC_DCHECK_GT(frame_info.AccumulatedFrames, 0);
+ RTC_DCHECK(texture);
// AcquireNextFrame returns a CPU inaccessible IDXGIResource, so we need to
// copy it to a CPU accessible staging ID3D11Texture2D.
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_sender.cc b/webrtc/modules/rtp_rtcp/source/rtp_sender.cc
index 024e028..89e7735 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_sender.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_sender.cc
@@ -288,9 +288,8 @@
}
void RTPSender::SetMaxRtpPacketSize(size_t max_packet_size) {
- // Sanity check.
- RTC_DCHECK(max_packet_size >= 100 && max_packet_size <= IP_PACKET_SIZE)
- << "Invalid max payload length: " << max_packet_size;
+ RTC_DCHECK_GE(max_packet_size, 100);
+ RTC_DCHECK_LE(max_packet_size, IP_PACKET_SIZE);
rtc::CritScope lock(&send_critsect_);
max_packet_size_ = max_packet_size;
}
diff --git a/webrtc/modules/video_coding/frame_object.cc b/webrtc/modules/video_coding/frame_object.cc
index 25d0e29..1d858fc 100644
--- a/webrtc/modules/video_coding/frame_object.cc
+++ b/webrtc/modules/video_coding/frame_object.cc
@@ -102,7 +102,8 @@
timestamp = first_packet->timestamp;
VCMPacket* last_packet = packet_buffer_->GetPacket(last_seq_num);
- RTC_CHECK(last_packet && last_packet->markerBit);
+ RTC_CHECK(last_packet);
+ RTC_CHECK(last_packet->markerBit);
// http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/
// ts_126114v120700p.pdf Section 7.4.5.
// The MTSI client shall add the payload bytes as defined in this clause