Replace all use of the VERIFY macro.
Replaced by assigning value to a local variable, followed by a DCHECK. Also deletes dead test code under the always false TEST_DIGEST define. BUG=webrtc:6424 Review-Url: https://codereview.webrtc.org/2623473004 Cr-Commit-Position: refs/heads/master@{#16476}
This commit is contained in:
parent
ff0e72fd16
commit
c16fa5ea69
@ -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"
|
||||
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
#include <memory>
|
||||
#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"
|
||||
|
||||
@ -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<int>(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);
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
#include <vector>
|
||||
|
||||
#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"
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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() {
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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() {
|
||||
|
||||
@ -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<int>(strlen(buffer));
|
||||
int sent = socket->Send(buffer, len);
|
||||
RTC_DCHECK(sent == len);
|
||||
RTC_UNUSED2(sent, len);
|
||||
}
|
||||
|
||||
void PeerConnectionClient::OnMessageFromPeer(int peer_id,
|
||||
|
||||
@ -469,7 +469,7 @@ class FakeVoiceMediaChannel : public RtpHelper<VoiceMediaChannel> {
|
||||
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)));
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -13,7 +13,6 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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_; }
|
||||
|
||||
@ -354,7 +354,8 @@ bool DtlsTransport::SetSrtpCryptoSuites(const std::vector<int>& 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;
|
||||
}
|
||||
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
#include <utility>
|
||||
|
||||
#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"
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user