webrtc/base: Use RTC_DCHECK() instead of assert()

Review-Url: https://codereview.webrtc.org/2325623002
Cr-Commit-Position: refs/heads/master@{#14192}
This commit is contained in:
kwiberg 2016-09-13 01:17:10 -07:00 committed by Commit bot
parent ade2a038a9
commit 22487b2d0a
12 changed files with 42 additions and 47 deletions

View File

@ -10,7 +10,6 @@
#include "webrtc/base/bytebuffer.h"
#include <assert.h>
#include <string.h>
#include <algorithm>

View File

@ -8,11 +8,11 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include <assert.h>
#include "webrtc/base/fileutils.h"
#include "webrtc/base/arraysize.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/pathutils.h"
#include "webrtc/base/fileutils.h"
#include "webrtc/base/stringutils.h"
#include "webrtc/base/stream.h"
@ -112,7 +112,7 @@ std::string DirectoryIterator::Name() const {
#if defined(WEBRTC_WIN)
return ToUtf8(data_.cFileName);
#else
assert(dirent_ != NULL);
RTC_DCHECK(dirent_);
return dirent_->d_name;
#endif
}

View File

@ -10,11 +10,10 @@
#include "webrtc/base/firewallsocketserver.h"
#include <assert.h>
#include <algorithm>
#include "webrtc/base/asyncsocket.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/logging.h"
namespace rtc {
@ -220,7 +219,7 @@ FirewallManager::FirewallManager() {
}
FirewallManager::~FirewallManager() {
assert(servers_.empty());
RTC_DCHECK(servers_.empty());
}
void FirewallManager::AddServer(FirewallSocketServer* server) {

View File

@ -8,18 +8,19 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include "webrtc/base/flags.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "webrtc/base/checks.h"
#if defined(WEBRTC_WIN)
#include "webrtc/base/win32.h"
#include <shellapi.h>
#endif
#include "webrtc/base/flags.h"
namespace rtc {
// -----------------------------------------------------------------------------
// Implementation of Flag
@ -256,7 +257,8 @@ int FlagList::SetFlagsFromCommandLine(int* argc, const char** argv,
}
void FlagList::Register(Flag* flag) {
assert(flag != NULL && strlen(flag->name()) > 0);
RTC_DCHECK(flag);
RTC_DCHECK_GT(strlen(flag->name()), 0u);
// NOTE: Don't call Lookup() within Register because it accesses the name_
// of other flags in list_, and if the flags are coming from two different
// compilation units, the initialization order between them is undefined, and

View File

@ -23,8 +23,6 @@
#ifndef WEBRTC_BASE_FLAGS_H__
#define WEBRTC_BASE_FLAGS_H__
#include <assert.h>
#include "webrtc/base/checks.h"
#include "webrtc/base/common.h"
#include "webrtc/base/constructormagic.h"
@ -88,43 +86,43 @@ class Flag {
// Flag variables
bool* bool_variable() const {
assert(type_ == BOOL);
RTC_DCHECK_EQ(BOOL, type_);
return &variable_->b;
}
int* int_variable() const {
assert(type_ == INT);
RTC_DCHECK_EQ(INT, type_);
return &variable_->i;
}
double* float_variable() const {
assert(type_ == FLOAT);
RTC_DCHECK_EQ(FLOAT, type_);
return &variable_->f;
}
const char** string_variable() const {
assert(type_ == STRING);
RTC_DCHECK_EQ(STRING, type_);
return &variable_->s;
}
// Default values
bool bool_default() const {
assert(type_ == BOOL);
RTC_DCHECK_EQ(BOOL, type_);
return default_.b;
}
int int_default() const {
assert(type_ == INT);
RTC_DCHECK_EQ(INT, type_);
return default_.i;
}
double float_default() const {
assert(type_ == FLOAT);
RTC_DCHECK_EQ(FLOAT, type_);
return default_.f;
}
const char* string_default() const {
assert(type_ == STRING);
RTC_DCHECK_EQ(STRING, type_);
return default_.s;
}

View File

@ -11,7 +11,6 @@
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
#include <assert.h>
#include "webrtc/base/scoped_autorelease_pool.h"

View File

@ -9,11 +9,12 @@
*/
// Helper function for using Cocoa with Posix threading.
#import <assert.h>
#import <Foundation/Foundation.h>
#import "webrtc/base/maccocoathreadhelper.h"
#include "webrtc/base/checks.h"
namespace rtc {
// Cocoa must be "put into multithreading mode" before Cocoa functionality can
@ -34,7 +35,7 @@ void InitCocoaMultiThreading() {
[hack drain];
}
assert([NSThread isMultiThreaded]);
RTC_DCHECK([NSThread isMultiThreaded]);
}
} // namespace rtc

View File

@ -8,10 +8,10 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include <assert.h>
#include "webrtc/base/nattypes.h"
#include "webrtc/base/checks.h"
namespace rtc {
class SymmetricNAT : public NAT {
@ -44,11 +44,17 @@ public:
NAT* NAT::Create(NATType type) {
switch (type) {
case NAT_OPEN_CONE: return new OpenConeNAT();
case NAT_ADDR_RESTRICTED: return new AddressRestrictedNAT();
case NAT_PORT_RESTRICTED: return new PortRestrictedNAT();
case NAT_SYMMETRIC: return new SymmetricNAT();
default: assert(0); return 0;
case NAT_OPEN_CONE:
return new OpenConeNAT();
case NAT_ADDR_RESTRICTED:
return new AddressRestrictedNAT();
case NAT_PORT_RESTRICTED:
return new PortRestrictedNAT();
case NAT_SYMMETRIC:
return new SymmetricNAT();
default:
RTC_NOTREACHED();
return 0;
}
}

View File

@ -13,8 +13,6 @@
#pragma warning(disable:4786)
#endif
#include <assert.h>
#ifdef MEMORY_SANITIZER
#include <sanitizer/msan_interface.h>
#endif

View File

@ -73,16 +73,9 @@ class CSecBuffer: public CSecBufferBase {
Clear();
}
private:
// A placeholder function for compile-time asserts on the class
void CompileAsserts() {
// never invoked...
assert(false); // _T("Notreached")
// This class must not extend the size of SecBuffer, since
// we use arrays of CSecBuffer in CSecBufferBundle below
cassert(sizeof(CSecBuffer<SSPIFree> == sizeof(SecBuffer)));
}
// This class must not extend the size of SecBuffer, since we use arrays of
// CSecBuffer in CSecBufferBundle below.
static_assert(sizeof(CSecBuffer<pfnFreeBuffer>) == sizeof(SecBuffer), "");
};
// Contains all generic implementation for the

View File

@ -11,11 +11,10 @@
#ifndef WEBRTC_BASE_VIRTUALSOCKETSERVER_H_
#define WEBRTC_BASE_VIRTUALSOCKETSERVER_H_
#include <assert.h>
#include <deque>
#include <map>
#include "webrtc/base/checks.h"
#include "webrtc/base/constructormagic.h"
#include "webrtc/base/messagequeue.h"
#include "webrtc/base/socketserver.h"
@ -86,7 +85,8 @@ class VirtualSocketServer : public SocketServer, public sigslot::has_slots<> {
// is separate from calculations to drop based on queue size.
double drop_probability() { return drop_prob_; }
void set_drop_probability(double drop_prob) {
assert((0 <= drop_prob) && (drop_prob <= 1));
RTC_DCHECK_GE(drop_prob, 0.0);
RTC_DCHECK_LE(drop_prob, 1.0);
drop_prob_ = drop_prob;
}

View File

@ -10,12 +10,12 @@
#include "webrtc/base/winping.h"
#include <assert.h>
#include <Iphlpapi.h>
#include <algorithm>
#include "webrtc/base/byteorder.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/common.h"
#include "webrtc/base/ipaddress.h"
#include "webrtc/base/logging.h"
@ -218,7 +218,7 @@ WinPing::PingResult WinPing::Ping(IPAddress ip,
return PING_INVALID_PARAMS;
}
assert(IsValid());
RTC_DCHECK(IsValid());
IP_OPTION_INFORMATION ipopt;
memset(&ipopt, 0, sizeof(ipopt));