diff options
author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-14 07:28:03 +0000 |
---|---|---|
committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-14 07:28:03 +0000 |
commit | e62b55134fab8df52edd47cb370f768f050f6eaf (patch) | |
tree | 41f599575fddfe64fc7f13078dc1f66260e2b9d7 /base | |
parent | feec41b94f2f88ed9ddcf50f3415343346943488 (diff) | |
download | chromium_src-e62b55134fab8df52edd47cb370f768f050f6eaf.zip chromium_src-e62b55134fab8df52edd47cb370f768f050f6eaf.tar.gz chromium_src-e62b55134fab8df52edd47cb370f768f050f6eaf.tar.bz2 |
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
Diffstat (limited to 'base')
-rw-r--r-- | base/shared_memory_unittest.cc | 6 |
1 files changed, 4 insertions, 2 deletions
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<int*>(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<PlatformThreadHandle> thread_handles; scoped_array<MultipleThreadMain*> thread_delegates; |