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-Original-Commit-Position: refs/heads/master@{#19297}
Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc
Cr-Mirrored-Commit: ee89e7870c332c943fb78faebc63e47d0a314d74
diff --git a/logging/rtc_event_log/rtc_event_log2stats.cc b/logging/rtc_event_log/rtc_event_log2stats.cc
index eb290b8..6b21cf1 100644
--- a/logging/rtc_event_log/rtc_event_log2stats.cc
+++ b/logging/rtc_event_log/rtc_event_log2stats.cc
@@ -54,7 +54,8 @@
if (stream.eof()) {
return std::make_pair(varint, false);
}
- RTC_DCHECK(0 <= byte && byte <= 255);
+ RTC_DCHECK_GE(byte, 0);
+ RTC_DCHECK_LE(byte, 255);
varint |= static_cast<uint64_t>(byte & 0x7F) << (7 * bytes_read);
if ((byte & 0x80) == 0) {
return std::make_pair(varint, true);
diff --git a/logging/rtc_event_log/rtc_event_log_parser.cc b/logging/rtc_event_log/rtc_event_log_parser.cc
index 8a8d8e3..a7237ee 100644
--- a/logging/rtc_event_log/rtc_event_log_parser.cc
+++ b/logging/rtc_event_log/rtc_event_log_parser.cc
@@ -104,7 +104,8 @@
if (stream.eof()) {
return std::make_pair(varint, false);
}
- RTC_DCHECK(0 <= byte && byte <= 255);
+ RTC_DCHECK_GE(byte, 0);
+ RTC_DCHECK_LE(byte, 255);
varint |= static_cast<uint64_t>(byte & 0x7F) << (7 * bytes_read);
if ((byte & 0x80) == 0) {
return std::make_pair(varint, true);
diff --git a/modules/audio_coding/codecs/cng/webrtc_cng.cc b/modules/audio_coding/codecs/cng/webrtc_cng.cc
index 9461cd0..b891d84 100644
--- a/modules/audio_coding/codecs/cng/webrtc_cng.cc
+++ b/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/modules/audio_coding/codecs/opus/audio_encoder_opus.cc b/modules/audio_coding/codecs/opus/audio_encoder_opus.cc
index 5b9a895..e94ea65 100644
--- a/modules/audio_coding/codecs/opus/audio_encoder_opus.cc
+++ b/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/modules/audio_device/dummy/file_audio_device_factory.cc b/modules/audio_device/dummy/file_audio_device_factory.cc
index bce6be4..9aeba20 100644
--- a/modules/audio_device/dummy/file_audio_device_factory.cc
+++ b/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/modules/audio_device/dummy/file_audio_device_factory.h b/modules/audio_device/dummy/file_audio_device_factory.h
index 250b7f6..6763e02 100644
--- a/modules/audio_device/dummy/file_audio_device_factory.h
+++ b/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/modules/audio_processing/transient/moving_moments.cc b/modules/audio_processing/transient/moving_moments.cc
index 5701a00..bca987f 100644
--- a/modules/audio_processing/transient/moving_moments.cc
+++ b/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/modules/desktop_capture/desktop_capturer_differ_wrapper.cc b/modules/desktop_capture/desktop_capturer_differ_wrapper.cc
index 9dbcd68..f3a846c 100644
--- a/modules/desktop_capture/desktop_capturer_differ_wrapper.cc
+++ b/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/modules/desktop_capture/desktop_frame_generator.cc b/modules/desktop_capture/desktop_frame_generator.cc
index 30a08f2..7bb5897 100644
--- a/modules/desktop_capture/desktop_frame_generator.cc
+++ b/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/modules/desktop_capture/win/dxgi_adapter_duplicator.cc b/modules/desktop_capture/win/dxgi_adapter_duplicator.cc
index c2a0794..4174dc9 100644
--- a/modules/desktop_capture/win/dxgi_adapter_duplicator.cc
+++ b/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/modules/desktop_capture/win/dxgi_output_duplicator.cc b/modules/desktop_capture/win/dxgi_output_duplicator.cc
index 21453b2..acb9c9d 100644
--- a/modules/desktop_capture/win/dxgi_output_duplicator.cc
+++ b/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/modules/desktop_capture/win/dxgi_texture.cc b/modules/desktop_capture/win/dxgi_texture.cc
index 964e00f..f9cfd82 100644
--- a/modules/desktop_capture/win/dxgi_texture.cc
+++ b/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/modules/desktop_capture/win/dxgi_texture_mapping.cc b/modules/desktop_capture/win/dxgi_texture_mapping.cc
index 90d8e89..66e5e75 100644
--- a/modules/desktop_capture/win/dxgi_texture_mapping.cc
+++ b/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/modules/desktop_capture/win/dxgi_texture_staging.cc b/modules/desktop_capture/win/dxgi_texture_staging.cc
index 48dc027..c4415ca 100644
--- a/modules/desktop_capture/win/dxgi_texture_staging.cc
+++ b/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/modules/rtp_rtcp/source/rtp_sender.cc b/modules/rtp_rtcp/source/rtp_sender.cc
index 024e028..89e7735 100644
--- a/modules/rtp_rtcp/source/rtp_sender.cc
+++ b/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/modules/video_coding/frame_object.cc b/modules/video_coding/frame_object.cc
index 25d0e29..1d858fc 100644
--- a/modules/video_coding/frame_object.cc
+++ b/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
diff --git a/p2p/base/p2ptransportchannel_unittest.cc b/p2p/base/p2ptransportchannel_unittest.cc
index 3ba2558..62fddb2 100644
--- a/p2p/base/p2ptransportchannel_unittest.cc
+++ b/p2p/base/p2ptransportchannel_unittest.cc
@@ -2179,7 +2179,8 @@
class P2PTransportChannelSameNatTest : public P2PTransportChannelTestBase {
protected:
void ConfigureEndpoints(Config nat_type, Config config1, Config config2) {
- RTC_CHECK(nat_type >= NAT_FULL_CONE && nat_type <= NAT_SYMMETRIC);
+ RTC_CHECK_GE(nat_type, NAT_FULL_CONE);
+ RTC_CHECK_LE(nat_type, NAT_SYMMETRIC);
rtc::NATSocketServer::Translator* outer_nat =
nat()->AddTranslator(kPublicAddrs[0], kNatAddrs[0],
static_cast<rtc::NATType>(nat_type - NAT_FULL_CONE));
diff --git a/p2p/client/basicportallocator.cc b/p2p/client/basicportallocator.cc
index ce95895..66ee9a4 100644
--- a/p2p/client/basicportallocator.cc
+++ b/p2p/client/basicportallocator.cc
@@ -1350,7 +1350,8 @@
// If BasicPortAllocatorSession::OnAllocate left relay ports enabled then we
// ought to have a relay list for them here.
- RTC_DCHECK(config_ && !config_->relays.empty());
+ RTC_DCHECK(config_);
+ RTC_DCHECK(!config_->relays.empty());
if (!(config_ && !config_->relays.empty())) {
LOG(LS_WARNING)
<< "AllocationSequence: No relay server configured, skipping.";
diff --git a/pc/datachannel.cc b/pc/datachannel.cc
index ce0aa14..28c090d 100644
--- a/pc/datachannel.cc
+++ b/pc/datachannel.cc
@@ -282,8 +282,9 @@
}
void DataChannel::SetSctpSid(int sid) {
- RTC_DCHECK(config_.id < 0 && sid >= 0 &&
- data_channel_type_ == cricket::DCT_SCTP);
+ RTC_DCHECK_LT(config_.id, 0);
+ RTC_DCHECK_GE(sid, 0);
+ RTC_DCHECK_EQ(data_channel_type_, cricket::DCT_SCTP);
if (config_.id == sid) {
return;
}
@@ -618,8 +619,10 @@
bool DataChannel::SendControlMessage(const rtc::CopyOnWriteBuffer& buffer) {
bool is_open_message = handshake_state_ == kHandshakeShouldSendOpen;
- RTC_DCHECK(data_channel_type_ == cricket::DCT_SCTP && writable_ &&
- config_.id >= 0 && (!is_open_message || !config_.negotiated));
+ RTC_DCHECK_EQ(data_channel_type_, cricket::DCT_SCTP);
+ RTC_DCHECK(writable_);
+ RTC_DCHECK_GE(config_.id, 0);
+ RTC_DCHECK(!is_open_message || !config_.negotiated);
cricket::SendDataParams send_params;
send_params.sid = config_.id;
diff --git a/pc/remoteaudiosource.cc b/pc/remoteaudiosource.cc
index 8d1a5d0..f6f23c3 100644
--- a/pc/remoteaudiosource.cc
+++ b/pc/remoteaudiosource.cc
@@ -96,7 +96,8 @@
}
void RemoteAudioSource::SetVolume(double volume) {
- RTC_DCHECK(volume >= 0 && volume <= 10);
+ RTC_DCHECK_GE(volume, 0);
+ RTC_DCHECK_LE(volume, 10);
for (auto* observer : audio_observers_)
observer->OnSetVolume(volume);
}
diff --git a/pc/rtpreceiver.cc b/pc/rtpreceiver.cc
index c6a2128..99c4010 100644
--- a/pc/rtpreceiver.cc
+++ b/pc/rtpreceiver.cc
@@ -53,7 +53,8 @@
}
void AudioRtpReceiver::OnSetVolume(double volume) {
- RTC_DCHECK(volume >= 0 && volume <= 10);
+ RTC_DCHECK_GE(volume, 0);
+ RTC_DCHECK_LE(volume, 10);
cached_volume_ = volume;
if (!channel_) {
LOG(LS_ERROR) << "AudioRtpReceiver::OnSetVolume: No audio channel exists.";
diff --git a/pc/rtpsender.cc b/pc/rtpsender.cc
index a16a28c..9d920e6 100644
--- a/pc/rtpsender.cc
+++ b/pc/rtpsender.cc
@@ -243,7 +243,8 @@
}
void AudioRtpSender::SetAudioSend() {
- RTC_DCHECK(!stopped_ && can_send_track());
+ RTC_DCHECK(!stopped_);
+ RTC_DCHECK(can_send_track());
if (!channel_) {
LOG(LS_ERROR) << "SetAudioSend: No audio channel exists.";
return;
@@ -430,7 +431,8 @@
}
void VideoRtpSender::SetVideoSend() {
- RTC_DCHECK(!stopped_ && can_send_track());
+ RTC_DCHECK(!stopped_);
+ RTC_DCHECK(can_send_track());
if (!channel_) {
LOG(LS_ERROR) << "SetVideoSend: No video channel exists.";
return;
diff --git a/pc/test/fakedatachannelprovider.h b/pc/test/fakedatachannelprovider.h
index 89bb987..ecc0aa6 100644
--- a/pc/test/fakedatachannelprovider.h
+++ b/pc/test/fakedatachannelprovider.h
@@ -26,7 +26,8 @@
bool SendData(const cricket::SendDataParams& params,
const rtc::CopyOnWriteBuffer& payload,
cricket::SendDataResult* result) override {
- RTC_CHECK(ready_to_send_ && transport_available_);
+ RTC_CHECK(ready_to_send_);
+ RTC_CHECK(transport_available_);
if (send_blocked_) {
*result = cricket::SDR_BLOCK;
return false;
diff --git a/pc/test/fakertccertificategenerator.h b/pc/test/fakertccertificategenerator.h
index 39b9107..7b47378 100644
--- a/pc/test/fakertccertificategenerator.h
+++ b/pc/test/fakertccertificategenerator.h
@@ -151,12 +151,12 @@
if (should_fail_) {
msg_id = MSG_FAILURE;
} else if (key_params.type() == rtc::KT_RSA) {
- RTC_DCHECK(key_params.rsa_params().mod_size == 1024 &&
- key_params.rsa_params().pub_exp == 0x10001);
+ RTC_DCHECK_EQ(key_params.rsa_params().mod_size, 1024);
+ RTC_DCHECK_EQ(key_params.rsa_params().pub_exp, 0x10001);
msg_id = MSG_SUCCESS_RSA;
} else {
- RTC_DCHECK(key_params.type() == rtc::KT_ECDSA &&
- key_params.ec_curve() == rtc::EC_NIST_P256);
+ RTC_DCHECK_EQ(key_params.type(), rtc::KT_ECDSA);
+ RTC_DCHECK_EQ(key_params.ec_curve(), rtc::EC_NIST_P256);
msg_id = MSG_SUCCESS_ECDSA;
}
rtc::Thread::Current()->Post(RTC_FROM_HERE, this, msg_id, msg);
diff --git a/rtc_base/macutils.cc b/rtc_base/macutils.cc
index 282f782..2e5e1fb 100644
--- a/rtc_base/macutils.cc
+++ b/rtc_base/macutils.cc
@@ -72,7 +72,9 @@
}
static bool GetOSVersion(int* major, int* minor, int* bugfix) {
- RTC_DCHECK(major && minor && bugfix);
+ RTC_DCHECK(major);
+ RTC_DCHECK(minor);
+ RTC_DCHECK(bugfix);
struct utsname uname_info;
if (uname(&uname_info) != 0)
return false;
diff --git a/rtc_base/opensslstreamadapter.cc b/rtc_base/opensslstreamadapter.cc
index 1c0b578..53f35fc 100644
--- a/rtc_base/opensslstreamadapter.cc
+++ b/rtc_base/opensslstreamadapter.cc
@@ -555,7 +555,8 @@
switch (ssl_error) {
case SSL_ERROR_NONE:
LOG(LS_VERBOSE) << " -- success";
- RTC_DCHECK(0 < code && static_cast<unsigned>(code) <= data_len);
+ RTC_DCHECK_GT(code, 0);
+ RTC_DCHECK_LE(code, data_len);
if (written)
*written = code;
return SR_SUCCESS;
@@ -619,7 +620,8 @@
switch (ssl_error) {
case SSL_ERROR_NONE:
LOG(LS_VERBOSE) << " -- success";
- RTC_DCHECK(0 < code && static_cast<unsigned>(code) <= data_len);
+ RTC_DCHECK_GT(code, 0);
+ RTC_DCHECK_LE(code, data_len);
if (read)
*read = code;
diff --git a/rtc_base/proxyserver.cc b/rtc_base/proxyserver.cc
index 18dceac..c00e243 100644
--- a/rtc_base/proxyserver.cc
+++ b/rtc_base/proxyserver.cc
@@ -43,7 +43,8 @@
}
void ProxyServer::OnAcceptEvent(AsyncSocket* socket) {
- RTC_DCHECK(socket != nullptr && socket == server_socket_.get());
+ RTC_DCHECK(socket);
+ RTC_DCHECK_EQ(socket, server_socket_.get());
AsyncSocket* int_socket = socket->Accept(nullptr);
AsyncProxyServerSocket* wrapped_socket = WrapSocket(int_socket);
AsyncSocket* ext_socket = ext_factory_->CreateAsyncSocket(ext_ip_.family(),
@@ -84,7 +85,8 @@
void ProxyBinding::OnConnectRequest(AsyncProxyServerSocket* socket,
const SocketAddress& addr) {
- RTC_DCHECK(!connected_ && ext_socket_.get() != nullptr);
+ RTC_DCHECK(!connected_);
+ RTC_DCHECK(ext_socket_);
ext_socket_->Connect(addr);
// TODO: handle errors here
}
diff --git a/rtc_base/socketaddress.cc b/rtc_base/socketaddress.cc
index 5b26b9f..8808414 100644
--- a/rtc_base/socketaddress.cc
+++ b/rtc_base/socketaddress.cc
@@ -9,6 +9,7 @@
*/
#include "webrtc/rtc_base/socketaddress.h"
+#include "webrtc/rtc_base/safe_conversions.h"
#if defined(WEBRTC_POSIX)
#include <sys/types.h>
@@ -120,8 +121,7 @@
}
void SocketAddress::SetPort(int port) {
- RTC_DCHECK((0 <= port) && (port < 65536));
- port_ = static_cast<uint16_t>(port);
+ port_ = rtc::dchecked_cast<uint16_t>(port);
}
uint32_t SocketAddress::ip() const {
diff --git a/voice_engine/channel.cc b/voice_engine/channel.cc
index 9158d36..5732e8e 100644
--- a/voice_engine/channel.cc
+++ b/voice_engine/channel.cc
@@ -2502,7 +2502,8 @@
RTC_DCHECK(rtp_packet_sender);
RTC_DCHECK(transport_feedback_observer);
- RTC_DCHECK(packet_router && !packet_router_);
+ RTC_DCHECK(packet_router);
+ RTC_DCHECK(!packet_router_);
rtcp_observer_->SetBandwidthObserver(bandwidth_observer);
feedback_observer_proxy_->SetTransportFeedbackObserver(
transport_feedback_observer);
@@ -2516,7 +2517,8 @@
void Channel::RegisterReceiverCongestionControlObjects(
PacketRouter* packet_router) {
- RTC_DCHECK(packet_router && !packet_router_);
+ RTC_DCHECK(packet_router);
+ RTC_DCHECK(!packet_router_);
constexpr bool remb_candidate = false;
packet_router->AddReceiveRtpModule(_rtpRtcpModule.get(), remb_candidate);
packet_router_ = packet_router;