summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-01 20:53:58 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-01 20:53:58 +0000
commitdedd33e7ad19964bab22f4d35c4f66872c463c3d (patch)
tree2374d9ad70f494e4819e601865ff70f216b8b329 /base
parent4fe33f6f7c6a501136b476e2e51c5577413f50b8 (diff)
downloadchromium_src-dedd33e7ad19964bab22f4d35c4f66872c463c3d.zip
chromium_src-dedd33e7ad19964bab22f4d35c4f66872c463c3d.tar.gz
chromium_src-dedd33e7ad19964bab22f4d35c4f66872c463c3d.tar.bz2
Revert r40289: "Add support for CHECK_* macros."
Broke official build compilation (only worked on debug/release builds). Review URL: http://codereview.chromium.org/661298 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40296 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/allocator/allocator_unittests.cc3
-rw-r--r--base/logging.h86
-rw-r--r--base/process_util_unittest.cc2
-rw-r--r--base/rand_util_posix.cc2
-rw-r--r--base/rand_util_win.cc2
5 files changed, 31 insertions, 64 deletions
diff --git a/base/allocator/allocator_unittests.cc b/base/allocator/allocator_unittests.cc
index fdda081..919cfab 100644
--- a/base/allocator/allocator_unittests.cc
+++ b/base/allocator/allocator_unittests.cc
@@ -402,7 +402,7 @@ TEST(Allocators, Realloc1) {
// The larger the start-size, the larger the non-reallocing delta.
for (int d = 0; d < s*2; ++d) {
void* new_p = realloc(p, start_sizes[s] + deltas[d]);
- CHECK_EQ(p, new_p); // realloc should not allocate new memory
+ CHECK(p == new_p); // realloc should not allocate new memory
}
// Test again, but this time reallocing smaller first.
for (int d = 0; d < s*2; ++d) {
@@ -487,3 +487,4 @@ int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
+
diff --git a/base/logging.h b/base/logging.h
index ebb2518..1aa1162 100644
--- a/base/logging.h
+++ b/base/logging.h
@@ -332,55 +332,6 @@ std::string* MakeCheckOpString(const int& v1,
return MakeCheckOpStringIntInt(v1, v2, names);
}
-// Helper macro for binary operators.
-// Don't use this macro directly in your code, use CHECK_EQ et al below.
-#define CHECK_OP(name, op, val1, val2) \
- if (logging::CheckOpString _result = \
- logging::Check##name##Impl((val1), (val2), #val1 " " #op " " #val2)) \
- logging::LogMessage(__FILE__, __LINE__, _result).stream()
-
-// Helper functions for string comparisons.
-// To avoid bloat, the definitions are in logging.cc.
-#define DECLARE_CHECK_STROP_IMPL(func, expected) \
- std::string* Check##func##expected##Impl(const char* s1, \
- const char* s2, \
- const char* names);
-DECLARE_CHECK_STROP_IMPL(strcmp, true)
-DECLARE_CHECK_STROP_IMPL(strcmp, false)
-DECLARE_CHECK_STROP_IMPL(_stricmp, true)
-DECLARE_CHECK_STROP_IMPL(_stricmp, false)
-#undef DECLARE_CHECK_STROP_IMPL
-
-// Helper macro for string comparisons.
-// Don't use this macro directly in your code, use CHECK_STREQ et al below.
-#define CHECK_STROP(func, op, expected, s1, s2) \
- while (CheckOpString _result = \
- logging::Check##func##expected##Impl((s1), (s2), \
- #s1 " " #op " " #s2)) \
- LOG(FATAL) << *_result.str_
-
-// String (char*) equality/inequality checks.
-// CASE versions are case-insensitive.
-//
-// Note that "s1" and "s2" may be temporary strings which are destroyed
-// by the compiler at the end of the current "full expression"
-// (e.g. CHECK_STREQ(Foo().c_str(), Bar().c_str())).
-
-#define CHECK_STREQ(s1, s2) CHECK_STROP(strcmp, ==, true, s1, s2)
-#define CHECK_STRNE(s1, s2) CHECK_STROP(strcmp, !=, false, s1, s2)
-#define CHECK_STRCASEEQ(s1, s2) CHECK_STROP(_stricmp, ==, true, s1, s2)
-#define CHECK_STRCASENE(s1, s2) CHECK_STROP(_stricmp, !=, false, s1, s2)
-
-#define CHECK_INDEX(I,A) CHECK(I < (sizeof(A)/sizeof(A[0])))
-#define CHECK_BOUND(B,A) CHECK(B <= (sizeof(A)/sizeof(A[0])))
-
-#define CHECK_EQ(val1, val2) CHECK_OP(EQ, ==, val1, val2)
-#define CHECK_NE(val1, val2) CHECK_OP(NE, !=, val1, val2)
-#define CHECK_LE(val1, val2) CHECK_OP(LE, <=, val1, val2)
-#define CHECK_LT(val1, val2) CHECK_OP(LT, < , val1, val2)
-#define CHECK_GE(val1, val2) CHECK_OP(GE, >=, val1, val2)
-#define CHECK_GT(val1, val2) CHECK_OP(GT, > , val1, val2)
-
// Plus some debug-logging macros that get compiled to nothing for production
//
// DEBUG_MODE is for uses like
@@ -493,8 +444,11 @@ enum { DEBUG_MODE = 0 };
// debug-only checking. not executed in NDEBUG mode.
enum { DEBUG_MODE = 1 };
-#define DCHECK(condition) CHECK(condition)
-#define DPCHECK(condition) PCHECK(condition)
+#define DCHECK(condition) \
+ LOG_IF(FATAL, !(condition)) << "Check failed: " #condition ". "
+
+#define DPCHECK(condition) \
+ PLOG_IF(FATAL, !(condition)) << "Check failed: " #condition ". "
// Helper macro for binary operators.
// Don't use this macro directly in your code, use DCHECK_EQ et al below.
@@ -503,6 +457,18 @@ enum { DEBUG_MODE = 1 };
logging::Check##name##Impl((val1), (val2), #val1 " " #op " " #val2)) \
logging::LogMessage(__FILE__, __LINE__, _result).stream()
+// Helper functions for string comparisons.
+// To avoid bloat, the definitions are in logging.cc.
+#define DECLARE_DCHECK_STROP_IMPL(func, expected) \
+ std::string* Check##func##expected##Impl(const char* s1, \
+ const char* s2, \
+ const char* names);
+DECLARE_DCHECK_STROP_IMPL(strcmp, true)
+DECLARE_DCHECK_STROP_IMPL(strcmp, false)
+DECLARE_DCHECK_STROP_IMPL(_stricmp, true)
+DECLARE_DCHECK_STROP_IMPL(_stricmp, false)
+#undef DECLARE_DCHECK_STROP_IMPL
+
// Helper macro for string comparisons.
// Don't use this macro directly in your code, use CHECK_STREQ et al below.
#define DCHECK_STROP(func, op, expected, s1, s2) \
@@ -594,11 +560,11 @@ extern bool g_enable_dcheck;
#endif // NDEBUG
-// Helper functions for CHECK_OP macro.
+// Helper functions for DCHECK_OP macro.
// The (int, int) specialization works around the issue that the compiler
// will not instantiate the template version of the function on values of
// unnamed enum type - see comment below.
-#define DEFINE_CHECK_OP_IMPL(name, op) \
+#define DEFINE_DCHECK_OP_IMPL(name, op) \
template <class t1, class t2> \
inline std::string* Check##name##Impl(const t1& v1, const t2& v2, \
const char* names) { \
@@ -609,13 +575,13 @@ extern bool g_enable_dcheck;
if (v1 op v2) return NULL; \
else return MakeCheckOpString(v1, v2, names); \
}
-DEFINE_CHECK_OP_IMPL(EQ, ==)
-DEFINE_CHECK_OP_IMPL(NE, !=)
-DEFINE_CHECK_OP_IMPL(LE, <=)
-DEFINE_CHECK_OP_IMPL(LT, < )
-DEFINE_CHECK_OP_IMPL(GE, >=)
-DEFINE_CHECK_OP_IMPL(GT, > )
-#undef DEFINE_CHECK_OP_IMPL
+DEFINE_DCHECK_OP_IMPL(EQ, ==)
+DEFINE_DCHECK_OP_IMPL(NE, !=)
+DEFINE_DCHECK_OP_IMPL(LE, <=)
+DEFINE_DCHECK_OP_IMPL(LT, < )
+DEFINE_DCHECK_OP_IMPL(GE, >=)
+DEFINE_DCHECK_OP_IMPL(GT, > )
+#undef DEFINE_DCHECK_OP_IMPL
// Equality/Inequality checks - compare two values, and log a LOG_FATAL message
// including the two values when the result is not as expected. The values
diff --git a/base/process_util_unittest.cc b/base/process_util_unittest.cc
index 3170b6a..f9c0b50 100644
--- a/base/process_util_unittest.cc
+++ b/base/process_util_unittest.cc
@@ -262,7 +262,7 @@ int ProcessUtilTest::CountOpenFDsInChild() {
int num_open_files = -1;
ssize_t bytes_read =
HANDLE_EINTR(read(fds[0], &num_open_files, sizeof(num_open_files)));
- CHECK_EQ(bytes_read, static_cast<ssize_t>(sizeof(num_open_files)));
+ CHECK(bytes_read == static_cast<ssize_t>(sizeof(num_open_files)));
CHECK(WaitForSingleProcess(handle, 1000));
base::CloseProcessHandle(handle);
diff --git a/base/rand_util_posix.cc b/base/rand_util_posix.cc
index c65551d..a2bdeb8 100644
--- a/base/rand_util_posix.cc
+++ b/base/rand_util_posix.cc
@@ -22,7 +22,7 @@ class URandomFd {
public:
URandomFd() {
fd_ = open("/dev/urandom", O_RDONLY);
- CHECK_GE(fd_, 0) << "Cannot open /dev/urandom: " << errno;
+ CHECK(fd_ >= 0) << "Cannot open /dev/urandom: " << errno;
}
~URandomFd() {
diff --git a/base/rand_util_win.cc b/base/rand_util_win.cc
index ec0411e..13e8fb2 100644
--- a/base/rand_util_win.cc
+++ b/base/rand_util_win.cc
@@ -13,7 +13,7 @@ namespace {
uint32 RandUint32() {
uint32 number;
- CHECK_EQ(rand_s(&number), 0);
+ CHECK(rand_s(&number) == 0);
return number;
}