diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-31 20:34:25 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-31 20:34:25 +0000 |
commit | 8e03fec1b3cc0dd2e6f25cf943914e9e760b187a (patch) | |
tree | 496c8a1b46ee18a7ce7537539c5d207e4bf5396f | |
parent | 2fc8f49dff31f79bff73b3491f3d07c8a0dfb9d5 (diff) | |
download | chromium_src-8e03fec1b3cc0dd2e6f25cf943914e9e760b187a.zip chromium_src-8e03fec1b3cc0dd2e6f25cf943914e9e760b187a.tar.gz chromium_src-8e03fec1b3cc0dd2e6f25cf943914e9e760b187a.tar.bz2 |
Use DCHECK_GE() where possible in base/. Patch by Kushal Pisavadia (see http://codereview.chromium.org/6688056/ ), r=me.
BUG=58409
TEST=none
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80063 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/mach_ipc_mac.h | 13 | ||||
-rw-r--r-- | base/mach_ipc_mac.mm | 8 | ||||
-rw-r--r-- | base/message_pump_win.cc | 2 | ||||
-rw-r--r-- | base/path_service.cc | 4 | ||||
-rw-r--r-- | base/pickle.cc | 4 | ||||
-rw-r--r-- | base/shared_memory_posix.cc | 6 |
6 files changed, 16 insertions, 21 deletions
diff --git a/base/mach_ipc_mac.h b/base/mach_ipc_mac.h index d506a00..4e80f62 100644 --- a/base/mach_ipc_mac.h +++ b/base/mach_ipc_mac.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 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. @@ -140,6 +140,7 @@ class MachMsgPortDescriptor : public mach_msg_port_descriptor_t { // class MachMessage { public: + static const size_t kEmptyMessageSize; virtual ~MachMessage(); @@ -209,7 +210,6 @@ class MachMessage { // of the Mach header. size_t MaxSize() const { return storage_length_bytes_; } - protected: mach_msg_header_t *Head() { return &(storage_->head); } private: @@ -220,15 +220,6 @@ class MachMessage { u_int8_t padding[1024]; }; - // kEmptyMessageSize needs to have the definition of MachMessageData before - // it. - public: - // The size of an empty message with no data. - static const size_t kEmptyMessageSize = sizeof(mach_msg_header_t) + - sizeof(mach_msg_body_t) + - sizeof(MessageDataPacket); - - private: MachMessageData *storage_; size_t storage_length_bytes_; bool own_storage_; // Is storage owned by this object? diff --git a/base/mach_ipc_mac.mm b/base/mach_ipc_mac.mm index a0bfdc8..e79c80b 100644 --- a/base/mach_ipc_mac.mm +++ b/base/mach_ipc_mac.mm @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 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. @@ -11,6 +11,10 @@ namespace base { +// static +const size_t MachSendMessage::kEmptyMessageSize = sizeof(mach_msg_header_t) + + sizeof(mach_msg_body_t) + sizeof(MessageDataPacket); + //============================================================================== MachSendMessage::MachSendMessage(int32_t message_id) : MachMessage() { Initialize(message_id); @@ -50,7 +54,7 @@ MachMessage::MachMessage(void *storage, size_t storage_length) storage_length_bytes_(storage_length), own_storage_(false) { DCHECK(storage); - DCHECK(storage_length >= kEmptyMessageSize); + DCHECK_GE(storage_length, kEmptyMessageSize); } //============================================================================== diff --git a/base/message_pump_win.cc b/base/message_pump_win.cc index 1924081..9d0ec53 100644 --- a/base/message_pump_win.cc +++ b/base/message_pump_win.cc @@ -123,7 +123,7 @@ void MessagePumpForUI::ScheduleDelayedWork(const TimeTicks& delayed_work_time) { delayed_work_time_ = delayed_work_time; int delay_msec = GetCurrentDelay(); - DCHECK(delay_msec >= 0); + DCHECK_GE(delay_msec, 0); if (delay_msec < USER_TIMER_MINIMUM) delay_msec = USER_TIMER_MINIMUM; diff --git a/base/path_service.cc b/base/path_service.cc index 1262f68..e72ae7d 100644 --- a/base/path_service.cc +++ b/base/path_service.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 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. @@ -171,7 +171,7 @@ bool PathService::Get(int key, FilePath* result) { PathData* path_data = GetPathData(); DCHECK(path_data); DCHECK(result); - DCHECK(key >= base::DIR_CURRENT); + DCHECK_GE(key, base::DIR_CURRENT); // special case the current directory because it can never be cached if (key == base::DIR_CURRENT) diff --git a/base/pickle.cc b/base/pickle.cc index 116d3f1..afe35db 100644 --- a/base/pickle.cc +++ b/base/pickle.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 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. @@ -33,7 +33,7 @@ Pickle::Pickle(int header_size) header_size_(AlignInt(header_size, sizeof(uint32))), capacity_(0), variable_buffer_offset_(0) { - DCHECK(static_cast<size_t>(header_size) >= sizeof(Header)); + DCHECK_GE(static_cast<size_t>(header_size), sizeof(Header)); DCHECK(header_size <= kPayloadUnit); Resize(kPayloadUnit); header_->payload_size = 0; diff --git a/base/shared_memory_posix.cc b/base/shared_memory_posix.cc index 8dc9463..538aed4 100644 --- a/base/shared_memory_posix.cc +++ b/base/shared_memory_posix.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. @@ -292,7 +292,7 @@ bool SharedMemory::FilePathForMemoryName(const std::string& mem_name, } void SharedMemory::LockOrUnlockCommon(int function) { - DCHECK(mapped_file_ >= 0); + DCHECK_GE(mapped_file_, 0); while (lockf(mapped_file_, function, 0) < 0) { if (errno == EINTR) { continue; @@ -314,7 +314,7 @@ bool SharedMemory::ShareToProcessCommon(ProcessHandle process, SharedMemoryHandle *new_handle, bool close_self) { const int new_fd = dup(mapped_file_); - DCHECK(new_fd >= 0); + DCHECK_GE(new_fd, 0); new_handle->fd = new_fd; new_handle->auto_close = true; |