diff --git a/webrtc/base/bytebuffer.cc b/webrtc/base/bytebuffer.cc index 9730ff23d6..c2ffe60934 100644 --- a/webrtc/base/bytebuffer.cc +++ b/webrtc/base/bytebuffer.cc @@ -10,7 +10,6 @@ #include "webrtc/base/bytebuffer.h" -#include #include #include diff --git a/webrtc/base/fileutils.cc b/webrtc/base/fileutils.cc index d354dd8eb5..ae9309ce1b 100644 --- a/webrtc/base/fileutils.cc +++ b/webrtc/base/fileutils.cc @@ -8,11 +8,11 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include +#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 } diff --git a/webrtc/base/firewallsocketserver.cc b/webrtc/base/firewallsocketserver.cc index bf3ec42433..d6d03df3ad 100644 --- a/webrtc/base/firewallsocketserver.cc +++ b/webrtc/base/firewallsocketserver.cc @@ -10,11 +10,10 @@ #include "webrtc/base/firewallsocketserver.h" -#include - #include #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) { diff --git a/webrtc/base/flags.cc b/webrtc/base/flags.cc index 248c5c3f18..a138b8fb9b 100644 --- a/webrtc/base/flags.cc +++ b/webrtc/base/flags.cc @@ -8,18 +8,19 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include "webrtc/base/flags.h" + #include #include #include +#include "webrtc/base/checks.h" #if defined(WEBRTC_WIN) #include "webrtc/base/win32.h" #include #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 diff --git a/webrtc/base/flags.h b/webrtc/base/flags.h index d16f12bad6..6ca50b5cea 100644 --- a/webrtc/base/flags.h +++ b/webrtc/base/flags.h @@ -23,8 +23,6 @@ #ifndef WEBRTC_BASE_FLAGS_H__ #define WEBRTC_BASE_FLAGS_H__ -#include - #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; } diff --git a/webrtc/base/maccocoasocketserver.mm b/webrtc/base/maccocoasocketserver.mm index 123ffdc525..034737ebcc 100644 --- a/webrtc/base/maccocoasocketserver.mm +++ b/webrtc/base/maccocoasocketserver.mm @@ -11,7 +11,6 @@ #import #import -#include #include "webrtc/base/scoped_autorelease_pool.h" diff --git a/webrtc/base/maccocoathreadhelper.mm b/webrtc/base/maccocoathreadhelper.mm index 59ae6c4c99..70d920de39 100644 --- a/webrtc/base/maccocoathreadhelper.mm +++ b/webrtc/base/maccocoathreadhelper.mm @@ -9,11 +9,12 @@ */ // Helper function for using Cocoa with Posix threading. -#import #import #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 diff --git a/webrtc/base/nattypes.cc b/webrtc/base/nattypes.cc index 890a664095..1e37698f0d 100644 --- a/webrtc/base/nattypes.cc +++ b/webrtc/base/nattypes.cc @@ -8,10 +8,10 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include - #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; } } diff --git a/webrtc/base/physicalsocketserver.cc b/webrtc/base/physicalsocketserver.cc index c94b9a3ded..f0dc69fe67 100644 --- a/webrtc/base/physicalsocketserver.cc +++ b/webrtc/base/physicalsocketserver.cc @@ -13,8 +13,6 @@ #pragma warning(disable:4786) #endif -#include - #ifdef MEMORY_SANITIZER #include #endif diff --git a/webrtc/base/sec_buffer.h b/webrtc/base/sec_buffer.h index e6ffea4eb7..3ef720a9b2 100644 --- a/webrtc/base/sec_buffer.h +++ b/webrtc/base/sec_buffer.h @@ -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 == sizeof(SecBuffer))); - } + // This class must not extend the size of SecBuffer, since we use arrays of + // CSecBuffer in CSecBufferBundle below. + static_assert(sizeof(CSecBuffer) == sizeof(SecBuffer), ""); }; // Contains all generic implementation for the diff --git a/webrtc/base/virtualsocketserver.h b/webrtc/base/virtualsocketserver.h index 565222bfd2..cce0279d32 100644 --- a/webrtc/base/virtualsocketserver.h +++ b/webrtc/base/virtualsocketserver.h @@ -11,11 +11,10 @@ #ifndef WEBRTC_BASE_VIRTUALSOCKETSERVER_H_ #define WEBRTC_BASE_VIRTUALSOCKETSERVER_H_ -#include - #include #include +#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; } diff --git a/webrtc/base/winping.cc b/webrtc/base/winping.cc index be436c3cb0..1b0fa5d82f 100644 --- a/webrtc/base/winping.cc +++ b/webrtc/base/winping.cc @@ -10,12 +10,12 @@ #include "webrtc/base/winping.h" -#include #include #include #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));