Mark a few constants as constexpr so VLAs aren't required
authorChristopher Dykes <cdykes@fb.com>
Sat, 2 Jul 2016 04:31:35 +0000 (21:31 -0700)
committerFacebook Github Bot 2 <facebook-github-bot-2-bot@fb.com>
Sat, 2 Jul 2016 04:38:33 +0000 (21:38 -0700)
Summary: Because MSVC doesn't support VLAs.

Reviewed By: yfeldblum

Differential Revision: D3513143

fbshipit-source-id: 256e9e843004a3c37821b3dddc6ecd4c6b5645d9

folly/io/async/test/AsyncSocketTest2.cpp
folly/io/async/test/EventBaseTest.cpp
folly/test/AtomicHashMapTest.cpp

index ca6460315d6108332581f34a598cbc7b7524ff7a..602e9862e2b1857b49f5e67a59325f07070d1839 100644 (file)
@@ -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;
index cfea59919a66b759b807e14e26d3c00b15914c88..9efaf571eb7cae6233412efca37428cc03b6b391 100644 (file)
@@ -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<std::thread> threads;
index a8c6dff220e593268e9bd9784fa11687273b7e72..08162273a3ffa850555dc2c08b14e13d59885623 100644 (file)
@@ -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]));
     }
   }