diff --git a/webrtc/base/asyncsocket.h b/webrtc/base/asyncsocket.h index 5dbffb966c..bf6c88aa39 100644 --- a/webrtc/base/asyncsocket.h +++ b/webrtc/base/asyncsocket.h @@ -11,7 +11,6 @@ #ifndef WEBRTC_BASE_ASYNCSOCKET_H_ #define WEBRTC_BASE_ASYNCSOCKET_H_ -#include "webrtc/base/common.h" #include "webrtc/base/sigslot.h" #include "webrtc/base/socket.h" diff --git a/webrtc/base/diskcache.cc b/webrtc/base/diskcache.cc index 4b3ec5feff..2747018d17 100644 --- a/webrtc/base/diskcache.cc +++ b/webrtc/base/diskcache.cc @@ -26,11 +26,7 @@ #include "webrtc/base/stringencode.h" #include "webrtc/base/stringutils.h" -#if !defined(NDEBUG) -#define TRANSPARENT_CACHE_NAMES 1 -#else -#define TRANSPARENT_CACHE_NAMES 0 -#endif +#define TRANSPARENT_CACHE_NAMES RTC_DCHECK_IS_ON namespace rtc { @@ -214,7 +210,7 @@ bool DiskCache::DeleteResource(const std::string& id) { } bool DiskCache::CheckLimit() { -#if !defined(NDEBUG) +#if RTC_DCHECK_IS_ON // Temporary check to make sure everything is working correctly. size_t cache_size = 0; for (EntryMap::iterator it = map_.begin(); it != map_.end(); ++it) { diff --git a/webrtc/base/httpclient.cc b/webrtc/base/httpclient.cc index c30b82f3ba..e65eb9e80c 100644 --- a/webrtc/base/httpclient.cc +++ b/webrtc/base/httpclient.cc @@ -13,6 +13,7 @@ #include #include "webrtc/base/asyncsocket.h" #include "webrtc/base/checks.h" +#include "webrtc/base/common.h" #include "webrtc/base/diskcache.h" #include "webrtc/base/httpclient.h" #include "webrtc/base/httpcommon-inl.h" diff --git a/webrtc/base/httpcommon.cc b/webrtc/base/httpcommon.cc index 389bca2aa1..3d46ab2770 100644 --- a/webrtc/base/httpcommon.cc +++ b/webrtc/base/httpcommon.cc @@ -679,37 +679,6 @@ HttpResponseData::parseLeader(const char* line, size_t len) { // Http Authentication ////////////////////////////////////////////////////////////////////// -#define TEST_DIGEST 0 -#if TEST_DIGEST -/* -const char * const DIGEST_CHALLENGE = - "Digest realm=\"testrealm@host.com\"," - " qop=\"auth,auth-int\"," - " nonce=\"dcd98b7102dd2f0e8b11d0f600bfb0c093\"," - " opaque=\"5ccc069c403ebaf9f0171e9517f40e41\""; -const char * const DIGEST_METHOD = "GET"; -const char * const DIGEST_URI = - "/dir/index.html";; -const char * const DIGEST_CNONCE = - "0a4f113b"; -const char * const DIGEST_RESPONSE = - "6629fae49393a05397450978507c4ef1"; -//user_ = "Mufasa"; -//pass_ = "Circle Of Life"; -*/ -const char * const DIGEST_CHALLENGE = - "Digest realm=\"Squid proxy-caching web server\"," - " nonce=\"Nny4QuC5PwiSDixJ\"," - " qop=\"auth\"," - " stale=false"; -const char * const DIGEST_URI = - "/"; -const char * const DIGEST_CNONCE = - "6501d58e9a21cee1e7b5fec894ded024"; -const char * const DIGEST_RESPONSE = - "edffcb0829e755838b073a4a42de06bc"; -#endif - std::string quote(const std::string& str) { std::string result; result.push_back('"'); @@ -748,11 +717,6 @@ HttpAuthResult HttpAuthenticate( const std::string& username, const CryptString& password, HttpAuthContext *& context, std::string& response, std::string& auth_method) { -#if TEST_DIGEST - challenge = DIGEST_CHALLENGE; - len = strlen(challenge); -#endif - HttpAttributeList args; HttpParseAttributes(challenge, len, args); HttpHasNthAttribute(args, 0, &auth_method, NULL); @@ -796,15 +760,9 @@ HttpAuthResult HttpAuthenticate( context = new HttpAuthContext(auth_method); std::string cnonce, ncount; -#if TEST_DIGEST - method = DIGEST_METHOD; - uri = DIGEST_URI; - cnonce = DIGEST_CNONCE; -#else char buffer[256]; sprintf(buffer, "%d", static_cast(time(0))); cnonce = MD5(buffer); -#endif ncount = "00000001"; std::string realm, nonce, qop, opaque; @@ -837,10 +795,6 @@ HttpAuthResult HttpAuthenticate( std::string HA2 = MD5(A2); std::string dig_response = MD5(HA1 + ":" + middle + ":" + HA2); -#if TEST_DIGEST - RTC_DCHECK(strcmp(dig_response.c_str(), DIGEST_RESPONSE) == 0); -#endif - std::stringstream ss; ss << auth_method; ss << " username=" << quote(username); diff --git a/webrtc/base/httpserver.cc b/webrtc/base/httpserver.cc index e5fb69ccbb..6594581aec 100644 --- a/webrtc/base/httpserver.cc +++ b/webrtc/base/httpserver.cc @@ -14,6 +14,7 @@ #include "webrtc/base/asyncsocket.h" #include "webrtc/base/checks.h" +#include "webrtc/base/common.h" #include "webrtc/base/httpserver.h" #include "webrtc/base/logging.h" #include "webrtc/base/socketstream.h" diff --git a/webrtc/base/network_unittest.cc b/webrtc/base/network_unittest.cc index 2c05b059cc..27dab48195 100644 --- a/webrtc/base/network_unittest.cc +++ b/webrtc/base/network_unittest.cc @@ -104,7 +104,7 @@ class NetworkTest : public testing::Test, public sigslot::has_slots<> { AdapterType GetAdapterType(BasicNetworkManager& network_manager) { BasicNetworkManager::NetworkList list; network_manager.GetNetworks(&list); - RTC_CHECK(list.size() == 1u); + RTC_CHECK_EQ(1, list.size()); return list[0]->type(); } diff --git a/webrtc/base/openssladapter.cc b/webrtc/base/openssladapter.cc index 5556ce233e..d368186186 100644 --- a/webrtc/base/openssladapter.cc +++ b/webrtc/base/openssladapter.cc @@ -27,6 +27,7 @@ #include "webrtc/base/arraysize.h" #include "webrtc/base/checks.h" +#include "webrtc/base/common.h" #include "webrtc/base/logging.h" #include "webrtc/base/openssl.h" #include "webrtc/base/safe_conversions.h" diff --git a/webrtc/base/opensslstreamadapter.cc b/webrtc/base/opensslstreamadapter.cc index 0057ce1bf5..6ff7fd584b 100644 --- a/webrtc/base/opensslstreamadapter.cc +++ b/webrtc/base/opensslstreamadapter.cc @@ -25,6 +25,7 @@ #include #include "webrtc/base/checks.h" +#include "webrtc/base/common.h" #include "webrtc/base/logging.h" #include "webrtc/base/safe_conversions.h" #include "webrtc/base/stream.h" diff --git a/webrtc/base/physicalsocketserver.cc b/webrtc/base/physicalsocketserver.cc index 3b395ce63c..6970388844 100644 --- a/webrtc/base/physicalsocketserver.cc +++ b/webrtc/base/physicalsocketserver.cc @@ -138,7 +138,9 @@ PhysicalSocket::PhysicalSocket(PhysicalSocketServer* ss, SOCKET s) int type = SOCK_STREAM; socklen_t len = sizeof(type); - VERIFY(0 == getsockopt(s_, SOL_SOCKET, SO_TYPE, (SockOptArg)&type, &len)); + const int res = + getsockopt(s_, SOL_SOCKET, SO_TYPE, (SockOptArg)&type, &len); + RTC_DCHECK_EQ(0, res); udp_ = (SOCK_DGRAM == type); } } @@ -834,9 +836,9 @@ class EventDispatcher : public Dispatcher { CritScope cs(&crit_); if (!fSignaled_) { const uint8_t b[1] = {0}; - if (VERIFY(1 == write(afd_[1], b, sizeof(b)))) { - fSignaled_ = true; - } + const ssize_t res = write(afd_[1], b, sizeof(b)); + RTC_DCHECK_EQ(1, res); + fSignaled_ = true; } } @@ -849,7 +851,8 @@ class EventDispatcher : public Dispatcher { CritScope cs(&crit_); if (fSignaled_) { uint8_t b[4]; // Allow for reading more than 1 byte, but expect 1. - VERIFY(1 == read(afd_[0], b, sizeof(b))); + const ssize_t res = read(afd_[0], b, sizeof(b)); + RTC_DCHECK_EQ(1, res); fSignaled_ = false; } } diff --git a/webrtc/base/proxydetect.cc b/webrtc/base/proxydetect.cc index 83596b5669..b0fa30488a 100644 --- a/webrtc/base/proxydetect.cc +++ b/webrtc/base/proxydetect.cc @@ -34,6 +34,7 @@ #include "webrtc/base/arraysize.h" #include "webrtc/base/checks.h" +#include "webrtc/base/common.h" #include "webrtc/base/fileutils.h" #include "webrtc/base/httpcommon.h" #include "webrtc/base/httpcommon-inl.h" diff --git a/webrtc/base/signalthread.h b/webrtc/base/signalthread.h index befb02fb5b..a91e4ad34a 100644 --- a/webrtc/base/signalthread.h +++ b/webrtc/base/signalthread.h @@ -125,7 +125,7 @@ class SignalThread t_->cs_.Enter(); // If refcount_ is zero then the object has already been deleted and we // will be double-deleting it in ~EnterExit()! (shouldn't happen) - RTC_DCHECK(t_->refcount_ != 0); + RTC_DCHECK_NE(0, t_->refcount_); ++t_->refcount_; } ~EnterExit() UNLOCK_FUNCTION() { diff --git a/webrtc/base/socketadapters.cc b/webrtc/base/socketadapters.cc index 0a94982613..f6029ce964 100644 --- a/webrtc/base/socketadapters.cc +++ b/webrtc/base/socketadapters.cc @@ -185,8 +185,8 @@ int AsyncSSLSocket::Connect(const SocketAddress& addr) { void AsyncSSLSocket::OnConnectEvent(AsyncSocket * socket) { RTC_DCHECK(socket == socket_); // TODO: we could buffer output too... - VERIFY(sizeof(kSslClientHello) == - DirectSend(kSslClientHello, sizeof(kSslClientHello))); + const int res = DirectSend(kSslClientHello, sizeof(kSslClientHello)); + RTC_DCHECK_EQ(sizeof(kSslClientHello), res); } void AsyncSSLSocket::ProcessInput(char* data, size_t* len) { diff --git a/webrtc/base/sslstreamadapter_unittest.cc b/webrtc/base/sslstreamadapter_unittest.cc index 82036913e0..737118aa2b 100644 --- a/webrtc/base/sslstreamadapter_unittest.cc +++ b/webrtc/base/sslstreamadapter_unittest.cc @@ -377,7 +377,9 @@ class SSLStreamAdapterTestBase : public testing::Test, // Make sure we simulate a reliable network for TLS. // This is just a check to make sure that people don't write wrong // tests. - RTC_CHECK((mtu_ == 1460) && (loss_ == 0) && (lose_first_packet_ == 0)); + RTC_CHECK_EQ(1460, mtu_); + RTC_CHECK(!loss_); + RTC_CHECK(!lose_first_packet_); } if (!identities_set_) @@ -414,7 +416,9 @@ class SSLStreamAdapterTestBase : public testing::Test, // Make sure we simulate a reliable network for TLS. // This is just a check to make sure that people don't write wrong // tests. - RTC_CHECK((mtu_ == 1460) && (loss_ == 0) && (lose_first_packet_ == 0)); + RTC_CHECK_EQ(1460, mtu_); + RTC_CHECK(!loss_); + RTC_CHECK(!lose_first_packet_); } // Start the handshake diff --git a/webrtc/base/win32window.cc b/webrtc/base/win32window.cc index daa7688554..9abbc86807 100644 --- a/webrtc/base/win32window.cc +++ b/webrtc/base/win32window.cc @@ -9,7 +9,6 @@ */ #include "webrtc/base/checks.h" -#include "webrtc/base/common.h" #include "webrtc/base/logging.h" #include "webrtc/base/win32window.h" @@ -65,7 +64,8 @@ bool Win32Window::Create(HWND parent, const wchar_t* title, DWORD style, } void Win32Window::Destroy() { - VERIFY(::DestroyWindow(wnd_) != FALSE); + const bool success = ::DestroyWindow(wnd_); + RTC_DCHECK(success); } void Win32Window::Shutdown() { diff --git a/webrtc/examples/peerconnection/client/peer_connection_client.cc b/webrtc/examples/peerconnection/client/peer_connection_client.cc index 5cdce087c1..ab9cd328ba 100644 --- a/webrtc/examples/peerconnection/client/peer_connection_client.cc +++ b/webrtc/examples/peerconnection/client/peer_connection_client.cc @@ -238,7 +238,6 @@ void PeerConnectionClient::OnConnect(rtc::AsyncSocket* socket) { RTC_DCHECK(!onconnect_data_.empty()); size_t sent = socket->Send(onconnect_data_.c_str(), onconnect_data_.length()); RTC_DCHECK(sent == onconnect_data_.length()); - RTC_UNUSED(sent); onconnect_data_.clear(); } @@ -249,7 +248,6 @@ void PeerConnectionClient::OnHangingGetConnect(rtc::AsyncSocket* socket) { int len = static_cast(strlen(buffer)); int sent = socket->Send(buffer, len); RTC_DCHECK(sent == len); - RTC_UNUSED2(sent, len); } void PeerConnectionClient::OnMessageFromPeer(int peer_id, diff --git a/webrtc/media/base/fakemediaengine.h b/webrtc/media/base/fakemediaengine.h index 11909659ea..2b774b2bb9 100644 --- a/webrtc/media/base/fakemediaengine.h +++ b/webrtc/media/base/fakemediaengine.h @@ -469,7 +469,7 @@ class FakeVoiceMediaChannel : public RtpHelper { auto it = local_sinks_.find(ssrc); if (source) { if (it != local_sinks_.end()) { - RTC_DCHECK(it->second->source() == source); + RTC_CHECK(it->second->source() == source); } else { local_sinks_.insert( std::make_pair(ssrc, new VoiceChannelAudioSink(source))); diff --git a/webrtc/media/engine/fakewebrtcvoiceengine.h b/webrtc/media/engine/fakewebrtcvoiceengine.h index 5f61cf1143..3b992f1e2c 100644 --- a/webrtc/media/engine/fakewebrtcvoiceengine.h +++ b/webrtc/media/engine/fakewebrtcvoiceengine.h @@ -332,7 +332,7 @@ class FakeWebRtcVoiceEngine } bool GetNetEqFastAccelerate() const { auto ch = channels_.find(last_channel_); - RTC_DCHECK(ch != channels_.end()); + RTC_CHECK(ch != channels_.end()); return ch->second->neteq_fast_accelerate; } diff --git a/webrtc/media/engine/webrtcvoe.h b/webrtc/media/engine/webrtcvoe.h index 41a5b5fe6a..6884aa4ea3 100644 --- a/webrtc/media/engine/webrtcvoe.h +++ b/webrtc/media/engine/webrtcvoe.h @@ -13,7 +13,6 @@ #include -#include "webrtc/base/common.h" #include "webrtc/media/engine/webrtccommon.h" #include "webrtc/common_types.h" @@ -30,12 +29,18 @@ namespace cricket { class scoped_voe_engine { public: explicit scoped_voe_engine(webrtc::VoiceEngine* e) : ptr(e) {} - // VERIFY, to ensure that there are no leaks at shutdown - ~scoped_voe_engine() { if (ptr) VERIFY(webrtc::VoiceEngine::Delete(ptr)); } + // RTC_DCHECK, to ensure that there are no leaks at shutdown + ~scoped_voe_engine() { + if (ptr) { + const bool success = webrtc::VoiceEngine::Delete(ptr); + RTC_DCHECK(success); + } + } // Releases the current pointer. void reset() { if (ptr) { - VERIFY(webrtc::VoiceEngine::Delete(ptr)); + const bool success = webrtc::VoiceEngine::Delete(ptr); + RTC_DCHECK(success); ptr = NULL; } } diff --git a/webrtc/p2p/base/candidate.h b/webrtc/p2p/base/candidate.h index 992f492617..5073aeb322 100644 --- a/webrtc/p2p/base/candidate.h +++ b/webrtc/p2p/base/candidate.h @@ -149,7 +149,7 @@ class Candidate { // cost of 0 indicates this candidate can be used freely. A value of // rtc::kNetworkCostMax indicates it should be used only as the last resort. void set_network_cost(uint16_t network_cost) { - RTC_DCHECK(network_cost <= rtc::kNetworkCostMax); + RTC_DCHECK_LE(network_cost, rtc::kNetworkCostMax); network_cost_ = network_cost; } uint16_t network_cost() const { return network_cost_; } diff --git a/webrtc/p2p/base/dtlstransportchannel.cc b/webrtc/p2p/base/dtlstransportchannel.cc index 575ec327b9..0359954a11 100644 --- a/webrtc/p2p/base/dtlstransportchannel.cc +++ b/webrtc/p2p/base/dtlstransportchannel.cc @@ -354,7 +354,8 @@ bool DtlsTransport::SetSrtpCryptoSuites(const std::vector& ciphers) { return true; } - if (!VERIFY(dtls_state() == DTLS_TRANSPORT_NEW)) { + if (dtls_state() != DTLS_TRANSPORT_NEW) { + LOG(LS_ERROR) << "Can't set SRTP ciphers for a closed session"; return false; } diff --git a/webrtc/p2p/base/turnport.cc b/webrtc/p2p/base/turnport.cc index 9ecc75ea28..7e0e64d6ed 100644 --- a/webrtc/p2p/base/turnport.cc +++ b/webrtc/p2p/base/turnport.cc @@ -927,14 +927,15 @@ void TurnPort::SendRequest(StunRequest* req, int delay) { void TurnPort::AddRequestAuthInfo(StunMessage* msg) { // If we've gotten the necessary data from the server, add it to our request. - VERIFY(!hash_.empty()); + RTC_DCHECK(!hash_.empty()); msg->AddAttribute(new StunByteStringAttribute( STUN_ATTR_USERNAME, credentials_.username)); msg->AddAttribute(new StunByteStringAttribute( STUN_ATTR_REALM, realm_)); msg->AddAttribute(new StunByteStringAttribute( STUN_ATTR_NONCE, nonce_)); - VERIFY(msg->AddMessageIntegrity(hash())); + const bool success = msg->AddMessageIntegrity(hash()); + RTC_DCHECK(success); } int TurnPort::Send(const void* data, size_t len, @@ -943,8 +944,9 @@ int TurnPort::Send(const void* data, size_t len, } void TurnPort::UpdateHash() { - VERIFY(ComputeStunCredentialHash(credentials_.username, realm_, - credentials_.password, &hash_)); + const bool success = ComputeStunCredentialHash(credentials_.username, realm_, + credentials_.password, &hash_); + RTC_DCHECK(success); } bool TurnPort::UpdateNonce(StunMessage* response) { @@ -1475,7 +1477,8 @@ int TurnEntry::Send(const void* data, size_t size, bool payload, STUN_ATTR_XOR_PEER_ADDRESS, ext_addr_)); msg.AddAttribute(new StunByteStringAttribute( STUN_ATTR_DATA, data, size)); - VERIFY(msg.Write(&buf)); + const bool success = msg.Write(&buf); + RTC_DCHECK(success); // If we're sending real data, request a channel bind that we can use later. if (state_ == STATE_UNBOUND && payload) { diff --git a/webrtc/pc/mediasession.cc b/webrtc/pc/mediasession.cc index 910c72b2f0..c596951f93 100644 --- a/webrtc/pc/mediasession.cc +++ b/webrtc/pc/mediasession.cc @@ -19,6 +19,7 @@ #include #include "webrtc/base/base64.h" +#include "webrtc/base/common.h" #include "webrtc/base/checks.h" #include "webrtc/base/helpers.h" #include "webrtc/base/logging.h" diff --git a/webrtc/pc/webrtcsdp.cc b/webrtc/pc/webrtcsdp.cc index 11eefe5c3d..d5110fc854 100644 --- a/webrtc/pc/webrtcsdp.cc +++ b/webrtc/pc/webrtcsdp.cc @@ -1376,7 +1376,9 @@ void BuildMediaDescription(const ContentInfo* content_info, cricket::ConnectionRole role = transport_info->description.connection_role; std::string dtls_role_str; - VERIFY(cricket::ConnectionRoleToString(role, &dtls_role_str)); + const bool success = + cricket::ConnectionRoleToString(role, &dtls_role_str); + RTC_DCHECK(success); InitAttrLine(kAttributeSetup, &os); os << kSdpDelimiterColon << dtls_role_str; AddLine(os.str(), message);