diff options
author | kushi.p@gmail.com <kushi.p@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-05 09:59:28 +0000 |
---|---|---|
committer | kushi.p@gmail.com <kushi.p@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-05 09:59:28 +0000 |
commit | 52af5d521ef5d821672f7aaabdf9fd432e48a8cc (patch) | |
tree | d669a49913eaec3848fb53c2d9ae8507b20d506a /net/base | |
parent | 9b5b5204b65c4e8519becd77686031b720a1b0c5 (diff) | |
download | chromium_src-52af5d521ef5d821672f7aaabdf9fd432e48a8cc.zip chromium_src-52af5d521ef5d821672f7aaabdf9fd432e48a8cc.tar.gz chromium_src-52af5d521ef5d821672f7aaabdf9fd432e48a8cc.tar.bz2 |
Using DCHECK_NE/EQ/LE/GE/GT/LT() where possible. Updating logging in src/net/base/
Contributor: kushi.p@gmail.com
BUG=58409
Review URL: http://codereview.chromium.org/6905059
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@84228 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base')
-rw-r--r-- | net/base/escape.cc | 3 | ||||
-rw-r--r-- | net/base/ev_root_ca_metadata.cc | 4 | ||||
-rw-r--r-- | net/base/file_stream_win.cc | 4 | ||||
-rw-r--r-- | net/base/filter.cc | 2 | ||||
-rw-r--r-- | net/base/io_buffer.cc | 8 | ||||
-rw-r--r-- | net/base/listen_socket.cc | 5 | ||||
-rw-r--r-- | net/base/sdch_filter.cc | 4 | ||||
-rw-r--r-- | net/base/sdch_manager.cc | 4 | ||||
-rw-r--r-- | net/base/x509_certificate.cc | 4 | ||||
-rw-r--r-- | net/base/x509_certificate_nss.cc | 6 | ||||
-rw-r--r-- | net/base/x509_certificate_win.cc | 4 |
11 files changed, 26 insertions, 22 deletions
diff --git a/net/base/escape.cc b/net/base/escape.cc index f04e790..9f119d8 100644 --- a/net/base/escape.cc +++ b/net/base/escape.cc @@ -17,7 +17,8 @@ namespace { static const char* const kHexString = "0123456789ABCDEF"; inline char IntToHex(int i) { - DCHECK(i >= 0 && i <= 15) << i << " not a hex value"; + DCHECK_GE(i, 0) << i << " not a hex value"; + DCHECK_LE(i, 15) << i << " not a hex value"; return kHexString[i]; } diff --git a/net/base/ev_root_ca_metadata.cc b/net/base/ev_root_ca_metadata.cc index a721357..113babd 100644 --- a/net/base/ev_root_ca_metadata.cc +++ b/net/base/ev_root_ca_metadata.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -354,7 +354,7 @@ EVRootCAMetadata::EVRootCAMetadata() { od.mechanism = CKM_INVALID_MECHANISM; od.supportedExtension = INVALID_CERT_EXTENSION; SECOidTag policy = SECOID_AddEntry(&od); - DCHECK(policy != SEC_OID_UNKNOWN); + DCHECK_NE(SEC_OID_UNKNOWN, policy); ev_policy_[metadata.fingerprint] = policy; policy_oids_.push_back(policy); } diff --git a/net/base/file_stream_win.cc b/net/base/file_stream_win.cc index f902042..c08521e 100644 --- a/net/base/file_stream_win.cc +++ b/net/base/file_stream_win.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -96,7 +96,7 @@ void FileStream::AsyncContext::IOCompletionIsPending( void FileStream::AsyncContext::OnIOCompleted( MessageLoopForIO::IOContext* context, DWORD bytes_read, DWORD error) { - DCHECK(&context_ == context); + DCHECK_EQ(&context_, context); DCHECK(callback_); if (is_closing_) { diff --git a/net/base/filter.cc b/net/base/filter.cc index eb8a2c5..d633ca5 100644 --- a/net/base/filter.cc +++ b/net/base/filter.cc @@ -123,7 +123,7 @@ Filter::FilterStatus Filter::ReadData(char* dest_buffer, int* dest_len) { } bool Filter::FlushStreamBuffer(int stream_data_len) { - DCHECK(stream_data_len <= stream_buffer_size_); + DCHECK_LE(stream_data_len, stream_buffer_size_); if (stream_data_len <= 0 || stream_data_len > stream_buffer_size_) return false; diff --git a/net/base/io_buffer.cc b/net/base/io_buffer.cc index 4d9f9ad..aa04870 100644 --- a/net/base/io_buffer.cc +++ b/net/base/io_buffer.cc @@ -67,7 +67,8 @@ int DrainableIOBuffer::BytesConsumed() const { } void DrainableIOBuffer::SetOffset(int bytes) { - DCHECK(bytes >= 0 && bytes <= size_); + DCHECK_GE(bytes, 0); + DCHECK_LE(bytes, size_); used_ = bytes; data_ = base_->data() + used_; } @@ -84,7 +85,7 @@ GrowableIOBuffer::GrowableIOBuffer() } void GrowableIOBuffer::SetCapacity(int capacity) { - DCHECK(capacity >= 0); + DCHECK_GE(capacity, 0); // realloc will crash if it fails. real_data_.reset(static_cast<char*>(realloc(real_data_.release(), capacity))); capacity_ = capacity; @@ -95,7 +96,8 @@ void GrowableIOBuffer::SetCapacity(int capacity) { } void GrowableIOBuffer::set_offset(int offset) { - DCHECK(offset >= 0 && offset <= capacity_); + DCHECK_GE(offset, 0); + DCHECK_LE(offset, capacity_); offset_ = offset; data_ = real_data_.get() + offset; } diff --git a/net/base/listen_socket.cc b/net/base/listen_socket.cc index 6ca8dcc..e6804b9 100644 --- a/net/base/listen_socket.cc +++ b/net/base/listen_socket.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -219,7 +219,8 @@ void ListenSocket::Read() { #endif } else { // TODO(ibrar): maybe change DidRead to take a length instead - DCHECK(len > 0 && len <= kReadBufSize); + DCHECK_GT(len, 0); + DCHECK_LE(len, kReadBufSize); buf[len] = 0; // already create a buffer with +1 length socket_delegate_->DidRead(this, buf, len); } diff --git a/net/base/sdch_filter.cc b/net/base/sdch_filter.cc index 47325ff..f5dcc35 100644 --- a/net/base/sdch_filter.cc +++ b/net/base/sdch_filter.cc @@ -155,7 +155,7 @@ Filter::FilterStatus SdchFilter::ReadFilteredData(char* dest_buffer, if (FILTER_NEED_MORE_DATA == status) return FILTER_NEED_MORE_DATA; if (FILTER_ERROR == status) { - DCHECK(DECODING_ERROR == decoding_status_); + DCHECK_EQ(DECODING_ERROR, decoding_status_); DCHECK_EQ(0u, dest_buffer_excess_index_); DCHECK(dest_buffer_excess_.empty()); // This is where we try very hard to do error recovery, and make this @@ -251,7 +251,7 @@ Filter::FilterStatus SdchFilter::ReadFilteredData(char* dest_buffer, dest_buffer_excess_ = kDecompressionErrorHtml; } } else { - DCHECK(DECODING_IN_PROGRESS == decoding_status_); + DCHECK_EQ(DECODING_IN_PROGRESS, decoding_status_); } } diff --git a/net/base/sdch_manager.cc b/net/base/sdch_manager.cc index 6887fd0..9c8883f 100644 --- a/net/base/sdch_manager.cc +++ b/net/base/sdch_manager.cc @@ -207,7 +207,7 @@ SdchManager::SdchManager() : sdch_enabled_(false) { } SdchManager::~SdchManager() { - DCHECK(global_ == this); + DCHECK_EQ(this, global_); while (!dictionaries_.empty()) { DictionaryMap::iterator it = dictionaries_.begin(); it->second->Release(); @@ -388,7 +388,7 @@ bool SdchManager::AddSdchDictionary(const std::string& dictionary_text, while (1) { size_t line_end = dictionary_text.find('\n', line_start); DCHECK(std::string::npos != line_end); - DCHECK(line_end <= header_end); + DCHECK_LE(line_end, header_end); size_t colon_index = dictionary_text.find(':', line_start); if (std::string::npos == colon_index) { diff --git a/net/base/x509_certificate.cc b/net/base/x509_certificate.cc index 73636d7..4934ef3 100644 --- a/net/base/x509_certificate.cc +++ b/net/base/x509_certificate.cc @@ -153,14 +153,14 @@ X509Certificate* X509Certificate::CreateFromHandle( Source source, const OSCertHandles& intermediates) { DCHECK(cert_handle); - DCHECK(source != SOURCE_UNUSED); + DCHECK_NE(source, SOURCE_UNUSED); // Check if we already have this certificate in memory. X509CertificateCache* cache = g_x509_certificate_cache.Pointer(); X509Certificate* cached_cert = cache->Find(CalculateFingerprint(cert_handle)); if (cached_cert) { - DCHECK(cached_cert->source_ != SOURCE_UNUSED); + DCHECK_NE(cached_cert->source_, SOURCE_UNUSED); if (cached_cert->source_ > source || (cached_cert->source_ == source && cached_cert->HasIntermediateCertificates(intermediates))) { diff --git a/net/base/x509_certificate_nss.cc b/net/base/x509_certificate_nss.cc index a6d0663..dd967d3 100644 --- a/net/base/x509_certificate_nss.cc +++ b/net/base/x509_certificate_nss.cc @@ -277,7 +277,7 @@ void ParsePrincipal(CERTName* name, void ParseDate(SECItem* der_date, base::Time* result) { PRTime prtime; SECStatus rv = DER_DecodeTimeChoice(&prtime, der_date); - DCHECK(rv == SECSuccess); + DCHECK_EQ(SECSuccess, rv); *result = crypto::PRTimeToBaseTime(prtime); } @@ -980,11 +980,11 @@ SHA1Fingerprint X509Certificate::CalculateFingerprint( memset(sha1.data, 0, sizeof(sha1.data)); DCHECK(NULL != cert->derCert.data); - DCHECK(0 != cert->derCert.len); + DCHECK_NE(0U, cert->derCert.len); SECStatus rv = HASH_HashBuf(HASH_AlgSHA1, sha1.data, cert->derCert.data, cert->derCert.len); - DCHECK(rv == SECSuccess); + DCHECK_EQ(SECSuccess, rv); return sha1; } diff --git a/net/base/x509_certificate_win.cc b/net/base/x509_certificate_win.cc index 367f4ed..9b3e923 100644 --- a/net/base/x509_certificate_win.cc +++ b/net/base/x509_certificate_win.cc @@ -897,7 +897,7 @@ bool X509Certificate::GetDEREncoded(std::string* encoded) { // http://cabforum.org/EV_Certificate_Guidelines.pdf. bool X509Certificate::CheckEV(PCCERT_CHAIN_CONTEXT chain_context, const char* policy_oid) const { - DCHECK(chain_context->cChain != 0); + DCHECK_NE(static_cast<DWORD>(0), chain_context->cChain); // If the cert doesn't match any of the policies, the // CERT_TRUST_IS_NOT_VALID_FOR_USAGE bit (0x10) in // chain_context->TrustStatus.dwErrorStatus is set. @@ -991,7 +991,7 @@ void X509Certificate::FreeOSCertHandle(OSCertHandle cert_handle) { SHA1Fingerprint X509Certificate::CalculateFingerprint( OSCertHandle cert) { DCHECK(NULL != cert->pbCertEncoded); - DCHECK(0 != cert->cbCertEncoded); + DCHECK_NE(static_cast<DWORD>(0), cert->cbCertEncoded); BOOL rv; SHA1Fingerprint sha1; |