From e62b55134fab8df52edd47cb370f768f050f6eaf Mon Sep 17 00:00:00 2001 From: "thakis@chromium.org" Date: Fri, 14 Oct 2011 07:28:03 +0000 Subject: Don't use `sizeof(a) / sizeof(a)` to compute the number of elements in array a. The interesting parts of the patch are by wtc. Found by PVS Studio: http://www.viva64.com/en/b/0113/ , N12 BUG=100278 TEST=none Review URL: http://codereview.chromium.org/8273009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@105467 0039d316-1c4b-4281-b951-d872f2087c98 --- base/shared_memory_unittest.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'base/shared_memory_unittest.cc') diff --git a/base/shared_memory_unittest.cc b/base/shared_memory_unittest.cc index 9472101..330add4 100644 --- a/base/shared_memory_unittest.cc +++ b/base/shared_memory_unittest.cc @@ -42,13 +42,15 @@ class MultipleThreadMain : public PlatformThread::Delegate { rv = memory.Map(kDataSize); EXPECT_TRUE(rv); int *ptr = static_cast(memory.memory()) + id_; - EXPECT_EQ(*ptr, 0); + EXPECT_EQ(0, *ptr); for (int idx = 0; idx < 100; idx++) { *ptr = idx; PlatformThread::Sleep(1); // Short wait. EXPECT_EQ(*ptr, idx); } + // Reset back to 0 for the next test that uses the same name. + *ptr = 0; memory.Close(); } @@ -228,7 +230,7 @@ TEST(SharedMemoryTest, MultipleThreads) { // kNumThreads. int threadcounts[] = { 1, kNumThreads }; - for (size_t i = 0; i < sizeof(threadcounts) / sizeof(threadcounts); i++) { + for (size_t i = 0; i < arraysize(threadcounts); i++) { int numthreads = threadcounts[i]; scoped_array thread_handles; scoped_array thread_delegates; -- cgit v1.1