From 5bd9b1362d7b01d49904f7f0d3271bafe725201a Mon Sep 17 00:00:00 2001 From: Christopher Dykes Date: Fri, 1 Jul 2016 21:31:35 -0700 Subject: [PATCH] Mark a few constants as constexpr so VLAs aren't required Summary: Because MSVC doesn't support VLAs. Reviewed By: yfeldblum Differential Revision: D3513143 fbshipit-source-id: 256e9e843004a3c37821b3dddc6ecd4c6b5645d9 --- folly/io/async/test/AsyncSocketTest2.cpp | 4 ++-- folly/io/async/test/EventBaseTest.cpp | 4 ++-- folly/test/AtomicHashMapTest.cpp | 9 +++++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/folly/io/async/test/AsyncSocketTest2.cpp b/folly/io/async/test/AsyncSocketTest2.cpp index ca646031..602e9862 100644 --- a/folly/io/async/test/AsyncSocketTest2.cpp +++ b/folly/io/async/test/AsyncSocketTest2.cpp @@ -1105,7 +1105,7 @@ TEST(AsyncSocketTest, WriteIOBuf) { acceptedSocket->setReadCB(&rcb); // Write a simple buffer to the socket - size_t simpleBufLength = 5; + constexpr size_t simpleBufLength = 5; char simpleBuf[simpleBufLength]; memset(simpleBuf, 'a', simpleBufLength); WriteCallback wcb; @@ -1289,7 +1289,7 @@ TEST(AsyncSocketTest, ZeroLengthWritev) { memset(buf.get(), 'b', len2); WriteCallback wcb; - size_t iovCount = 4; + constexpr size_t iovCount = 4; struct iovec iov[iovCount]; iov[0].iov_base = buf.get(); iov[0].iov_len = len1; diff --git a/folly/io/async/test/EventBaseTest.cpp b/folly/io/async/test/EventBaseTest.cpp index cfea5991..9efaf571 100644 --- a/folly/io/async/test/EventBaseTest.cpp +++ b/folly/io/async/test/EventBaseTest.cpp @@ -1112,8 +1112,8 @@ void runInThreadTestFunc(RunInThreadArg* arg) { } TEST(EventBaseTest, RunInThread) { - uint32_t numThreads = 50; - uint32_t opsPerThread = 100; + constexpr uint32_t numThreads = 50; + constexpr uint32_t opsPerThread = 100; RunInThreadData data(numThreads, opsPerThread); deque threads; diff --git a/folly/test/AtomicHashMapTest.cpp b/folly/test/AtomicHashMapTest.cpp index a8c6dff2..08162273 100644 --- a/folly/test/AtomicHashMapTest.cpp +++ b/folly/test/AtomicHashMapTest.cpp @@ -681,13 +681,14 @@ void* atomicHashArrayInsertRaceThread(void* /* j */) { } TEST(Ahm, atomic_hash_array_insert_race) { AHA* arr = atomicHashArrayInsertRaceArray.get(); - int numIterations = 5000, FLAGS_numThreads = 4; - void* statuses[FLAGS_numThreads]; + int numIterations = 5000; + constexpr int numThreads = 4; + void* statuses[numThreads]; for (int i = 0; i < numIterations; i++) { arr->clear(); - runThreads(atomicHashArrayInsertRaceThread, FLAGS_numThreads, statuses); + runThreads(atomicHashArrayInsertRaceThread, numThreads, statuses); EXPECT_GE(arr->size(), 1); - for (int j = 0; j < FLAGS_numThreads; j++) { + for (int j = 0; j < numThreads; j++) { EXPECT_EQ(arr->size(), uintptr_t(statuses[j])); } } -- 2.34.1