Ensure curly-braces around control-flow
authorChristopher Dykes <cdykes@fb.com>
Thu, 19 Oct 2017 18:04:53 +0000 (11:04 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Thu, 19 Oct 2017 18:10:25 +0000 (11:10 -0700)
Summary: The style guidelines say control flow should always have curly braces, and we follow that, mostly. This just uses clang-tidy to clean up everywhere that we weren't.

Reviewed By: markisaa, luciang

Differential Revision: D6097377

fbshipit-source-id: bfe6766c37bd863ecf68851ef93265a200d4259d

70 files changed:
folly/AtomicHashMap-inl.h
folly/ConcurrentSkipList-inl.h
folly/ConcurrentSkipList.h
folly/Conv.h
folly/DiscriminatedPtr.h
folly/Expected.h
folly/FBString.h
folly/FBVector.h
folly/File.cpp
folly/FileUtil.h
folly/Fingerprint.h
folly/FixedString.h
folly/Foreach.h
folly/Format.cpp
folly/GroupVarint.h
folly/Lazy.h
folly/Malloc.h
folly/Memory.h
folly/MemoryMapping.cpp
folly/RWSpinLock.h
folly/String-inl.h
folly/Subprocess.cpp
folly/Unicode.cpp
folly/Varint.h
folly/concurrency/test/AtomicSharedPtrCounted.h
folly/concurrency/test/CoreCachedSharedPtrTest.cpp
folly/dynamic.cpp
folly/executors/test/ThreadPoolExecutorTest.cpp
folly/experimental/EliasFanoCoding.h
folly/experimental/EventCount.h
folly/experimental/flat_combining/test/FlatCombiningTestHelpers.h
folly/experimental/hazptr/bench/HazptrBench.h
folly/experimental/hazptr/example/LockFreeLIFO.h
folly/experimental/hazptr/example/SWMRList.h
folly/experimental/hazptr/example/WideCAS.h
folly/experimental/hazptr/hazptr-impl.h
folly/experimental/test/CodingTestUtils.h
folly/experimental/test/FlatCombiningPriorityQueueTest.cpp
folly/futures/Future-inl.h
folly/futures/ManualExecutor.cpp
folly/futures/ManualExecutor.h
folly/futures/Promise-inl.h
folly/futures/test/Benchmark.cpp
folly/futures/test/CollectTest.cpp
folly/futures/test/FSMTest.cpp
folly/futures/test/ViaTest.cpp
folly/gen/test/BaseTest.cpp
folly/hash/test/SpookyHashV1Test.cpp
folly/hash/test/SpookyHashV2Test.cpp
folly/io/IOBufQueue.h
folly/io/async/AsyncServerSocket.cpp
folly/io/async/AsyncSocket.cpp
folly/io/async/test/EventBaseTest.cpp
folly/sorted_vector_types.h
folly/test/AHMIntStressTest.cpp
folly/test/AtomicHashArrayTest.cpp
folly/test/AtomicHashMapTest.cpp
folly/test/ConcurrentSkipListBenchmark.cpp
folly/test/ConcurrentSkipListTest.cpp
folly/test/FBStringTest.cpp
folly/test/FBStringTestBenchmarks.cpp.h
folly/test/FBVectorTestBenchmarks.cpp.h
folly/test/FixedStringTest.cpp
folly/test/ForeachTest.cpp
folly/test/IndexedMemPoolTest.cpp
folly/test/RWSpinLockTest.cpp
folly/test/SynchronizedTestLib-inl.h
folly/test/TraitsTest.cpp
folly/test/sorted_vector_test.cpp
folly/test/stl_tests/StlVectorTest.cpp

index 2dc552559b36bce0e660d07eaf05c92b8ce9eaa3..b4032ab2b2444f890b5e242e52907adf1bcc6cf2 100644 (file)
@@ -439,7 +439,9 @@ AtomicHashMap<KeyT, ValueT, HashFcn, EqualFcn,
               Allocator, ProbeFcn, KeyConvertFcn>::
     encodeIndex(uint32_t subMap, uint32_t offset) {
   DCHECK_EQ(offset & kSecondaryMapBit_, 0);  // offset can't be too big
-  if (subMap == 0) return offset;
+  if (subMap == 0) {
+    return offset;
+  }
   // Make sure subMap isn't too big
   DCHECK_EQ(subMap >> kNumSubMapBits_, 0);
   // Make sure subMap bits of offset are clear
index ac6023aa4511d057678af6d7d4b70b4a824e5372..eca30ceb3d01265f30b7984e4db5d10c64704559 100644 (file)
@@ -138,7 +138,9 @@ class SkipListNode : private boost::noncopyable {
       height_(height), data_(std::forward<U>(data)) {
     spinLock_.init();
     setFlags(0);
-    if (isHead) setIsHeadNode();
+    if (isHead) {
+      setIsHeadNode();
+    }
     // need to explicitly init the dynamic atomic pointer array
     for (uint8_t i = 0; i < height_; ++i) {
       new (&skip_[i]) std::atomic<SkipListNode*>(nullptr);
index 1a2fdadcd5d6f71fb638aaa52b23de0689fa1548..7d511aadefd53ef5ed0f1355b92c6aeeb4c4fb02 100644 (file)
@@ -258,7 +258,9 @@ class ConcurrentSkipList {
   // Returns the node if found, nullptr otherwise.
   NodeType* find(const value_type &data) {
     auto ret = findNode(data);
-    if (ret.second && !ret.first->markedForRemoval()) return ret.first;
+    if (ret.second && !ret.first->markedForRemoval()) {
+      return ret.first;
+    }
     return nullptr;
   }
 
@@ -369,7 +371,9 @@ class ConcurrentSkipList {
         nodeToDelete = succs[layer];
         nodeHeight = nodeToDelete->height();
         nodeGuard = nodeToDelete->acquireGuard();
-        if (nodeToDelete->markedForRemoval()) return false;
+        if (nodeToDelete->markedForRemoval()) {
+          return false;
+        }
         nodeToDelete->setMarkedForRemoval();
         isMarked = true;
       }
@@ -402,7 +406,9 @@ class ConcurrentSkipList {
     for (int layer = maxLayer(); layer >= 0; --layer) {
       do {
         node = pred->skip(layer);
-        if (node) pred = node;
+        if (node) {
+          pred = node;
+        }
       } while (node != nullptr);
     }
     return pred == head_.load(std::memory_order_relaxed)
@@ -445,7 +451,9 @@ class ConcurrentSkipList {
     while (!found) {
       // stepping down
       for (; ht > 0 && less(data, node = pred->skip(ht - 1)); --ht) {}
-      if (ht == 0) return std::make_pair(node, 0);  // not found
+      if (ht == 0) {
+        return std::make_pair(node, 0); // not found
+      }
       // node <= data now, but we need to fix up ht
       --ht;
 
@@ -773,7 +781,9 @@ class ConcurrentSkipList<T, Comp, NodeAlloc, MAX_HEIGHT>::Skipper {
    */
   bool to(const value_type &data) {
     int layer = curHeight() - 1;
-    if (layer < 0) return false;   // reaches the end of the list
+    if (layer < 0) {
+      return false; // reaches the end of the list
+    }
 
     int lyr = hints_[layer];
     int max_layer = maxLayer();
@@ -784,7 +794,9 @@ class ConcurrentSkipList<T, Comp, NodeAlloc, MAX_HEIGHT>::Skipper {
 
     int foundLayer = SkipListType::
       findInsertionPoint(preds_[lyr], lyr, data, preds_, succs_);
-    if (foundLayer < 0) return false;
+    if (foundLayer < 0) {
+      return false;
+    }
 
     DCHECK(succs_[0] != nullptr) << "lyr=" << lyr
                                  << "; max_layer=" << max_layer;
index ff3bb81d7743cc24b5aaa0c157ac141b371abe96..351fd4f92d1a431ef3142b519b3ca94d917d94cc 100644 (file)
@@ -1426,8 +1426,9 @@ using ParseToResult = decltype(parseTo(StringPiece{}, std::declval<Tgt&>()));
 struct CheckTrailingSpace {
   Expected<Unit, ConversionCode> operator()(StringPiece sp) const {
     auto e = enforceWhitespaceErr(sp);
-    if (UNLIKELY(e != ConversionCode::SUCCESS))
+    if (UNLIKELY(e != ConversionCode::SUCCESS)) {
       return makeUnexpected(e);
+    }
     return unit;
   }
 };
index 2c57fb6ee75ccc7c1447166873e774f3c38e4b2f..f12e3d9cde660f4de83de7f325aa676b18cfc96d 100644 (file)
@@ -173,7 +173,9 @@ class DiscriminatedPtr {
   template <typename V>
   typename dptr_detail::VisitorResult<V, Types...>::type apply(V&& visitor) {
     size_t n = index();
-    if (n == 0) throw std::invalid_argument("Empty DiscriminatedPtr");
+    if (n == 0) {
+      throw std::invalid_argument("Empty DiscriminatedPtr");
+    }
     return dptr_detail::ApplyVisitor<V, Types...>()(
       n, std::forward<V>(visitor), ptr());
   }
@@ -182,7 +184,9 @@ class DiscriminatedPtr {
   typename dptr_detail::ConstVisitorResult<V, Types...>::type apply(V&& visitor)
   const {
     size_t n = index();
-    if (n == 0) throw std::invalid_argument("Empty DiscriminatedPtr");
+    if (n == 0) {
+      throw std::invalid_argument("Empty DiscriminatedPtr");
+    }
     return dptr_detail::ApplyConstVisitor<V, Types...>()(
       n, std::forward<V>(visitor), ptr());
   }
index 8f5d9a6496f5fd1a35d4d3574454462e2ba96f97..57098e28df18f3118816dd874887f0f61acaeb61 100644 (file)
@@ -460,8 +460,9 @@ struct ExpectedStorage<Value, Error, StorageType::eUnion>
   }
   template <class Other>
   void assign(Other&& that) {
-    if (isSelfAssign(&that))
+    if (isSelfAssign(&that)) {
       return;
+    }
     switch (that.which_) {
       case Which::eValue:
         this->assignValue(static_cast<Other&&>(that).value());
@@ -590,13 +591,14 @@ struct ExpectedHelper {
       T::template return_<E>(
           (std::declval<Fn>()(std::declval<This>().value()), unit)),
       std::declval<Fns>()...)) {
-    if (LIKELY(ex.which_ == expected_detail::Which::eValue))
+    if (LIKELY(ex.which_ == expected_detail::Which::eValue)) {
       return T::then_(
           T::template return_<E>(
               // Uses the comma operator defined above IFF the lambda
               // returns non-void.
               (static_cast<Fn&&>(fn)(static_cast<This&&>(ex).value()), unit)),
           static_cast<Fns&&>(fns)...);
+    }
     return makeUnexpected(static_cast<This&&>(ex).error());
   }
 
@@ -608,8 +610,9 @@ struct ExpectedHelper {
       class Err = decltype(std::declval<No>()(std::declval<This>().error()))
           FOLLY_REQUIRES_TRAILING(!std::is_void<Err>::value)>
   static Ret thenOrThrow_(This&& ex, Yes&& yes, No&& no) {
-    if (LIKELY(ex.which_ == expected_detail::Which::eValue))
+    if (LIKELY(ex.which_ == expected_detail::Which::eValue)) {
       return Ret(static_cast<Yes&&>(yes)(static_cast<This&&>(ex).value()));
+    }
     throw static_cast<No&&>(no)(static_cast<This&&>(ex).error());
   }
 
@@ -621,8 +624,9 @@ struct ExpectedHelper {
       class Err = decltype(std::declval<No>()(std::declval<This&>().error()))
           FOLLY_REQUIRES_TRAILING(std::is_void<Err>::value)>
   static Ret thenOrThrow_(This&& ex, Yes&& yes, No&& no) {
-    if (LIKELY(ex.which_ == expected_detail::Which::eValue))
+    if (LIKELY(ex.which_ == expected_detail::Which::eValue)) {
       return Ret(static_cast<Yes&&>(yes)(static_cast<This&&>(ex).value()));
+    }
     static_cast<No&&>(no)(ex.error());
     throw typename Unexpected<ExpectedErrorType<This>>::MakeBadExpectedAccess()(
         static_cast<This&&>(ex).error());
@@ -1041,8 +1045,9 @@ class Expected final : expected_detail::ExpectedStorage<Value, Error> {
    */
   void swap(Expected& that) noexcept(
       expected_detail::StrictAllOf<IsNothrowSwappable, Value, Error>::value) {
-    if (this->uninitializedByException() || that.uninitializedByException())
+    if (this->uninitializedByException() || that.uninitializedByException()) {
       throw BadExpectedAccess();
+    }
     using std::swap;
     if (*this) {
       if (that) {
@@ -1180,8 +1185,9 @@ class Expected final : expected_detail::ExpectedStorage<Value, Error> {
       expected_detail::ExpectedHelper::then_(
           std::declval<const Base&>(),
           std::declval<Fns>()...)) {
-    if (this->uninitializedByException())
+    if (this->uninitializedByException()) {
       throw BadExpectedAccess();
+    }
     return expected_detail::ExpectedHelper::then_(
         base(), static_cast<Fns&&>(fns)...);
   }
@@ -1190,8 +1196,9 @@ class Expected final : expected_detail::ExpectedStorage<Value, Error> {
   auto then(Fns&&... fns) & -> decltype(expected_detail::ExpectedHelper::then_(
       std::declval<Base&>(),
       std::declval<Fns>()...)) {
-    if (this->uninitializedByException())
+    if (this->uninitializedByException()) {
       throw BadExpectedAccess();
+    }
     return expected_detail::ExpectedHelper::then_(
         base(), static_cast<Fns&&>(fns)...);
   }
@@ -1200,8 +1207,9 @@ class Expected final : expected_detail::ExpectedStorage<Value, Error> {
   auto then(Fns&&... fns) && -> decltype(expected_detail::ExpectedHelper::then_(
       std::declval<Base&&>(),
       std::declval<Fns>()...)) {
-    if (this->uninitializedByException())
+    if (this->uninitializedByException()) {
       throw BadExpectedAccess();
+    }
     return expected_detail::ExpectedHelper::then_(
         std::move(base()), static_cast<Fns&&>(fns)...);
   }
@@ -1213,8 +1221,9 @@ class Expected final : expected_detail::ExpectedStorage<Value, Error> {
   auto thenOrThrow(Yes&& yes, No&& no = No{}) const& -> decltype(
       std::declval<Yes>()(std::declval<const Value&>())) {
     using Ret = decltype(std::declval<Yes>()(std::declval<const Value&>()));
-    if (this->uninitializedByException())
+    if (this->uninitializedByException()) {
       throw BadExpectedAccess();
+    }
     return Ret(expected_detail::ExpectedHelper::thenOrThrow_(
         base(), static_cast<Yes&&>(yes), static_cast<No&&>(no)));
   }
@@ -1223,8 +1232,9 @@ class Expected final : expected_detail::ExpectedStorage<Value, Error> {
   auto thenOrThrow(Yes&& yes, No&& no = No{}) & -> decltype(
       std::declval<Yes>()(std::declval<Value&>())) {
     using Ret = decltype(std::declval<Yes>()(std::declval<Value&>()));
-    if (this->uninitializedByException())
+    if (this->uninitializedByException()) {
       throw BadExpectedAccess();
+    }
     return Ret(expected_detail::ExpectedHelper::thenOrThrow_(
         base(), static_cast<Yes&&>(yes), static_cast<No&&>(no)));
   }
@@ -1233,8 +1243,9 @@ class Expected final : expected_detail::ExpectedStorage<Value, Error> {
   auto thenOrThrow(Yes&& yes, No&& no = No{}) && -> decltype(
       std::declval<Yes>()(std::declval<Value&&>())) {
     using Ret = decltype(std::declval<Yes>()(std::declval<Value&&>()));
-    if (this->uninitializedByException())
+    if (this->uninitializedByException()) {
       throw BadExpectedAccess();
+    }
     return Ret(expected_detail::ExpectedHelper::thenOrThrow_(
         std::move(base()), static_cast<Yes&&>(yes), static_cast<No&&>(no)));
   }
@@ -1242,8 +1253,9 @@ class Expected final : expected_detail::ExpectedStorage<Value, Error> {
  private:
   void requireValue() const {
     if (UNLIKELY(!hasValue())) {
-      if (LIKELY(hasError()))
+      if (LIKELY(hasError())) {
         throw typename Unexpected<Error>::BadExpectedAccess(this->error_);
+      }
       throw BadExpectedAccess();
     }
   }
@@ -1264,13 +1276,16 @@ inline typename std::enable_if<IsEqualityComparable<Value>::value, bool>::type
 operator==(
     const Expected<Value, Error>& lhs,
     const Expected<Value, Error>& rhs) {
-  if (UNLIKELY(lhs.which_ != rhs.which_))
+  if (UNLIKELY(lhs.which_ != rhs.which_)) {
     return UNLIKELY(lhs.uninitializedByException()) ? false
                                                     : throw BadExpectedAccess();
-  if (UNLIKELY(lhs.uninitializedByException()))
+  }
+  if (UNLIKELY(lhs.uninitializedByException())) {
     throw BadExpectedAccess();
-  if (UNLIKELY(lhs.hasError()))
+  }
+  if (UNLIKELY(lhs.hasError())) {
     return true; // All error states are considered equal
+  }
   return lhs.value_ == rhs.value_;
 }
 
@@ -1289,12 +1304,15 @@ operator<(
     const Expected<Value, Error>& lhs,
     const Expected<Value, Error>& rhs) {
   if (UNLIKELY(
-          lhs.uninitializedByException() || rhs.uninitializedByException()))
+          lhs.uninitializedByException() || rhs.uninitializedByException())) {
     throw BadExpectedAccess();
-  if (UNLIKELY(lhs.hasError()))
+  }
+  if (UNLIKELY(lhs.hasError())) {
     return !rhs.hasError();
-  if (UNLIKELY(rhs.hasError()))
+  }
+  if (UNLIKELY(rhs.hasError())) {
     return false;
+  }
   return lhs.value_ < rhs.value_;
 }
 
index b566d1191cffa9bc063190c192aad7d533da3cdf..731b3d9c466100f01ea0fe89ec57f7aa11a63361 100644 (file)
@@ -1420,7 +1420,9 @@ class basic_fbstring {
   }
 
   basic_fbstring& assign(const basic_fbstring& str) {
-    if (&str == this) return *this;
+    if (&str == this) {
+      return *this;
+    }
     return assign(str.data(), str.size());
   }
 
index 21253afe474b2ef86b1d86e628f6b846cb29d0f0..c52c350141dbadff0bd6c5cace879e3a4996e870 100644 (file)
@@ -184,7 +184,9 @@ class fbvector {
 
   static void swap(Impl& a, Impl& b) {
     using std::swap;
-    if (!usingStdAllocator::value) swap<Allocator>(a, b);
+    if (!usingStdAllocator::value) {
+      swap<Allocator>(a, b);
+    }
     a.swapData(b);
   }
 
@@ -318,8 +320,9 @@ class fbvector {
 
   void M_destroy(T* p) noexcept {
     if (usingStdAllocator::value) {
-      if (!std::is_trivially_destructible<T>::value)
+      if (!std::is_trivially_destructible<T>::value) {
         p->~T();
+      }
     } else {
       std::allocator_traits<Allocator>::destroy(impl_, p);
     }
@@ -350,8 +353,9 @@ class fbvector {
 
   // allocator
   static void S_destroy_range_a(Allocator& a, T* first, T* last) noexcept {
-    for (; first != last; ++first)
+    for (; first != last; ++first) {
       std::allocator_traits<Allocator>::destroy(a, first);
+    }
   }
 
   // optimized
@@ -412,9 +416,10 @@ class fbvector {
     auto b = dest;
     auto e = dest + sz;
     try {
-      for (; b != e; ++b)
+      for (; b != e; ++b) {
         std::allocator_traits<Allocator>::construct(a, b,
           std::forward<Args>(args)...);
+      }
     } catch (...) {
       S_destroy_range_a(a, dest, b);
       throw;
@@ -431,10 +436,14 @@ class fbvector {
       auto b = dest;
       auto e = dest + n;
       try {
-        for (; b != e; ++b) S_construct(b);
+        for (; b != e; ++b) {
+          S_construct(b);
+        }
       } catch (...) {
         --b;
-        for (; b >= dest; --b) b->~T();
+        for (; b >= dest; --b) {
+          b->~T();
+        }
         throw;
       }
     }
@@ -444,7 +453,9 @@ class fbvector {
     auto b = dest;
     auto e = dest + n;
     try {
-      for (; b != e; ++b) S_construct(b, value);
+      for (; b != e; ++b) {
+        S_construct(b, value);
+      }
     } catch (...) {
       S_destroy_range(dest, b);
       throw;
@@ -496,8 +507,9 @@ class fbvector {
   S_uninitialized_copy_a(Allocator& a, T* dest, It first, It last) {
     auto b = dest;
     try {
-      for (; first != last; ++first, ++b)
+      for (; first != last; ++first, ++b) {
         std::allocator_traits<Allocator>::construct(a, b, *first);
+      }
     } catch (...) {
       S_destroy_range_a(a, dest, b);
       throw;
@@ -509,8 +521,9 @@ class fbvector {
   static void S_uninitialized_copy(T* dest, It first, It last) {
     auto b = dest;
     try {
-      for (; first != last; ++first, ++b)
+      for (; first != last; ++first, ++b) {
         S_construct(b, *first);
+      }
     } catch (...) {
       S_destroy_range(dest, b);
       throw;
@@ -550,7 +563,9 @@ class fbvector {
   template <typename It>
   static It S_copy_n(T* dest, It first, size_type n) {
     auto e = dest + n;
-    for (; dest != e; ++dest, ++first) *dest = *first;
+    for (; dest != e; ++dest, ++first) {
+      *dest = *first;
+    }
     return first;
   }
 
@@ -725,7 +740,9 @@ class fbvector {
   ~fbvector() = default; // the cleanup occurs in impl_
 
   fbvector& operator=(const fbvector& other) {
-    if (UNLIKELY(this == &other)) return *this;
+    if (UNLIKELY(this == &other)) {
+      return *this;
+    }
 
     if (!usingStdAllocator::value &&
         A::propagate_on_container_copy_assignment::value) {
@@ -741,7 +758,9 @@ class fbvector {
   }
 
   fbvector& operator=(fbvector&& other) {
-    if (UNLIKELY(this == &other)) return *this;
+    if (UNLIKELY(this == &other)) {
+      return *this;
+    }
     moveFrom(std::move(other), moveIsSwap());
     return *this;
   }
@@ -796,10 +815,16 @@ class fbvector {
     { M_uninitialized_copy_e(first, last); }
 
   template <class InputIterator>
-  fbvector(InputIterator first, InputIterator last,
-           const Allocator& a, std::input_iterator_tag)
-    : impl_(a)
-    { for (; first != last; ++first) emplace_back(*first); }
+  fbvector(
+      InputIterator first,
+      InputIterator last,
+      const Allocator& a,
+      std::input_iterator_tag)
+      : impl_(a) {
+    for (; first != last; ++first) {
+      emplace_back(*first);
+    }
+  }
 
   // contract dispatch for allocator movement in operator=(fbvector&&)
   void
@@ -842,13 +867,17 @@ class fbvector {
     if (p != impl_.e_) {
       M_destroy_range_e(p);
     } else {
-      for (; first != last; ++first) emplace_back(*first);
+      for (; first != last; ++first) {
+        emplace_back(*first);
+      }
     }
   }
 
   // contract dispatch for aliasing under VT optimization
   bool dataIsInternalAndNotVT(const T& t) {
-    if (should_pass_by_value::value) return false;
+    if (should_pass_by_value::value) {
+      return false;
+    }
     return dataIsInternal(t);
   }
   bool dataIsInternal(const T& t) {
@@ -943,8 +972,12 @@ class fbvector {
   }
 
   void reserve(size_type n) {
-    if (n <= capacity()) return;
-    if (impl_.b_ && reserve_in_place(n)) return;
+    if (n <= capacity()) {
+      return;
+    }
+    if (impl_.b_ && reserve_in_place(n)) {
+      return;
+    }
 
     auto newCap = folly::goodMallocSize(n * sizeof(T)) / sizeof(T);
     auto newB = M_allocate(newCap);
@@ -954,8 +987,9 @@ class fbvector {
       M_deallocate(newB, newCap);
       throw;
     }
-    if (impl_.b_)
+    if (impl_.b_) {
       M_deallocate(impl_.b_, size_type(impl_.z_ - impl_.b_));
+    }
     impl_.z_ = newB + newCap;
     impl_.e_ = newB + (impl_.e_ - impl_.b_);
     impl_.b_ = newB;
@@ -971,7 +1005,9 @@ class fbvector {
     auto const newCap = newCapacityBytes / sizeof(T);
     auto const oldCap = capacity();
 
-    if (newCap >= oldCap) return;
+    if (newCap >= oldCap) {
+      return;
+    }
 
     void* p = impl_.b_;
     // xallocx() will shrink to precisely newCapacityBytes (which was generated
@@ -993,8 +1029,9 @@ class fbvector {
       } catch (...) {
         return;
       }
-      if (impl_.b_)
+      if (impl_.b_) {
         M_deallocate(impl_.b_, size_type(impl_.z_ - impl_.b_));
+      }
       impl_.z_ = newB + newCap;
       impl_.e_ = newB + (impl_.e_ - impl_.b_);
       impl_.b_ = newB;
@@ -1003,11 +1040,15 @@ class fbvector {
 
  private:
   bool reserve_in_place(size_type n) {
-    if (!usingStdAllocator::value || !usingJEMalloc()) return false;
+    if (!usingStdAllocator::value || !usingJEMalloc()) {
+      return false;
+    }
 
     // jemalloc can never grow in place blocks smaller than 4096 bytes.
     if ((impl_.z_ - impl_.b_) * sizeof(T) <
-      folly::jemallocMinInPlaceExpandable) return false;
+        folly::jemallocMinInPlaceExpandable) {
+      return false;
+    }
 
     auto const newCapacityBytes = folly::goodMallocSize(n * sizeof(T));
     void* p = impl_.b_;
@@ -1109,10 +1150,11 @@ class fbvector {
   }
 
   void swap(fbvector& other) noexcept {
-    if (!usingStdAllocator::value &&
-        A::propagate_on_container_swap::value)
+    if (!usingStdAllocator::value && A::propagate_on_container_swap::value) {
       swap(impl_, other.impl_);
-    else impl_.swapData(other.impl_);
+    } else {
+      impl_.swapData(other.impl_);
+    }
   }
 
   void clear() noexcept {
@@ -1313,12 +1355,18 @@ class fbvector {
 
   bool insert_use_fresh(bool at_end, size_type n) {
     if (at_end) {
-      if (size() + n <= capacity()) return false;
-      if (reserve_in_place(size() + n)) return false;
+      if (size() + n <= capacity()) {
+        return false;
+      }
+      if (reserve_in_place(size() + n)) {
+        return false;
+      }
       return true;
     }
 
-    if (size() + n > capacity()) return true;
+    if (size() + n > capacity()) {
+      return true;
+    }
 
     return false;
   }
@@ -1484,7 +1532,9 @@ class fbvector {
                      std::make_move_iterator(end()),
                      A::select_on_container_copy_construction(impl_));
     M_destroy_range_e(position);
-    for (; first != last; ++first) emplace_back(*first);
+    for (; first != last; ++first) {
+      emplace_back(*first);
+    }
     insert(cend(), std::make_move_iterator(storage.begin()),
            std::make_move_iterator(storage.end()));
     return impl_.b_ + idx;
@@ -1597,7 +1647,9 @@ void fbvector<T, Allocator>::emplace_back_aux(Args&&... args) {
     M_deallocate(newB, sz);
     throw;
   }
-  if (impl_.b_) M_deallocate(impl_.b_, size());
+  if (impl_.b_) {
+    M_deallocate(impl_.b_, size());
+  }
   impl_.b_ = newB;
   impl_.e_ = newE;
   impl_.z_ = newB + sz;
index 74d8669ef1fc29852e935764609fb56877b9ff4e..9fb755a8468e37a2c212f18f8369ef3faa211803 100644 (file)
@@ -138,7 +138,9 @@ void File::doLock(int op) {
 bool File::doTryLock(int op) {
   int r = flockNoInt(fd_, op | LOCK_NB);
   // flock returns EWOULDBLOCK if already locked
-  if (r == -1 && errno == EWOULDBLOCK) return false;
+  if (r == -1 && errno == EWOULDBLOCK) {
+    return false;
+  }
   checkUnixError(r, "flock() failed (try_lock)");
   return true;
 }
index 92598093a836a0df1f5535f2809765722da10352..0913b23d2385510a86928ee2e347e0b3d767df0f 100644 (file)
@@ -131,7 +131,9 @@ bool readFile(
 
   // Obtain file size:
   struct stat buf;
-  if (fstat(fd, &buf) == -1) return false;
+  if (fstat(fd, &buf) == -1) {
+    return false;
+  }
   // Some files (notably under /proc and /sys on Linux) lie about
   // their size, so treat the size advertised by fstat under advise
   // but don't rely on it. In particular, if the size is zero, we
index 558cfd597bccdaefac89ae376401bbcd017f85ec..26d1dc9b1a3818c4f2012bb79c5106d68243fda5 100644 (file)
@@ -99,8 +99,9 @@ class Fingerprint {
   Fingerprint() {
     // Use a non-zero starting value. We'll use (1 << (BITS-1))
     fp_[0] = 1ULL << 63;
-    for (int i = 1; i < size(); i++)
+    for (int i = 1; i < size(); i++) {
       fp_[i] = 0;
+    }
   }
 
   Fingerprint& update8(uint8_t v) {
index 732ae6ac61ae0df886e5462992f8edb88d3de7f0..d91ce1a0dddce8e459ee1e070e70ecf944e9aa1e 100644 (file)
@@ -1242,8 +1242,9 @@ class BasicFixedString : private detail::fixedstring::FixedStringBase {
       std::size_t count,
       Char ch) noexcept(false) {
     detail::fixedstring::checkOverflow(count, N - size_);
-    for (std::size_t i = 0u; i < count; ++i)
+    for (std::size_t i = 0u; i < count; ++i) {
       data_[size_ + i] = ch;
+    }
     size_ += count;
     data_[size_] = Char(0);
     return *this;
@@ -1290,8 +1291,9 @@ class BasicFixedString : private detail::fixedstring::FixedStringBase {
     detail::fixedstring::checkOverflow(pos, that.size_);
     count = detail::fixedstring::checkOverflowOrNpos(count, that.size_ - pos);
     detail::fixedstring::checkOverflow(count, N - size_);
-    for (std::size_t i = 0u; i < count; ++i)
+    for (std::size_t i = 0u; i < count; ++i) {
       data_[size_ + i] = that.data_[pos + i];
+    }
     size_ += count;
     data_[size_] = Char(0);
     return *this;
@@ -1318,8 +1320,9 @@ class BasicFixedString : private detail::fixedstring::FixedStringBase {
       const Char* that,
       std::size_t count) noexcept(false) {
     detail::fixedstring::checkOverflow(count, N - size_);
-    for (std::size_t i = 0u; i < count; ++i)
+    for (std::size_t i = 0u; i < count; ++i) {
       data_[size_ + i] = that[i];
+    }
     size_ += count;
     data_[size_] = Char(0);
     return *this;
@@ -2027,8 +2030,9 @@ class BasicFixedString : private detail::fixedstring::FixedStringBase {
   copy(Char* dest, std::size_t count, std::size_t pos) const noexcept(false) {
     detail::fixedstring::checkOverflow(pos, size_);
     for (std::size_t i = 0u; i < count; ++i) {
-      if (i + pos == size_)
+      if (i + pos == size_) {
         return size_;
+      }
       dest[i] = data_[i + pos];
     }
     return count;
index 34d074f10bb9631401ddbc7d888a6154d5c92eaa..50740f40dc1243c000bf27daeb5ac47a277eaa43 100644 (file)
@@ -291,7 +291,9 @@ downTo(T& iter, const U& begin) {
 template <class T, class U>
 typename std::enable_if<!HasLess<U, T>::value, bool>::type
 downTo(T& iter, const U& begin) {
-  if (iter == begin) return false;
+  if (iter == begin) {
+    return false;
+  }
   --iter;
   return true;
 }
index bbcd2d004dec69f155331f26652c8ab3d963e616..380cddbe418788ecdfabad7e686c820997661fa0 100644 (file)
@@ -179,7 +179,9 @@ void FormatArg::initSlow() {
 
   if (*p == ':') {
     // parse format spec
-    if (++p == end) return;
+    if (++p == end) {
+      return;
+    }
 
     // fill/align, or just align
     Align a;
@@ -189,30 +191,40 @@ void FormatArg::initSlow() {
       fill = *p;
       align = a;
       p += 2;
-      if (p == end) return;
+      if (p == end) {
+        return;
+      }
     } else if ((a = formatAlignTable[static_cast<unsigned char>(*p)]) !=
                Align::INVALID) {
       align = a;
-      if (++p == end) return;
+      if (++p == end) {
+        return;
+      }
     }
 
     Sign s;
     unsigned char uSign = static_cast<unsigned char>(*p);
     if ((s = formatSignTable[uSign]) != Sign::INVALID) {
       sign = s;
-      if (++p == end) return;
+      if (++p == end) {
+        return;
+      }
     }
 
     if (*p == '#') {
       basePrefix = true;
-      if (++p == end) return;
+      if (++p == end) {
+        return;
+      }
     }
 
     if (*p == '0') {
       enforce(align == Align::DEFAULT, "alignment specified twice");
       fill = '0';
       align = Align::PAD_AFTER_SIGN;
-      if (++p == end) return;
+      if (++p == end) {
+        return;
+      }
     }
 
     auto readInt = [&] {
@@ -227,20 +239,30 @@ void FormatArg::initSlow() {
       width = kDynamicWidth;
       ++p;
 
-      if (p == end) return;
+      if (p == end) {
+        return;
+      }
 
-      if (*p >= '0' && *p <= '9') widthIndex = readInt();
+      if (*p >= '0' && *p <= '9') {
+        widthIndex = readInt();
+      }
 
-      if (p == end) return;
+      if (p == end) {
+        return;
+      }
     } else if (*p >= '0' && *p <= '9') {
       width = readInt();
 
-      if (p == end) return;
+      if (p == end) {
+        return;
+      }
     }
 
     if (*p == ',') {
       thousandsSeparator = true;
-      if (++p == end) return;
+      if (++p == end) {
+        return;
+      }
     }
 
     if (*p == '.') {
@@ -258,11 +280,15 @@ void FormatArg::initSlow() {
         trailingDot = true;
       }
 
-      if (p == end) return;
+      if (p == end) {
+        return;
+      }
     }
 
     presentation = *p;
-    if (++p == end) return;
+    if (++p == end) {
+      return;
+    }
   }
 
   error("extra characters in format string");
index 6f1807d20eff314517f51c3f9290cc6ea07c86ed..ed7dae63192456a486232054511aaef2949ea1df 100644 (file)
@@ -107,13 +107,21 @@ class GroupVarint<uint32_t> : public detail::GroupVarintBase<uint32_t> {
     uint8_t v = uint8_t(*p);
     size_t s = kHeaderSize;
     s += 1 + b0key(v);
-    if (s > size) return 0;
+    if (s > size) {
+      return 0;
+    }
     s += 1 + b1key(v);
-    if (s > size) return 1;
+    if (s > size) {
+      return 1;
+    }
     s += 1 + b2key(v);
-    if (s > size) return 2;
+    if (s > size) {
+      return 2;
+    }
     s += 1 + b3key(v);
-    if (s > size) return 3;
+    if (s > size) {
+      return 3;
+    }
     return 4;
   }
 
@@ -312,15 +320,25 @@ class GroupVarint<uint64_t> : public detail::GroupVarintBase<uint64_t> {
     uint16_t v = loadUnaligned<uint16_t>(p);
     size_t s = kHeaderSize;
     s += 1 + b0key(v);
-    if (s > size) return 0;
+    if (s > size) {
+      return 0;
+    }
     s += 1 + b1key(v);
-    if (s > size) return 1;
+    if (s > size) {
+      return 1;
+    }
     s += 1 + b2key(v);
-    if (s > size) return 2;
+    if (s > size) {
+      return 2;
+    }
     s += 1 + b3key(v);
-    if (s > size) return 3;
+    if (s > size) {
+      return 3;
+    }
     s += 1 + b4key(v);
-    if (s > size) return 4;
+    if (s > size) {
+      return 4;
+    }
     return 5;
   }
 
index afab2faa830274cae31a31e866cdc7545955a455..a4fcfd359810be170a731aaa997039845d3b0af0 100644 (file)
@@ -107,7 +107,9 @@ struct Lazy {
   }
 
   result_type& operator()() {
-    if (!value_) value_ = func_();
+    if (!value_) {
+      value_ = func_();
+    }
     return *value_;
   }
 
index 388a16679197fbcde64a278f2652e6d588904471..71f37ca2c3094f7908211b54e00f0f769c8d4b29 100644 (file)
@@ -223,19 +223,25 @@ static const size_t jemallocMinInPlaceExpandable = 4096;
  */
 inline void* checkedMalloc(size_t size) {
   void* p = malloc(size);
-  if (!p) std::__throw_bad_alloc();
+  if (!p) {
+    std::__throw_bad_alloc();
+  }
   return p;
 }
 
 inline void* checkedCalloc(size_t n, size_t size) {
   void* p = calloc(n, size);
-  if (!p) std::__throw_bad_alloc();
+  if (!p) {
+    std::__throw_bad_alloc();
+  }
   return p;
 }
 
 inline void* checkedRealloc(void* ptr, size_t size) {
   void* p = realloc(ptr, size);
-  if (!p) std::__throw_bad_alloc();
+  if (!p) {
+    std::__throw_bad_alloc();
+  }
   return p;
 }
 
index 121f43dbdd53803a2029d5703d8042946e9b8f6e..c17662774b1aac670f6c4ece4ae216f6f28e1896 100644 (file)
@@ -171,7 +171,9 @@ class SysAlloc {
  public:
   void* allocate(size_t size) {
     void* p = ::malloc(size);
-    if (!p) throw std::bad_alloc();
+    if (!p) {
+      throw std::bad_alloc();
+    }
     return p;
   }
   void deallocate(void* p) {
@@ -340,7 +342,9 @@ class allocator_delete
   }
 
   void operator()(pointer p) const {
-    if (!p) return;
+    if (!p) {
+      return;
+    }
     const_cast<allocator_delete*>(this)->destroy(p);
     const_cast<allocator_delete*>(this)->deallocate(p, 1);
   }
index 5165c0735500f504644272b9c1a135d73186c1ab..30d6a1feecb76439042c462b026f14f9ec12a201 100644 (file)
@@ -177,8 +177,12 @@ void MemoryMapping::init(off_t offset, off_t length) {
     mapStart_ = nullptr;
   } else {
     int flags = options_.shared ? MAP_SHARED : MAP_PRIVATE;
-    if (anon) flags |= MAP_ANONYMOUS;
-    if (options_.prefault) flags |= MAP_POPULATE;
+    if (anon) {
+      flags |= MAP_ANONYMOUS;
+    }
+    if (options_.prefault) {
+      flags |= MAP_POPULATE;
+    }
 
     // The standard doesn't actually require PROT_NONE to be zero...
     int prot = PROT_NONE;
@@ -280,7 +284,9 @@ bool MemoryMapping::mlock(LockMode lock) {
 }
 
 void MemoryMapping::munlock(bool dontneed) {
-  if (!locked_) return;
+  if (!locked_) {
+    return;
+  }
 
   size_t amountSucceeded = 0;
   if (!memOpInChunks(
index 3cce0d90603ef02b1dafec7ac5581279a1d020d4..8edd6b3279679d82c68e0c8614b594e539939c8d 100644 (file)
@@ -192,7 +192,9 @@ class RWSpinLock {
   void lock() {
     uint_fast32_t count = 0;
     while (!LIKELY(try_lock())) {
-      if (++count > 1000) std::this_thread::yield();
+      if (++count > 1000) {
+        std::this_thread::yield();
+      }
     }
   }
 
@@ -206,7 +208,9 @@ class RWSpinLock {
   void lock_shared() {
     uint_fast32_t count = 0;
     while (!LIKELY(try_lock_shared())) {
-      if (++count > 1000) std::this_thread::yield();
+      if (++count > 1000) {
+        std::this_thread::yield();
+      }
     }
   }
 
@@ -224,7 +228,9 @@ class RWSpinLock {
   void lock_upgrade() {
     uint_fast32_t count = 0;
     while (!try_lock_upgrade()) {
-      if (++count > 1000) std::this_thread::yield();
+      if (++count > 1000) {
+        std::this_thread::yield();
+      }
     }
   }
 
@@ -236,7 +242,9 @@ class RWSpinLock {
   void unlock_upgrade_and_lock() {
     int64_t count = 0;
     while (!try_unlock_upgrade_and_lock()) {
-      if (++count > 1000) std::this_thread::yield();
+      if (++count > 1000) {
+        std::this_thread::yield();
+      }
     }
   }
 
@@ -306,7 +314,9 @@ class RWSpinLock {
   class ReadHolder {
    public:
     explicit ReadHolder(RWSpinLock* lock) : lock_(lock) {
-      if (lock_) lock_->lock_shared();
+      if (lock_) {
+        lock_->lock_shared();
+      }
     }
 
     explicit ReadHolder(RWSpinLock& lock) : lock_(&lock) {
@@ -320,12 +330,16 @@ class RWSpinLock {
     // down-grade
     explicit ReadHolder(UpgradedHolder&& upgraded) : lock_(upgraded.lock_) {
       upgraded.lock_ = nullptr;
-      if (lock_) lock_->unlock_upgrade_and_lock_shared();
+      if (lock_) {
+        lock_->unlock_upgrade_and_lock_shared();
+      }
     }
 
     explicit ReadHolder(WriteHolder&& writer) : lock_(writer.lock_) {
       writer.lock_ = nullptr;
-      if (lock_) lock_->unlock_and_lock_shared();
+      if (lock_) {
+        lock_->unlock_and_lock_shared();
+      }
     }
 
     ReadHolder& operator=(ReadHolder&& other) {
@@ -337,13 +351,23 @@ class RWSpinLock {
     ReadHolder(const ReadHolder& other) = delete;
     ReadHolder& operator=(const ReadHolder& other) = delete;
 
-    ~ReadHolder() { if (lock_) lock_->unlock_shared(); }
+    ~ReadHolder() {
+      if (lock_) {
+        lock_->unlock_shared();
+      }
+    }
 
     void reset(RWSpinLock* lock = nullptr) {
-      if (lock == lock_) return;
-      if (lock_) lock_->unlock_shared();
+      if (lock == lock_) {
+        return;
+      }
+      if (lock_) {
+        lock_->unlock_shared();
+      }
       lock_ = lock;
-      if (lock_) lock_->lock_shared();
+      if (lock_) {
+        lock_->lock_shared();
+      }
     }
 
     void swap(ReadHolder* other) {
@@ -359,7 +383,9 @@ class RWSpinLock {
   class UpgradedHolder {
    public:
     explicit UpgradedHolder(RWSpinLock* lock) : lock_(lock) {
-      if (lock_) lock_->lock_upgrade();
+      if (lock_) {
+        lock_->lock_upgrade();
+      }
     }
 
     explicit UpgradedHolder(RWSpinLock& lock) : lock_(&lock) {
@@ -369,7 +395,9 @@ class RWSpinLock {
     explicit UpgradedHolder(WriteHolder&& writer) {
       lock_ = writer.lock_;
       writer.lock_ = nullptr;
-      if (lock_) lock_->unlock_and_lock_upgrade();
+      if (lock_) {
+        lock_->unlock_and_lock_upgrade();
+      }
     }
 
     UpgradedHolder(UpgradedHolder&& other) noexcept : lock_(other.lock_) {
@@ -385,13 +413,23 @@ class RWSpinLock {
     UpgradedHolder(const UpgradedHolder& other) = delete;
     UpgradedHolder& operator =(const UpgradedHolder& other) = delete;
 
-    ~UpgradedHolder() { if (lock_) lock_->unlock_upgrade(); }
+    ~UpgradedHolder() {
+      if (lock_) {
+        lock_->unlock_upgrade();
+      }
+    }
 
     void reset(RWSpinLock* lock = nullptr) {
-      if (lock == lock_) return;
-      if (lock_) lock_->unlock_upgrade();
+      if (lock == lock_) {
+        return;
+      }
+      if (lock_) {
+        lock_->unlock_upgrade();
+      }
       lock_ = lock;
-      if (lock_) lock_->lock_upgrade();
+      if (lock_) {
+        lock_->lock_upgrade();
+      }
     }
 
     void swap(UpgradedHolder* other) {
@@ -408,7 +446,9 @@ class RWSpinLock {
   class WriteHolder {
    public:
     explicit WriteHolder(RWSpinLock* lock) : lock_(lock) {
-      if (lock_) lock_->lock();
+      if (lock_) {
+        lock_->lock();
+      }
     }
 
     explicit WriteHolder(RWSpinLock& lock) : lock_(&lock) {
@@ -419,7 +459,9 @@ class RWSpinLock {
     explicit WriteHolder(UpgradedHolder&& upgraded) {
       lock_ = upgraded.lock_;
       upgraded.lock_ = nullptr;
-      if (lock_) lock_->unlock_upgrade_and_lock();
+      if (lock_) {
+        lock_->unlock_upgrade_and_lock();
+      }
     }
 
     WriteHolder(WriteHolder&& other) noexcept : lock_(other.lock_) {
@@ -435,13 +477,23 @@ class RWSpinLock {
     WriteHolder(const WriteHolder& other) = delete;
     WriteHolder& operator =(const WriteHolder& other) = delete;
 
-    ~WriteHolder () { if (lock_) lock_->unlock(); }
+    ~WriteHolder() {
+      if (lock_) {
+        lock_->unlock();
+      }
+    }
 
     void reset(RWSpinLock* lock = nullptr) {
-      if (lock == lock_) return;
-      if (lock_) lock_->unlock();
+      if (lock == lock_) {
+        return;
+      }
+      if (lock_) {
+        lock_->unlock();
+      }
       lock_ = lock;
-      if (lock_) lock_->lock();
+      if (lock_) {
+        lock_->lock();
+      }
     }
 
     void swap(WriteHolder* other) {
@@ -586,7 +638,9 @@ class RWTicketSpinLockT {
   bool try_lock() {
     RWTicket t;
     FullInt old = t.whole = load_acquire(&ticket.whole);
-    if (t.users != t.write) return false;
+    if (t.users != t.write) {
+      return false;
+    }
     ++t.users;
     return __sync_bool_compare_and_swap(&ticket.whole, old, t.whole);
   }
@@ -607,7 +661,9 @@ class RWTicketSpinLockT {
     QuarterInt val = __sync_fetch_and_add(&ticket.users, 1);
     while (val != load_acquire(&ticket.write)) {
       asm_volatile_pause();
-      if (UNLIKELY(++count > 1000)) std::this_thread::yield();
+      if (UNLIKELY(++count > 1000)) {
+        std::this_thread::yield();
+      }
     }
   }
 
@@ -656,7 +712,9 @@ class RWTicketSpinLockT {
     uint_fast32_t count = 0;
     while (!LIKELY(try_lock_shared())) {
       asm_volatile_pause();
-      if (UNLIKELY((++count & 1023) == 0)) std::this_thread::yield();
+      if (UNLIKELY((++count & 1023) == 0)) {
+        std::this_thread::yield();
+      }
     }
   }
 
@@ -690,11 +748,15 @@ class RWTicketSpinLockT {
     ReadHolder& operator=(ReadHolder const&) = delete;
 
     explicit ReadHolder(RWSpinLock* lock) : lock_(lock) {
-      if (lock_) lock_->lock_shared();
+      if (lock_) {
+        lock_->lock_shared();
+      }
     }
 
     explicit ReadHolder(RWSpinLock &lock) : lock_ (&lock) {
-      if (lock_) lock_->lock_shared();
+      if (lock_) {
+        lock_->lock_shared();
+      }
     }
 
     // atomically unlock the write-lock from writer and acquire the read-lock
@@ -706,13 +768,19 @@ class RWTicketSpinLockT {
     }
 
     ~ReadHolder() {
-      if (lock_) lock_->unlock_shared();
+      if (lock_) {
+        lock_->unlock_shared();
+      }
     }
 
     void reset(RWSpinLock *lock = nullptr) {
-      if (lock_) lock_->unlock_shared();
+      if (lock_) {
+        lock_->unlock_shared();
+      }
       lock_ = lock;
-      if (lock_) lock_->lock_shared();
+      if (lock_) {
+        lock_->lock_shared();
+      }
     }
 
     void swap(ReadHolder *other) {
@@ -729,21 +797,33 @@ class RWTicketSpinLockT {
     WriteHolder& operator=(WriteHolder const&) = delete;
 
     explicit WriteHolder(RWSpinLock* lock) : lock_(lock) {
-      if (lock_) lock_->lock();
+      if (lock_) {
+        lock_->lock();
+      }
     }
     explicit WriteHolder(RWSpinLock &lock) : lock_ (&lock) {
-      if (lock_) lock_->lock();
+      if (lock_) {
+        lock_->lock();
+      }
     }
 
     ~WriteHolder() {
-      if (lock_) lock_->unlock();
+      if (lock_) {
+        lock_->unlock();
+      }
     }
 
     void reset(RWSpinLock *lock = nullptr) {
-      if (lock == lock_) return;
-      if (lock_) lock_->unlock();
+      if (lock == lock_) {
+        return;
+      }
+      if (lock_) {
+        lock_->unlock();
+      }
       lock_ = lock;
-      if (lock_) lock_->lock();
+      if (lock_) {
+        lock_->lock();
+      }
     }
 
     void swap(WriteHolder *other) {
index cfcbd00a5486ef84fedcbcdb83cc8344556b0607..2ec534bffc4f36bf8c4a065136d5341296bc4016 100644 (file)
@@ -507,14 +507,21 @@ void backslashify(
       if (hex_style) {
         hex_append = true;
       } else {
-        if (c == '\r') output += 'r';
-        else if (c == '\n') output += 'n';
-        else if (c == '\t') output += 't';
-        else if (c == '\a') output += 'a';
-        else if (c == '\b') output += 'b';
-        else if (c == '\0') output += '0';
-        else if (c == '\\') output += '\\';
-        else {
+        if (c == '\r') {
+          output += 'r';
+        } else if (c == '\n') {
+          output += 'n';
+        } else if (c == '\t') {
+          output += 't';
+        } else if (c == '\a') {
+          output += 'a';
+        } else if (c == '\b') {
+          output += 'b';
+        } else if (c == '\0') {
+          output += '0';
+        } else if (c == '\\') {
+          output += '\\';
+        } else {
           hex_append = true;
         }
       }
@@ -576,7 +583,9 @@ void humanify(const String1& input, String2& output) {
 template <class InputString, class OutputString>
 bool hexlify(const InputString& input, OutputString& output,
              bool append_output) {
-  if (!append_output) output.clear();
+  if (!append_output) {
+    output.clear();
+  }
 
   static char hexValues[] = "0123456789abcdef";
   auto j = output.size();
index bd59336e00d986c7c4f603f039b5480d56a72852..c342a9695492e76ade8144d5e69e4ca4363873dc 100644 (file)
@@ -72,10 +72,18 @@ ProcessReturnCode& ProcessReturnCode::operator=(ProcessReturnCode&& p)
 }
 
 ProcessReturnCode::State ProcessReturnCode::state() const {
-  if (rawStatus_ == RV_NOT_STARTED) return NOT_STARTED;
-  if (rawStatus_ == RV_RUNNING) return RUNNING;
-  if (WIFEXITED(rawStatus_)) return EXITED;
-  if (WIFSIGNALED(rawStatus_)) return KILLED;
+  if (rawStatus_ == RV_NOT_STARTED) {
+    return NOT_STARTED;
+  }
+  if (rawStatus_ == RV_RUNNING) {
+    return RUNNING;
+  }
+  if (WIFEXITED(rawStatus_)) {
+    return EXITED;
+  }
+  if (WIFSIGNALED(rawStatus_)) {
+    return KILLED;
+  }
   assume_unreachable();
 }
 
@@ -185,7 +193,9 @@ Subprocess::Subprocess(
   if (argv.empty()) {
     throw std::invalid_argument("argv must not be empty");
   }
-  if (!executable) executable = argv[0].c_str();
+  if (!executable) {
+    executable = argv[0].c_str();
+  }
   spawn(cloneStrings(argv), executable, options, env);
 }
 
index b222fe6aa2c1ddc56b11ef526bda682968106dee..811e65c7ac9775bf9e35f3b6615c7c930e1be5a0 100644 (file)
@@ -67,7 +67,9 @@ char32_t utf8ToCodePoint(
   auto skip = [&] { ++p; return U'\ufffd'; };
 
   if (p >= e) {
-    if (skipOnError) return skip();
+    if (skipOnError) {
+      return skip();
+    }
     throw std::runtime_error("folly::utf8ToCodePoint empty/invalid string");
   }
 
@@ -88,7 +90,9 @@ char32_t utf8ToCodePoint(
   uint32_t d = fst;
 
   if ((fst & 0xC0) != 0xC0) {
-    if (skipOnError) return skip();
+    if (skipOnError) {
+      return skip();
+    }
     throw std::runtime_error(to<std::string>("folly::utf8ToCodePoint i=0 d=", d));
   }
 
@@ -98,7 +102,9 @@ char32_t utf8ToCodePoint(
     unsigned char tmp = p[i];
 
     if ((tmp & 0xC0) != 0x80) {
-      if (skipOnError) return skip();
+      if (skipOnError) {
+        return skip();
+      }
       throw std::runtime_error(
         to<std::string>("folly::utf8ToCodePoint i=", i, " tmp=", (uint32_t)tmp));
     }
@@ -111,7 +117,9 @@ char32_t utf8ToCodePoint(
 
       // overlong, could have been encoded with i bytes
       if ((d & ~bitMask[i - 1]) == 0) {
-        if (skipOnError) return skip();
+        if (skipOnError) {
+          return skip();
+        }
         throw std::runtime_error(
           to<std::string>("folly::utf8ToCodePoint i=", i, " d=", d));
       }
@@ -119,7 +127,9 @@ char32_t utf8ToCodePoint(
       // check for surrogates only needed for 3 bytes
       if (i == 2) {
         if ((d >= 0xD800 && d <= 0xDFFF) || d > 0x10FFFF) {
-          if (skipOnError) return skip();
+          if (skipOnError) {
+            return skip();
+          }
           throw std::runtime_error(
             to<std::string>("folly::utf8ToCodePoint i=", i, " d=", d));
         }
@@ -130,7 +140,9 @@ char32_t utf8ToCodePoint(
     }
   }
 
-  if (skipOnError) return skip();
+  if (skipOnError) {
+    return skip();
+  }
   throw std::runtime_error("folly::utf8ToCodePoint encoding length maxed out");
 }
 
index 2f53dcf13058d0afaf44de6da1ceef0bb1e5204d..c28d7f724fa2ddace0307b5b71d3dd8accbd1a9c 100644 (file)
@@ -136,16 +136,56 @@ inline Expected<uint64_t, DecodeVarintError> tryDecodeVarint(Range<T*>& data) {
   if (LIKELY(size_t(end - begin) >= kMaxVarintLength64)) {  // fast path
     int64_t b;
     do {
-      b = *p++; val  = (b & 0x7f)      ; if (b >= 0) break;
-      b = *p++; val |= (b & 0x7f) <<  7; if (b >= 0) break;
-      b = *p++; val |= (b & 0x7f) << 14; if (b >= 0) break;
-      b = *p++; val |= (b & 0x7f) << 21; if (b >= 0) break;
-      b = *p++; val |= (b & 0x7f) << 28; if (b >= 0) break;
-      b = *p++; val |= (b & 0x7f) << 35; if (b >= 0) break;
-      b = *p++; val |= (b & 0x7f) << 42; if (b >= 0) break;
-      b = *p++; val |= (b & 0x7f) << 49; if (b >= 0) break;
-      b = *p++; val |= (b & 0x7f) << 56; if (b >= 0) break;
-      b = *p++; val |= (b & 0x01) << 63; if (b >= 0) break;
+      b = *p++;
+      val = (b & 0x7f);
+      if (b >= 0) {
+        break;
+      }
+      b = *p++;
+      val |= (b & 0x7f) << 7;
+      if (b >= 0) {
+        break;
+      }
+      b = *p++;
+      val |= (b & 0x7f) << 14;
+      if (b >= 0) {
+        break;
+      }
+      b = *p++;
+      val |= (b & 0x7f) << 21;
+      if (b >= 0) {
+        break;
+      }
+      b = *p++;
+      val |= (b & 0x7f) << 28;
+      if (b >= 0) {
+        break;
+      }
+      b = *p++;
+      val |= (b & 0x7f) << 35;
+      if (b >= 0) {
+        break;
+      }
+      b = *p++;
+      val |= (b & 0x7f) << 42;
+      if (b >= 0) {
+        break;
+      }
+      b = *p++;
+      val |= (b & 0x7f) << 49;
+      if (b >= 0) {
+        break;
+      }
+      b = *p++;
+      val |= (b & 0x7f) << 56;
+      if (b >= 0) {
+        break;
+      }
+      b = *p++;
+      val |= (b & 0x01) << 63;
+      if (b >= 0) {
+        break;
+      }
       return makeUnexpected(DecodeVarintError::TooManyBytes);
     } while (false);
   } else {
index 35ec740036da1a972753f9633cc30ec74623e8a3..45287829d4a52143f81e0fe93e197b65d9c4fc5d 100644 (file)
@@ -49,13 +49,15 @@ class counted_ptr : public counted_ptr_base<Atom> {
   T* p_;
   counted_ptr() : p_(nullptr) {}
   counted_ptr(counted_shared_tag, T* p) : p_(p) {
-    if (p_)
+    if (p_) {
       counted_ptr_base<Atom>::getRef(p_)->add_ref();
+    }
   }
 
   counted_ptr(const counted_ptr& o) : p_(o.p_) {
-    if (p_)
+    if (p_) {
       counted_ptr_base<Atom>::getRef(p_)->add_ref();
+    }
   }
   counted_ptr& operator=(const counted_ptr& o) {
     if (p_ && counted_ptr_base<Atom>::getRef(p_)->release_ref() == 1) {
@@ -63,8 +65,9 @@ class counted_ptr : public counted_ptr_base<Atom> {
       free(counted_ptr_base<Atom>::getRef(p_));
     }
     p_ = o.p_;
-    if (p_)
+    if (p_) {
       counted_ptr_base<Atom>::getRef(p_)->add_ref();
+    }
     return *this;
   }
   explicit counted_ptr(T* p) : p_(p) {
index bd29427f3e2c1948bc98d6b70c5591af4e9f4860..4cf94c24a1a172d6f5f60772690261678bb19dd5 100644 (file)
@@ -65,9 +65,10 @@ void parallelRun(Operation op, size_t numThreads, size_t iters) {
     });
   }
 
-  for (auto& t : threads)
+  for (auto& t : threads) {
     t.join();
 }
+}
 
 void benchmarkSharedPtrCopy(size_t numThreads, size_t iters) {
   auto p = std::make_shared<int>(1);
index 08e97472832b4ac4f4cb069e766a9347fa1bca23..842b7fb68a606a196f173cba5a71f793337a40b5 100644 (file)
@@ -310,7 +310,9 @@ char const* dynamic::typeName(Type t) {
 
 void dynamic::destroy() noexcept {
   // This short-circuit speeds up some microbenchmarks.
-  if (type_ == NULLT) return;
+  if (type_ == NULLT) {
+    return;
+  }
 
 #define FB_X(T) detail::Destroy::destroy(getAddress<T>())
   FB_DYNAMIC_APPLY(type_, FB_X);
index 66388f9b4338e9ae9ecf29a68e0eeff2da9b304e..40b4af15c4f760115813fbc7d24d5fcea9e0627c 100644 (file)
@@ -490,15 +490,17 @@ TEST(ThreadPoolExecutorTest, BugD3527722) {
 
   std::thread producer1([&] {
     ++turn;
-    while (turn < 4)
+    while (turn < 4) {
       ;
+    }
     ++turn;
     q.add(SlowMover(true));
   });
   std::thread producer2([&] {
     ++turn;
-    while (turn < 5)
+    while (turn < 5) {
       ;
+    }
     q.add(SlowMover(false));
   });
 
index 96ea7cd7606c9b46da16b1dedb834ea24292560e..edfed0968858d0364f52af5a953dcde5c5862db2 100644 (file)
@@ -606,8 +606,9 @@ class EliasFanoReader {
 
     if (kUnchecked || LIKELY(position() + n < size_)) {
       if (LIKELY(n < kLinearScanThreshold)) {
-        for (SizeType i = 0; i < n; ++i)
+        for (SizeType i = 0; i < n; ++i) {
           upper_.next();
+        }
       } else {
         upper_.skip(n);
       }
@@ -735,7 +736,9 @@ class EliasFanoReader {
     while (true) {
       value_ = readLowerPart(upper_.position()) |
         (upper_.value() << numLowerBits_);
-      if (LIKELY(value_ >= value)) break;
+      if (LIKELY(value_ >= value)) {
+        break;
+      }
       upper_.next();
     }
   }
index f2f806cb0bac7de5228c757cfb33b2fa186d3dc2..1496b8b17139d6cddc8fdbf1237a306fe427e193 100644 (file)
@@ -175,7 +175,9 @@ inline void EventCount::wait(Key key) noexcept {
 
 template <class Condition>
 void EventCount::await(Condition condition) {
-  if (condition()) return;  // fast path
+  if (condition()) {
+    return; // fast path
+  }
 
   // condition() is the only thing that may throw, everything else is
   // noexcept, so we can hoist the try/catch block outside of the loop
index 81007de7e6b4f349f6136a412cea44cc8ee1da34..e2aa684dcaf31a1f7d17d732fffc064543e7aa1d 100644 (file)
@@ -80,8 +80,9 @@ uint64_t fc_test(
       started.fetch_add(1);
       Rec* myrec = (combining && tc) ? ex.allocRec() : nullptr;
       uint64_t sum = 0;
-      while (!start.load())
+      while (!start.load()) {
         ;
+      }
 
       if (!combining) {
         // no combining
@@ -141,8 +142,9 @@ uint64_t fc_test(
     });
   }
 
-  while (started.load() < nthreads)
+  while (started.load() < nthreads) {
     ;
+  }
   auto tbegin = std::chrono::steady_clock::now();
 
   // begin time measurement
index 1b62bc507bfd302c8c0b8dd98253b6e49e09aff6..971a4ff0fd142ec3c411d80ecb11a5502c0584ee 100644 (file)
@@ -43,14 +43,16 @@ inline uint64_t run_once(
   for (int tid = 0; tid < nthreads; ++tid) {
     threads[tid] = std::thread([&, tid] {
       started.fetch_add(1);
-      while (!start.load())
+      while (!start.load()) {
         /* spin */;
+      }
       fn(tid);
     });
   }
 
-  while (started.load() < nthreads)
+  while (started.load() < nthreads) {
     /* spin */;
+  }
 
   // begin time measurement
   auto tbegin = std::chrono::steady_clock::now();
index 7627c44f22ae67e6b1806dfcb142bbc7f0a208c1..22a00de8ef66cf6da155bce670d0ea90c81e182d 100644 (file)
@@ -49,7 +49,9 @@ class LockFreeLIFO {
   void push(T val) {
     DEBUG_PRINT(this);
     auto pnode = new Node(val, head_.load());
-    while (!head_.compare_exchange_weak(pnode->next_, pnode));
+    while (!head_.compare_exchange_weak(pnode->next_, pnode)) {
+      ;
+    }
   }
 
   bool pop(T& val) {
@@ -57,12 +59,16 @@ class LockFreeLIFO {
     hazptr_holder hptr;
     Node* pnode = head_.load();
     do {
-      if (pnode == nullptr)
+      if (pnode == nullptr) {
         return false;
-      if (!hptr.try_protect(pnode, head_))
+      }
+      if (!hptr.try_protect(pnode, head_)) {
         continue;
+      }
       auto next = pnode->next_;
-      if (head_.compare_exchange_weak(pnode, next)) break;
+      if (head_.compare_exchange_weak(pnode, next)) {
+        break;
+      }
     } while (true);
     hptr.reset();
     val = pnode->value_;
index 20aa0e3beff89d41b510b0e3bbeb6c67f733c0f1..17ed7ce94f8c080ddb8fdfdf7583d2b547c47f15 100644 (file)
@@ -58,7 +58,9 @@ class SWMRListSet {
   void locate_lower_bound(const T& v, std::atomic<Node*>*& prev) const {
     auto curr = prev->load(std::memory_order_relaxed);
     while (curr) {
-      if (curr->elem_ >= v) break;
+      if (curr->elem_ >= v) {
+        break;
+      }
       prev = &(curr->next_);
       curr = curr->next_.load(std::memory_order_relaxed);
     }
@@ -78,7 +80,9 @@ class SWMRListSet {
     auto prev = &head_;
     locate_lower_bound(v, prev);
     auto curr = prev->load(std::memory_order_relaxed);
-    if (curr && curr->elem_ == v) return false;
+    if (curr && curr->elem_ == v) {
+      return false;
+    }
     prev->store(new Node(std::move(v), curr));
     return true;
   }
@@ -87,7 +91,9 @@ class SWMRListSet {
     auto prev = &head_;
     locate_lower_bound(v, prev);
     auto curr = prev->load(std::memory_order_relaxed);
-    if (!curr || curr->elem_ != v) return false;
+    if (!curr || curr->elem_ != v) {
+      return false;
+    }
     Node *curr_next = curr->next_.load();
     // Patch up the actual list...
     prev->store(curr_next, std::memory_order_release);
@@ -108,11 +114,13 @@ class SWMRListSet {
       auto curr = prev->load(std::memory_order_acquire);
       while (true) {
         if (!curr) { return false; }
-        if (!hptr_curr->try_protect(curr, *prev))
+        if (!hptr_curr->try_protect(curr, *prev)) {
           break;
+        }
         auto next = curr->next_.load(std::memory_order_acquire);
-        if (prev->load(std::memory_order_acquire) != curr)
+        if (prev->load(std::memory_order_acquire) != curr) {
           break;
+        }
         if (curr->elem_ == val) {
             return true;
         } else if (!(curr->elem_ < val)) {
index 9a3ed2788edf5045a85dc579234b0e35ed1846b5..8b4ce81a370e38f8ff2ef0caa7028b9096bacd58 100644 (file)
@@ -53,7 +53,9 @@ class WideCAS {
     do {
       p = hptr.get_protected(p_);
       if (p->val_ != u) { delete n; return false; }
-      if (p_.compare_exchange_weak(p, n)) break;
+      if (p_.compare_exchange_weak(p, n)) {
+        break;
+      }
     } while (true);
     hptr.reset();
     p->retire();
index 5250a5de65ea6e0fd7ade558b1251d8c53900500..178bd9dbec59ba3388b1909e0d01da03514843f0 100644 (file)
@@ -638,8 +638,9 @@ inline hazptr_rec* hazptr_domain::hazptrAcquire() {
   p->active_.store(true, std::memory_order_relaxed);
   p->next_ = hazptrs_.load(std::memory_order_acquire);
   while (!hazptrs_.compare_exchange_weak(
-      p->next_, p, std::memory_order_release, std::memory_order_acquire))
+      p->next_, p, std::memory_order_release, std::memory_order_acquire)) {
     /* keep trying */;
+  }
   auto hcount = hcount_.fetch_add(1);
   DEBUG_PRINT(this << " " << p << " " << sizeof(hazptr_rec) << " " << hcount);
   return p;
index ffbfd53e1aeab4a6dc47a788c8e9b5baad41e186..19a556cf1ba961566ee21e72a0a5e76bebc9896b 100644 (file)
@@ -351,7 +351,9 @@ void bmJump(const List& list, const std::vector<uint32_t>& data,
 
   Reader reader(list);
   for (size_t i = 0, j = 0; i < iters; ++i, ++j) {
-    if (j == order.size()) j = 0;
+    if (j == order.size()) {
+      j = 0;
+    }
     reader.jump(order[j]);
     folly::doNotOptimizeAway(reader.value());
   }
@@ -365,7 +367,9 @@ void bmJumpTo(const List& list, const std::vector<uint32_t>& data,
 
   Reader reader(list);
   for (size_t i = 0, j = 0; i < iters; ++i, ++j) {
-    if (j == order.size()) j = 0;
+    if (j == order.size()) {
+      j = 0;
+    }
     reader.jumpTo(data[order[j]]);
     folly::doNotOptimizeAway(reader.value());
   }
index cb21b809dc38dd9a7db4f78ffa9507a41fc93c88..05650a12c5078fb94999ea5468fe668a072a9b06 100644 (file)
@@ -129,14 +129,16 @@ static uint64_t run_once(PriorityQueue& pq, const Func& fn) {
   for (uint32_t tid = 0; tid < nthreads; ++tid) {
     threads[tid] = std::thread([&, tid] {
       started.fetch_add(1);
-      while (!start.load())
+      while (!start.load()) {
         /* nothing */;
+      }
       fn(tid);
     });
   }
 
-  while (started.load() < nthreads)
+  while (started.load() < nthreads) {
     /* nothing */;
+  }
   auto tbegin = std::chrono::steady_clock::now();
 
   // begin time measurement
index 258c9f831de65b461a2a591669c8366793d8809a..70a2c581ee6d228de585a52ed4064480df7d4c37 100644 (file)
@@ -334,9 +334,10 @@ Try<T>& SemiFuture<T>::getTry() {
 
 template <class T>
 void SemiFuture<T>::throwIfInvalid() const {
-  if (!core_)
+  if (!core_) {
     throwNoState();
 }
+}
 
 template <class T>
 Optional<Try<T>> SemiFuture<T>::poll() {
@@ -1269,7 +1270,9 @@ namespace detail {
 template <class FutureType, typename T = typename FutureType::value_type>
 void waitImpl(FutureType& f) {
   // short-circuit if there's nothing to do
-  if (f.isReady()) return;
+  if (f.isReady()) {
+    return;
+  }
 
   FutureBatonType baton;
   f.setCallback_([&](const Try<T>& /* t */) { baton.post(); });
@@ -1302,8 +1305,9 @@ void waitViaImpl(Future<T>& f, DrivableExecutor* e) {
   // Set callback so to ensure that the via executor has something on it
   // so that once the preceding future triggers this callback, drive will
   // always have a callback to satisfy it
-  if (f.isReady())
+  if (f.isReady()) {
     return;
+  }
   f = f.via(e).then([](T&& t) { return std::move(t); });
   while (!f.isReady()) {
     e->drive();
index b7e316544b65d79112a3601edc9b9a733741e21d..50941d02567f59717a5b3b5cf75830de5f2d637a 100644 (file)
@@ -38,8 +38,9 @@ size_t ManualExecutor::run() {
 
     while (!scheduledFuncs_.empty()) {
       auto& sf = scheduledFuncs_.top();
-      if (sf.time > now_)
+      if (sf.time > now_) {
         break;
+      }
       funcs_.emplace(sf.moveOutFunc());
       scheduledFuncs_.pop();
     }
@@ -72,8 +73,9 @@ void ManualExecutor::wait() {
   while (true) {
     {
       std::lock_guard<std::mutex> lock(lock_);
-      if (!funcs_.empty())
+      if (!funcs_.empty()) {
         break;
+      }
     }
 
     sem_.wait();
index a45de257b0d4bfa2e6afd1cbdb6e9b1001dfd4ba..028a4ce63af03490c1b0d183cdf6ea725c9e6f2e 100644 (file)
@@ -132,8 +132,9 @@ namespace folly {
       bool operator<(ScheduledFunc const& b) const {
         // Earlier-scheduled things must be *higher* priority
         // in the max-based std::priority_queue
-        if (time == b.time)
+        if (time == b.time) {
           return ordinal > b.ordinal;
+        }
         return time > b.time;
       }
 
index 5fe4ed2cb029c782c39e3f54ac9fa2fdb0fc2222..7471228c4e2719db43c6af234a40b6994a9db3f4 100644 (file)
@@ -76,8 +76,9 @@ Promise<T>::~Promise() {
 template <class T>
 void Promise<T>::detach() {
   if (core_) {
-    if (!retrieved_)
+    if (!retrieved_) {
       core_->detachFuture();
+    }
     core_->detachPromise();
     core_ = nullptr;
   }
index 770a830ee1acd620adb94db806930954296442f0..56f4f712375ade70afd76525b80eeebe6247bb0f 100644 (file)
@@ -94,18 +94,23 @@ BENCHMARK(no_contention) {
 
   BENCHMARK_SUSPEND {
     folly::Baton<> b1, b2;
-    for (auto& p : promises)
+    for (auto& p : promises) {
       futures.push_back(p.getFuture());
+    }
 
     consumer = std::thread([&]{
       b1.post();
-      for (auto& f : futures) f.then(incr<int>);
+      for (auto& f : futures) {
+        f.then(incr<int>);
+      }
     });
     consumer.join();
 
     producer = std::thread([&]{
       b2.post();
-      for (auto& p : promises) p.setValue(42);
+      for (auto& p : promises) {
+        p.setValue(42);
+      }
     });
 
     b1.wait();
@@ -125,8 +130,9 @@ BENCHMARK_RELATIVE(contention) {
 
   BENCHMARK_SUSPEND {
     folly::Baton<> b1, b2;
-    for (auto& p : promises)
+    for (auto& p : promises) {
       futures.push_back(p.getFuture());
+    }
 
     consumer = std::thread([&]{
       b1.post();
index c01fadf42108edfee827a0ae5c7435a2253ec474..59ba80ea8c82cb7bb3ccd9cbf5ffae86ef1d6931 100644 (file)
@@ -36,8 +36,9 @@ TEST(Collect, collectAll) {
     std::vector<Promise<int>> promises(10);
     std::vector<Future<int>> futures;
 
-    for (auto& p : promises)
+    for (auto& p : promises) {
       futures.push_back(p.getFuture());
+    }
 
     auto allf = collectAll(futures);
 
@@ -59,8 +60,9 @@ TEST(Collect, collectAll) {
     std::vector<Promise<int>> promises(4);
     std::vector<Future<int>> futures;
 
-    for (auto& p : promises)
+    for (auto& p : promises) {
       futures.push_back(p.getFuture());
+    }
 
     auto allf = collectAll(futures);
 
@@ -91,18 +93,20 @@ TEST(Collect, collectAll) {
     std::vector<Promise<Unit>> promises(10);
     std::vector<Future<Unit>> futures;
 
-    for (auto& p : promises)
+    for (auto& p : promises) {
       futures.push_back(p.getFuture());
+    }
 
-    auto allf = collectAll(futures)
-      .then([](Try<std::vector<Try<Unit>>>&& ts) {
-        for (auto& f : ts.value())
-          f.value();
-      });
+    auto allf = collectAll(futures).then([](Try<std::vector<Try<Unit>>>&& ts) {
+      for (auto& f : ts.value()) {
+        f.value();
+      }
+    });
 
     std::shuffle(promises.begin(), promises.end(), rng);
-    for (auto& p : promises)
+    for (auto& p : promises) {
       p.setValue();
+    }
     EXPECT_TRUE(allf.isReady());
   }
 }
@@ -113,8 +117,9 @@ TEST(Collect, collect) {
     std::vector<Promise<int>> promises(10);
     std::vector<Future<int>> futures;
 
-    for (auto& p : promises)
+    for (auto& p : promises) {
       futures.push_back(p.getFuture());
+    }
 
     auto allf = collect(futures);
 
@@ -135,8 +140,9 @@ TEST(Collect, collect) {
     std::vector<Promise<int>> promises(10);
     std::vector<Future<int>> futures;
 
-    for (auto& p : promises)
+    for (auto& p : promises) {
       futures.push_back(p.getFuture());
+    }
 
     auto allf = collect(futures);
 
@@ -170,8 +176,9 @@ TEST(Collect, collect) {
     std::vector<Promise<Unit>> promises(10);
     std::vector<Future<Unit>> futures;
 
-    for (auto& p : promises)
+    for (auto& p : promises) {
       futures.push_back(p.getFuture());
+    }
 
     auto allf = collect(futures);
 
@@ -189,8 +196,9 @@ TEST(Collect, collect) {
     std::vector<Promise<Unit>> promises(10);
     std::vector<Future<Unit>> futures;
 
-    for (auto& p : promises)
+    for (auto& p : promises) {
       futures.push_back(p.getFuture());
+    }
 
     auto allf = collect(futures);
 
@@ -224,8 +232,9 @@ TEST(Collect, collect) {
     std::vector<Promise<std::unique_ptr<int>>> promises(10);
     std::vector<Future<std::unique_ptr<int>>> futures;
 
-    for (auto& p : promises)
+    for (auto& p : promises) {
       futures.push_back(p.getFuture());
+    }
 
     collect(futures);
   }
@@ -247,8 +256,9 @@ TEST(Collect, collectNotDefaultConstructible) {
   std::iota(indices.begin(), indices.end(), 0);
   std::shuffle(indices.begin(), indices.end(), rng);
 
-  for (auto& p : promises)
+  for (auto& p : promises) {
     futures.push_back(p.getFuture());
+  }
 
   auto allf = collect(futures);
 
@@ -270,8 +280,9 @@ TEST(Collect, collectAny) {
     std::vector<Promise<int>> promises(10);
     std::vector<Future<int>> futures;
 
-    for (auto& p : promises)
+    for (auto& p : promises) {
       futures.push_back(p.getFuture());
+    }
 
     for (auto& f : futures) {
       EXPECT_FALSE(f.isReady());
@@ -298,8 +309,9 @@ TEST(Collect, collectAny) {
     std::vector<Promise<Unit>> promises(10);
     std::vector<Future<Unit>> futures;
 
-    for (auto& p : promises)
+    for (auto& p : promises) {
       futures.push_back(p.getFuture());
+    }
 
     for (auto& f : futures) {
       EXPECT_FALSE(f.isReady());
@@ -319,8 +331,9 @@ TEST(Collect, collectAny) {
     std::vector<Promise<int>> promises(10);
     std::vector<Future<int>> futures;
 
-    for (auto& p : promises)
+    for (auto& p : promises) {
       futures.push_back(p.getFuture());
+    }
 
     auto anyf = collectAny(futures)
       .then([](std::pair<size_t, Try<int>> p) {
@@ -403,8 +416,9 @@ TEST(Collect, collectAnyWithoutException) {
 TEST(Collect, alreadyCompleted) {
   {
     std::vector<Future<Unit>> fs;
-    for (int i = 0; i < 10; i++)
+    for (int i = 0; i < 10; i++) {
       fs.push_back(makeFuture());
+    }
 
     collectAll(fs)
       .then([&](std::vector<Try<Unit>> ts) {
@@ -413,8 +427,9 @@ TEST(Collect, alreadyCompleted) {
   }
   {
     std::vector<Future<int>> fs;
-    for (int i = 0; i < 10; i++)
+    for (int i = 0; i < 10; i++) {
       fs.push_back(makeFuture(i));
+    }
 
     collectAny(fs)
       .then([&](std::pair<size_t, Try<int>> p) {
@@ -555,8 +570,9 @@ TEST(Collect, collectN) {
   std::vector<Promise<Unit>> promises(10);
   std::vector<Future<Unit>> futures;
 
-  for (auto& p : promises)
+  for (auto& p : promises) {
     futures.push_back(p.getFuture());
+  }
 
   bool flag = false;
   size_t n = 3;
@@ -564,8 +580,9 @@ TEST(Collect, collectN) {
     .then([&](std::vector<std::pair<size_t, Try<Unit>>> v) {
       flag = true;
       EXPECT_EQ(n, v.size());
-      for (auto& tt : v)
+      for (auto& tt : v) {
         EXPECT_TRUE(tt.second.hasValue());
+      }
     });
 
   promises[0].setValue();
@@ -586,16 +603,18 @@ TEST(Collect, smallVector) {
   {
     folly::small_vector<Future<Unit>> futures;
 
-    for (int i = 0; i < 10; i++)
+    for (int i = 0; i < 10; i++) {
       futures.push_back(makeFuture());
+    }
 
     auto anyf = collectAny(futures);
   }
   {
     folly::small_vector<Future<Unit>> futures;
 
-    for (int i = 0; i < 10; i++)
+    for (int i = 0; i < 10; i++) {
       futures.push_back(makeFuture());
+    }
 
     auto allf = collectAll(futures);
   }
index 1178603f3f86ef0cb508bde9d9a99d2f42cad5b5..0217eda5f622c2300f9da4257a095f7dd6617f2e 100644 (file)
@@ -39,12 +39,16 @@ TEST(FSM, example) {
   };
 
   // keep retrying until success (like a cas)
-  while (!tryTransition()) ;
+  while (!tryTransition()) {
+    ;
+  }
   EXPECT_EQ(State::B, fsm.getState());
   EXPECT_EQ(1, count);
   EXPECT_EQ(0, unprotectedCount);
 
-  while (!tryTransition()) ;
+  while (!tryTransition()) {
+    ;
+  }
   EXPECT_EQ(State::A, fsm.getState());
   EXPECT_EQ(0, count);
   EXPECT_EQ(-1, unprotectedCount);
index 1a530d37706aa2f651751cc9ed1c9833131a519e..79e6c9bf9847d5a3a9a6e82c7697cb6e20d75955 100644 (file)
@@ -50,8 +50,9 @@ struct ViaFixture : public testing::Test {
   {
     t = std::thread([=] {
         ManualWaiter eastWaiter(eastExecutor);
-        while (!done)
+        while (!done) {
           eastWaiter.drive();
+        }
       });
   }
 
@@ -466,7 +467,9 @@ TEST(Via, viaRaces) {
     p.setValue();
   });
 
-  while (!done) x.run();
+  while (!done) {
+    x.run();
+  }
   t1.join();
   t2.join();
 }
index 5d9075bda463e95632cfccb05b186812422c97cc..0158b93674eb702820dbfae24a3d51480ee1ab9b 100644 (file)
@@ -877,10 +877,12 @@ TEST(Gen, MapYielders) {
            | map([](int n) {
                return GENERATOR(int) {
                  int i;
-                 for (i = 1; i < n; ++i)
+                 for (i = 1; i < n; ++i) {
                    yield(i);
-                 for (; i >= 1; --i)
+                 }
+                 for (; i >= 1; --i) {
                    yield(i);
+                 }
                };
              })
            | concat;
index d5987f8e44de846b6f62d6bc3bbed1d00f9945c4..4ff196054ac13c746fa7016d4721585fa6227a52 100644 (file)
@@ -60,8 +60,9 @@ public:
     {
         m_a = 0xdeadbeef;
         m_b = m_c = m_d = seed;
-        for (int i=0; i<20; ++i)
-            (void)Value();
+        for (int i = 0; i < 20; ++i) {
+          (void)Value();
+        }
     }
 
 private:
@@ -447,10 +448,14 @@ void TestDeltas(int seed)
                         for (int m=0; m<MEASURES; ++m)
                         {
                             counter[m][l] |= measure[m][l];
-                            if (~counter[m][l]) done = 0;
+                            if (~counter[m][l]) {
+                              done = 0;
+                            }
                         }
                     }
-                    if (done) break;
+                    if (done) {
+                      break;
+                    }
                 }
                 if (k == TRIES)
                 {
index 4d01a2c3444337b2a2bcd45b788810175000538c..c428696d293fbfc52a4194c929b67d36b67a8b38 100644 (file)
@@ -60,8 +60,9 @@ public:
     {
         m_a = 0xdeadbeef;
         m_b = m_c = m_d = seed;
-        for (int i=0; i<20; ++i)
-            (void)Value();
+        for (int i = 0; i < 20; ++i) {
+          (void)Value();
+        }
     }
 
 private:
@@ -437,10 +438,14 @@ void TestDeltas(int seed)
                         for (int m=0; m<MEASURES; ++m)
                         {
                             counter[m][l] |= measure[m][l];
-                            if (~counter[m][l]) done = 0;
+                            if (~counter[m][l]) {
+                              done = 0;
+                            }
                         }
                     }
-                    if (done) break;
+                    if (done) {
+                      break;
+                    }
                 }
                 if (k == TRIES)
                 {
index d4201fbaa315e3adfbf114c213fa129c6fc24c0d..c801920d34f793cd9e60608af254207652657564 100644 (file)
@@ -298,7 +298,9 @@ class IOBufQueue {
 
  private:
   IOBuf* tailBuf() const {
-    if (UNLIKELY(!head_)) return nullptr;
+    if (UNLIKELY(!head_)) {
+      return nullptr;
+    }
     IOBuf* buf = head_->prev();
     return LIKELY(!buf->isSharedOne()) ? buf : nullptr;
   }
index 72f29d0caef2daaae17bfade745a5fdee6f2413d..908a95b6865fd6465a4eab52ff1db8cb9a6d1156 100644 (file)
@@ -55,15 +55,17 @@ int setCloseOnExec(int fd, int value) {
   int old_flags = fcntl(fd, F_GETFD, 0);
 
   // If reading the flags failed, return error indication now
-  if (old_flags < 0)
+  if (old_flags < 0) {
     return -1;
+  }
 
   // Set just the flag we want to set
   int new_flags;
-  if (value != 0)
+  if (value != 0) {
     new_flags = old_flags | FD_CLOEXEC;
-  else
+  } else {
     new_flags = old_flags & ~FD_CLOEXEC;
+  }
 
   // Store modified flag word in the descriptor
   return fcntl(fd, F_SETFD, new_flags);
index 991b225c13ed57c84ce70471779104039913d4c5..a6fbe6fe28f73ae4e60d71b1d01785c9b07c170c 100644 (file)
@@ -2692,7 +2692,9 @@ void AsyncSocket::invalidState(WriteCallback* callback) {
 }
 
 void AsyncSocket::doClose() {
-  if (fd_ == -1) return;
+  if (fd_ == -1) {
+    return;
+  }
   if (const auto shutdownSocketSet = wShutdownSocketSet_.lock()) {
     shutdownSocketSet->close(fd_);
   } else {
index 1353976ee9bf80c305d3681d26b9063f98b0cce9..5ffa8da4920c0ada801e308bbac3b6ac9b6d0618 100644 (file)
@@ -1211,7 +1211,9 @@ TEST(EventBaseTest, RunInEventBaseThreadAndWait) {
     th.join();
   }
   size_t sum = 0;
-  for (auto& atom : atoms) sum += *atom;
+  for (auto& atom : atoms) {
+    sum += *atom;
+  }
   EXPECT_EQ(c, sum);
 }
 
index 54f3cc26ab03b0eee54bbb583604b287d4576b9a..e05cabd0c69bf6e93673832c60f376b064a62847 100644 (file)
@@ -107,8 +107,9 @@ namespace detail {
   template <class Iterator>
   int distance_if_multipass(Iterator first, Iterator last) {
     typedef typename std::iterator_traits<Iterator>::iterator_category categ;
-    if (std::is_same<categ,std::input_iterator_tag>::value)
+    if (std::is_same<categ, std::input_iterator_tag>::value) {
       return -1;
+    }
     return std::distance(first, last);
   }
 
@@ -345,15 +346,17 @@ class sorted_vector_set
 
   iterator find(const key_type& key) {
     iterator it = lower_bound(key);
-    if (it == end() || !key_comp()(key, *it))
+    if (it == end() || !key_comp()(key, *it)) {
       return it;
+    }
     return end();
   }
 
   const_iterator find(const key_type& key) const {
     const_iterator it = lower_bound(key);
-    if (it == end() || !key_comp()(key, *it))
+    if (it == end() || !key_comp()(key, *it)) {
       return it;
+    }
     return end();
   }
 
@@ -599,15 +602,17 @@ class sorted_vector_map
 
   iterator find(const key_type& key) {
     iterator it = lower_bound(key);
-    if (it == end() || !key_comp()(key, it->first))
+    if (it == end() || !key_comp()(key, it->first)) {
       return it;
+    }
     return end();
   }
 
   const_iterator find(const key_type& key) const {
     const_iterator it = lower_bound(key);
-    if (it == end() || !key_comp()(key, it->first))
+    if (it == end() || !key_comp()(key, it->first)) {
       return it;
+    }
     return end();
   }
 
index a0837ca4f8ea0d8cefa483f695ff1dbbbe8c7391..5f577afa746538ca993c16e82eb545269d91c248 100644 (file)
@@ -119,5 +119,7 @@ TEST(AHMIntStressTest, Test) {
     });
   }
 
-  for (auto& t : threads) t.join();
+  for (auto& t : threads) {
+    t.join();
+}
 }
index 780076a1abcd402d1caaf600463814bebedb6069..15e76879b2c1e2b5e17fc42a1880edd417eaacbe 100644 (file)
@@ -74,7 +74,9 @@ class MmapAllocator {
   T *allocate(size_t n) {
     void *p = mmap(nullptr, n * sizeof(T), PROT_READ | PROT_WRITE,
         MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
-    if (p == MAP_FAILED) throw std::bad_alloc();
+    if (p == MAP_FAILED) {
+      throw std::bad_alloc();
+    }
     return (T *)p;
   }
 
@@ -264,7 +266,9 @@ struct EqTraits {
 struct HashTraits {
   size_t operator()(char* a) {
     size_t result = 0;
-    while (a[0] != 0) result += static_cast<size_t>(*(a++));
+    while (a[0] != 0) {
+      result += static_cast<size_t>(*(a++));
+    }
     return result;
   }
   size_t operator()(const char& a) {
@@ -272,7 +276,9 @@ struct HashTraits {
   }
   size_t operator()(const StringPiece a) {
     size_t result = 0;
-    for (const auto& ch : a) result += static_cast<size_t>(ch);
+    for (const auto& ch : a) {
+      result += static_cast<size_t>(ch);
+    }
     return result;
   }
 };
index f204f8ff8cb0bbe1ed38aed5dec524f8af719fb6..e2bedea47cd3a57dd7a5760a96adf958496c794e 100644 (file)
@@ -134,7 +134,9 @@ struct EqTraits {
 struct HashTraits {
   size_t operator()(const char* a) {
     size_t result = 0;
-    while (a[0] != 0) result += static_cast<size_t>(*(a++));
+    while (a[0] != 0) {
+      result += static_cast<size_t>(*(a++));
+    }
     return result;
   }
   size_t operator()(const char& a) {
@@ -142,7 +144,9 @@ struct HashTraits {
   }
   size_t operator()(const StringPiece a) {
     size_t result = 0;
-    for (const auto& ch : a) result += static_cast<size_t>(ch);
+    for (const auto& ch : a) {
+      result += static_cast<size_t>(ch);
+    }
     return result;
   }
 };
@@ -619,7 +623,9 @@ void* testEraseEraseThread(void*) {
     int currentLevel;
     do {
       currentLevel = insertedLevel.load(std::memory_order_acquire);
-      if (currentLevel == kTestEraseInsertions) currentLevel += lag + 1;
+      if (currentLevel == kTestEraseInsertions) {
+        currentLevel += lag + 1;
+      }
     } while (currentLevel - lag < i);
 
     KeyT key = randomizeKey(i);
@@ -673,7 +679,9 @@ auto atomicHashArrayInsertRaceArray = AHA::create(2, configRace);
 void* atomicHashArrayInsertRaceThread(void* /* j */) {
   AHA* arr = atomicHashArrayInsertRaceArray.get();
   uintptr_t numInserted = 0;
-  while (!runThreadsCreatedAllThreads.load());
+  while (!runThreadsCreatedAllThreads.load()) {
+    ;
+  }
   for (int i = 0; i < 2; i++) {
     if (arr->insert(RecordT(randomizeKey(i), 0)).first != arr->end()) {
       numInserted++;
@@ -867,7 +875,9 @@ BENCHMARK(mt_ahm_miss, iters) {
   numOpsPerThread = iters / FLAGS_numThreads;
   runThreads([](void* jj) -> void* {
     int64_t j = (int64_t) jj;
-    while (!runThreadsCreatedAllThreads.load());
+    while (!runThreadsCreatedAllThreads.load()) {
+      ;
+    }
     for (int i = 0; i < numOpsPerThread; ++i) {
       KeyT key = i + j * numOpsPerThread * 100;
       folly::doNotOptimizeAway(globalAHM->find(key) == globalAHM->end());
@@ -881,7 +891,9 @@ BENCHMARK(mt_qpahm_miss, iters) {
   numOpsPerThread = iters / FLAGS_numThreads;
   runThreads([](void* jj) -> void* {
     int64_t j = (int64_t) jj;
-    while (!runThreadsCreatedAllThreads.load());
+    while (!runThreadsCreatedAllThreads.load()) {
+      ;
+    }
     for (int i = 0; i < numOpsPerThread; ++i) {
       KeyT key = i + j * numOpsPerThread * 100;
       folly::doNotOptimizeAway(globalQPAHM->find(key) == globalQPAHM->end());
@@ -911,7 +923,9 @@ BENCHMARK(mt_ahm_find_insert_mix, iters) {
   numOpsPerThread = iters / FLAGS_numThreads;
   runThreads([](void* jj) -> void* {
     int64_t j = (int64_t) jj;
-    while (!runThreadsCreatedAllThreads.load());
+    while (!runThreadsCreatedAllThreads.load()) {
+      ;
+    }
     for (int i = 0; i < numOpsPerThread; ++i) {
       if (i % 128) {  // ~1% insert mix
         KeyT key = randomizeKey(i + j * numOpsPerThread);
@@ -931,7 +945,9 @@ BENCHMARK(mt_qpahm_find_insert_mix, iters) {
   numOpsPerThread = iters / FLAGS_numThreads;
   runThreads([](void* jj) -> void* {
     int64_t j = (int64_t) jj;
-    while (!runThreadsCreatedAllThreads.load());
+    while (!runThreadsCreatedAllThreads.load()) {
+      ;
+    }
     for (int i = 0; i < numOpsPerThread; ++i) {
       if (i % 128) {  // ~1% insert mix
         KeyT key = randomizeKey(i + j * numOpsPerThread);
@@ -950,7 +966,9 @@ BENCHMARK(mt_aha_find, iters) {
   numOpsPerThread = iters / FLAGS_numThreads;
   runThreads([](void* jj) -> void* {
       int64_t j = (int64_t) jj;
-      while (!runThreadsCreatedAllThreads.load());
+      while (!runThreadsCreatedAllThreads.load()) {
+        ;
+      }
       for (int i = 0; i < numOpsPerThread; ++i) {
         KeyT key = randomizeKey(i + j * numOpsPerThread);
         folly::doNotOptimizeAway(globalAHA->find(key)->second);
@@ -964,7 +982,9 @@ BENCHMARK(mt_ahm_find, iters) {
   numOpsPerThread = iters / FLAGS_numThreads;
   runThreads([](void* jj) -> void* {
     int64_t j = (int64_t) jj;
-    while (!runThreadsCreatedAllThreads.load());
+    while (!runThreadsCreatedAllThreads.load()) {
+      ;
+    }
     for (int i = 0; i < numOpsPerThread; ++i) {
       KeyT key = randomizeKey(i + j * numOpsPerThread);
       folly::doNotOptimizeAway(globalAHM->find(key)->second);
@@ -978,7 +998,9 @@ BENCHMARK(mt_qpahm_find, iters) {
   numOpsPerThread = iters / FLAGS_numThreads;
   runThreads([](void* jj) -> void* {
     int64_t j = (int64_t) jj;
-    while (!runThreadsCreatedAllThreads.load());
+    while (!runThreadsCreatedAllThreads.load()) {
+      ;
+    }
     for (int i = 0; i < numOpsPerThread; ++i) {
       KeyT key = randomizeKey(i + j * numOpsPerThread);
       folly::doNotOptimizeAway(globalQPAHM->find(key)->second);
index cfe9aa983b6a806c62bfd3c0670fd964adc3baae..09b9d17b446a38d82a55d103a148be1339e48923 100644 (file)
@@ -72,7 +72,9 @@ void BM_IterateOverSet(int iters, int size) {
   auto iter = a_set.begin();
   for (int i = 0; i < iters; ++i) {
     sum += *iter++;
-    if (iter == a_set.end()) iter = a_set.begin();
+    if (iter == a_set.end()) {
+      iter = a_set.begin();
+    }
   }
   BENCHMARK_SUSPEND {
     // VLOG(20) << "sum = " << sum;
@@ -92,7 +94,9 @@ void BM_IterateSkipList(int iters, int size) {
   auto iter = skipList.begin();
   for (int i = 0; i < iters; ++i) {
     sum += *iter++;
-    if (iter == skipList.end()) iter = skipList.begin();
+    if (iter == skipList.end()) {
+      iter = skipList.begin();
+    }
   }
 
   BENCHMARK_SUSPEND {
@@ -114,7 +118,9 @@ void BM_SetMerge(int iters, int size) {
 
   int64_t mergedSum = 0;
   FOR_EACH(it, a_set) {
-    if (b_set.find(*it) != b_set.end()) mergedSum += *it;
+    if (b_set.find(*it) != b_set.end()) {
+      mergedSum += *it;
+    }
   }
   BENCHMARK_SUSPEND {
     // VLOG(20) << mergedSum;
@@ -137,7 +143,9 @@ void BM_CSLMergeLookup(int iters, int size) {
 
   SkipListType::Skipper skipper(skipList2);
   FOR_EACH(it, skipList) {
-    if (skipper.to(*it)) mergedSum += *it;
+    if (skipper.to(*it)) {
+      mergedSum += *it;
+    }
   }
 
   BENCHMARK_SUSPEND {
@@ -347,7 +355,9 @@ class ConcurrentAccessData {
 
     for (int i = 0; i < FLAGS_num_sets; ++i) {
       locks_[i] = new RWSpinLock();
-      if (i > 0) sets_[i] = sets_[0];
+      if (i > 0) {
+        sets_[i] = sets_[0];
+      }
     }
 
 // This requires knowledge of the C++ library internals. Only use it if we're
index 35651eb5a424a53743a46e6f42b792be83276465..671a8341e1d78cb980423fab6fb5334405006d74 100644 (file)
@@ -115,7 +115,9 @@ static void concurrentSkip(const vector<ValueType> *values,
   int64_t sum = 0;
   SkipListAccessor::Skipper skipper(skipList);
   FOR_EACH(it, *values) {
-    if (skipper.to(*it)) sum += *it;
+    if (skipper.to(*it)) {
+      sum += *it;
+    }
   }
   VLOG(20) << "sum = " << sum;
 }
@@ -266,8 +268,12 @@ TEST(ConcurrentSkipList, TestStringType) {
 struct UniquePtrComp {
   bool operator ()(
       const std::unique_ptr<int> &x, const std::unique_ptr<int> &y) const {
-    if (!x) return false;
-    if (!y) return true;
+    if (!x) {
+      return false;
+    }
+    if (!y) {
+      return true;
+    }
     return *x < *y;
   }
 };
index 0d0c20fdd5219c4dc60823d963cdb44efc4a957c..64343b405ff03d41579bf282a85e67ee99b7ba77 100644 (file)
@@ -143,12 +143,16 @@ template <class String> void clause11_21_4_2_h(String & test) {
   EXPECT_EQ(test, s2);
   // Constructor from other iterators
   std::list<char> lst;
-  for (auto c : test) lst.push_back(c);
+  for (auto c : test) {
+    lst.push_back(c);
+  }
   String s3(lst.begin(), lst.end());
   EXPECT_EQ(test, s3);
   // Constructor from wchar_t iterators
   std::list<wchar_t> lst1;
-  for (auto c : test) lst1.push_back(c);
+  for (auto c : test) {
+    lst1.push_back(c);
+  }
   String s4(lst1.begin(), lst1.end());
   EXPECT_EQ(test, s4);
   // Constructor from wchar_t pointers
@@ -249,8 +253,11 @@ template <class String> void clause11_21_4_4(String & test) {
   // exercise empty
   string empty("empty");
   string notempty("not empty");
-  if (test.empty()) test = String(empty.begin(), empty.end());
-  else test = String(notempty.begin(), notempty.end());
+  if (test.empty()) {
+    test = String(empty.begin(), empty.end());
+  } else {
+    test = String(notempty.begin(), notempty.end());
+  }
 }
 
 template <class String> void clause11_21_4_5(String & test) {
@@ -828,8 +835,11 @@ template <class String> void clause11_21_4_7_9_a(String & test) {
   String s;
   randomString(&s, maxString);
   int tristate = test.compare(s);
-  if (tristate > 0) tristate = 1;
-  else if (tristate < 0) tristate = 2;
+  if (tristate > 0) {
+    tristate = 1;
+  } else if (tristate < 0) {
+    tristate = 2;
+  }
   Num2String(test, tristate);
 }
 
@@ -840,8 +850,11 @@ template <class String> void clause11_21_4_7_9_b(String & test) {
     random(0, test.size()),
     random(0, test.size()),
     s);
-  if (tristate > 0) tristate = 1;
-  else if (tristate < 0) tristate = 2;
+  if (tristate > 0) {
+    tristate = 1;
+  } else if (tristate < 0) {
+    tristate = 2;
+  }
   Num2String(test, tristate);
 }
 
@@ -854,8 +867,11 @@ template <class String> void clause11_21_4_7_9_c(String & test) {
     str,
     random(0, str.size()),
     random(0, str.size()));
-  if (tristate > 0) tristate = 1;
-  else if (tristate < 0) tristate = 2;
+  if (tristate > 0) {
+    tristate = 1;
+  } else if (tristate < 0) {
+    tristate = 2;
+  }
   Num2String(test, tristate);
 }
 
@@ -863,9 +879,12 @@ template <class String> void clause11_21_4_7_9_d(String & test) {
   String s;
   randomString(&s, maxString);
   int tristate = test.compare(s.c_str());
-  if (tristate > 0) tristate = 1;
-  else if (tristate < 0) tristate = 2;
-                Num2String(test, tristate);
+  if (tristate > 0) {
+    tristate = 1;
+  } else if (tristate < 0) {
+    tristate = 2;
+  }
+  Num2String(test, tristate);
 }
 
 template <class String> void clause11_21_4_7_9_e(String & test) {
@@ -876,8 +895,11 @@ template <class String> void clause11_21_4_7_9_e(String & test) {
     random(0, test.size()),
     str.c_str(),
     random(0, str.size()));
-  if (tristate > 0) tristate = 1;
-  else if (tristate < 0) tristate = 2;
+  if (tristate > 0) {
+    tristate = 1;
+  } else if (tristate < 0) {
+    tristate = 2;
+  }
   Num2String(test, tristate);
 }
 
@@ -996,7 +1018,10 @@ TEST(FBString, testAllClauses) {
                void(*f_fbstring)(folly::fbstring&),
                void(*f_wfbstring)(folly::basic_fbstring<wchar_t>&)) {
     do {
-      if (1) {} else EXPECT_TRUE(1) << "Testing clause " << clause;
+      if (1) {
+      } else {
+        EXPECT_TRUE(1) << "Testing clause " << clause;
+      }
       randomString(&r);
       c = r;
       EXPECT_EQ(c, r);
@@ -1020,7 +1045,9 @@ TEST(FBString, testAllClauses) {
       auto mbv = std::vector<char>(wret + 1);
       auto mb = mbv.data();
       int ret = wcstombs(mb, wc.c_str(), wret + 1);
-      if (ret == wret) mb[wret] = '\0';
+      if (ret == wret) {
+        mb[wret] = '\0';
+      }
       const char *mc = c.c_str();
       std::string one(mb);
       std::string two(mc);
index d1c68784d7ca11894aa8d9793db9b7219fcdc1bd..90bb8312cf5889e3f7b7f600117f8933e6a2fa37 100644 (file)
@@ -62,7 +62,9 @@ BENCHMARK_PARAM(BENCHFUN(ctorFromArray), 32768);
 void BENCHFUN(ctorFromTwoPointers)(size_t iters, size_t arg) {
   /* library-local */ static STRING s;
   BENCHMARK_SUSPEND {
-    if (s.size() < arg) s.resize(arg);
+    if (s.size() < arg) {
+      s.resize(arg);
+    }
   }
   FOR_EACH_RANGE (i, 0, iters) {
     STRING s1(s.begin(), s.end());
index e5181e4bedece35b6d58d5a9676364dc2f3f11ec..d46405ead7d9baa2f6d3a9c22fbe2b67206c1042 100644 (file)
@@ -73,7 +73,9 @@ TESTFUN(clause_23_3_6_1_11) {
   EXPECT_EQ(v.size(), lst.size() / 2);
   j = 0;
   FOR_EACH (i, lst) {
-    if (j == v.size()) break;
+    if (j == v.size()) {
+      break;
+    }
     EXPECT_EQ(v[j], *i);
     j++;
   }
@@ -373,7 +375,9 @@ void BENCHFUN(erase)(int iters, int /* size */) {
   auto const obj1 = randomObject<VECTOR::value_type>();
   VECTOR v(random(0U, 100U), obj1);
   FOR_EACH_RANGE (i, 0, iters) {
-    if (v.empty()) continue;
+    if (v.empty()) {
+      continue;
+    }
     v.erase(v.begin());
   }
 }
index 121e94fe4d3070b6e6da052a15e1cfc72e2a02eb..437bd67ce82b5205f463dfeee9d5f7827d087c0a 100644 (file)
@@ -641,8 +641,9 @@ constexpr std::size_t countSpacesReverse(folly::FixedString<50> s) {
   std::size_t count = 0u;
   auto i = s.rbegin();
   for( ; i != s.rend(); ++i, --i, i++, i--, i+=1, i-=1, i+=1 ) {
-    if (' ' == *i)
+    if (' ' == *i) {
       ++count;
+    }
   }
   return count;
 }
index ded3b7210fc3e5788248d5fb8fd843ed2bccb83c..48331668307c195a9725e40745d796aa15f4bd42 100644 (file)
@@ -439,7 +439,9 @@ TEST(Foreach, ForEachEnumerateBreak) {
     sumAA += aa;
     sumIter += *iter;
     ++numIterations;
-    if (aa == 1) break;
+    if (aa == 1) {
+      break;
+    }
   }
   EXPECT_EQ(sumAA, 1);   // 0 + 1
   EXPECT_EQ(sumIter, 3); // 1 + 2
index c15566b29def444d48a43c1c4fe8c4da41762f12..8bdd98e504a3397482b3f56213fb8b6d449b451a 100644 (file)
@@ -280,8 +280,9 @@ TEST(IndexedMemPool, construction_destruction) {
     for (auto i = 0; i < nthreads; ++i) {
       thr[i] = std::thread([&]() {
         started.fetch_add(1);
-        while (!start.load())
+        while (!start.load()) {
           ;
+        }
         for (auto j = 0; j < count; ++j) {
           uint32_t idx = pool.allocIndex();
           if (idx != 0) {
@@ -291,8 +292,9 @@ TEST(IndexedMemPool, construction_destruction) {
       });
     }
 
-    while (started.load() < nthreads)
+    while (started.load() < nthreads) {
       ;
+    }
     start.store(true);
 
     for (auto& t : thr) {
index fb61572feecff47d0a023d0569d67e5d8a30233d..385f2d2b8212665016ebc4c8e3b22f97d0a61c9a 100644 (file)
@@ -228,7 +228,9 @@ TEST(RWSpinLock, concurrent_holder_test) {
   sleep(5);
   stop.store(true, std::memory_order_release);
 
-  for (auto& t : threads) t.join();
+  for (auto& t : threads) {
+    t.join();
+  }
 
   LOG(INFO) << "reads: " << reads.load(std::memory_order_acquire)
     << "; writes: " << writes.load(std::memory_order_acquire)
index 33b91bef9388821e9f2750cf544154227876c994..48951a621ff7a922686435da671d6ded7a0f72cd 100644 (file)
@@ -763,7 +763,7 @@ template <class Mutex> void testTimedSynchronized() {
     v->push_back(2 * threadIdx);
 
     // Aaand test the TIMED_SYNCHRONIZED macro
-    for (;;)
+    for (;;) {
       TIMED_SYNCHRONIZED(5, lv, v) {
         if (lv) {
           // Sleep for a random time to ensure we trigger timeouts
@@ -776,6 +776,7 @@ template <class Mutex> void testTimedSynchronized() {
 
         ++(*numTimeouts.contextualLock());
       }
+    }
   };
 
   static const size_t numThreads = 100;
index fa6b663749fc43e880baa06d31706364ca3bf1f2..1289a07e2617c92ee777cfd5e8bfa958e2fd12ee 100644 (file)
@@ -183,7 +183,9 @@ TEST(Traits, int128) {
 
 template <typename T, typename... Args>
 void testIsRelocatable(Args&&... args) {
-  if (!IsRelocatable<T>::value) return;
+  if (!IsRelocatable<T>::value) {
+    return;
+  }
 
   // We use placement new on zeroed memory to avoid garbage subsections
   char vsrc[sizeof(T)] = { 0 };
index 0dcd8d006644c94b9dd4420f8f47429fd21c5878..834ed4cbedd7136bee33bfc14e7218c36ff83a11 100644 (file)
@@ -39,8 +39,9 @@ template <class Container>
 void check_invariant(Container& c) {
   auto it = c.begin();
   auto end = c.end();
-  if (it == end)
+  if (it == end) {
     return;
+  }
   auto prev = it;
   ++it;
   for (; it != end; ++it, ++prev) {
@@ -267,13 +268,15 @@ TEST(SortedVectorTypes, InitializerLists) {
 
 TEST(SortedVectorTypes, CustomCompare) {
   sorted_vector_set<int,less_invert<int> > s;
-  for (int i = 0; i < 200; ++i)
+  for (int i = 0; i < 200; ++i) {
     s.insert(i);
+  }
   check_invariant(s);
 
   sorted_vector_map<int,float,less_invert<int> > m;
-  for (int i = 0; i < 200; ++i)
+  for (int i = 0; i < 200; ++i) {
     m[i] = 12.0;
+  }
   check_invariant(m);
 }
 
index b107cd9891b2951674d59696a1b984b0e81c8e3b..1bd3c9667ddedd7d2a7a9cdd8d7ac13100fcdad7 100644 (file)
@@ -1419,21 +1419,31 @@ void verifyAllocator(int ele, int cap) {
 // Master verifier
 template <class Vector>
 void verify(int extras) {
-  if (!is_arithmetic<typename Vector::value_type>::value)
+  if (!is_arithmetic<typename Vector::value_type>::value) {
     ASSERT_EQ(0 + extras, getTotal()) << "there exist Data but no vectors";
+  }
   isSane();
-  if (::testing::Test::HasFatalFailure()) return;
-  if (customAllocator<Vector>::value) verifyAllocator(0, 0);
+  if (::testing::Test::HasFatalFailure()) {
+    return;
+  }
+  if (customAllocator<Vector>::value) {
+    verifyAllocator(0, 0);
+  }
 }
 template <class Vector>
 void verify(int extras, const Vector& v) {
   verifyVector(v);
-  if (!is_arithmetic<typename Vector::value_type>::value)
+  if (!is_arithmetic<typename Vector::value_type>::value) {
     ASSERT_EQ(v.size() + extras, getTotal())
       << "not all Data are in the vector";
+  }
   isSane();
-  if (::testing::Test::HasFatalFailure()) return;
-  if (customAllocator<Vector>::value) verifyAllocator(v.size(), v.capacity());
+  if (::testing::Test::HasFatalFailure()) {
+    return;
+  }
+  if (customAllocator<Vector>::value) {
+    verifyAllocator(v.size(), v.capacity());
+  }
 }
 template <class Vector>
 void verify(int extras, const Vector& v1, const Vector& v2) {
@@ -1445,11 +1455,16 @@ void verify(int extras, const Vector& v1, const Vector& v2) {
     size += v2.size();
     cap += v2.capacity();
   }
-  if (!is_arithmetic<typename Vector::value_type>::value)
+  if (!is_arithmetic<typename Vector::value_type>::value) {
     ASSERT_EQ(size + extras, getTotal()) << "not all Data are in the vector(s)";
+  }
   isSane();
-  if (::testing::Test::HasFatalFailure()) return;
-  if (customAllocator<Vector>::value) verifyAllocator(size, cap);
+  if (::testing::Test::HasFatalFailure()) {
+    return;
+  }
+  if (customAllocator<Vector>::value) {
+    verifyAllocator(size, cap);
+  }
 }
 
 //=============================================================================
@@ -1495,9 +1510,13 @@ class DataState {
   }
 
   bool operator==(const DataState& o) const {
-    if (size_ != o.size_) return false;
+    if (size_ != o.size_) {
+      return false;
+    }
     for (size_type i = 0; i < size_; ++i) {
-      if (data_[i] != o.data_[i]) return false;
+      if (data_[i] != o.data_[i]) {
+        return false;
+      }
     }
     return true;
   }
@@ -2071,7 +2090,9 @@ STL_TEST("23.2.1-7", inputIteratorAllocConstruction,
 
 STL_TEST("23.2.1-7", ilAllocConstruction, is_arithmetic, m) {
   // gcc fail
-  if (Ticker::TicksLeft >= 0) return;
+  if (Ticker::TicksLeft >= 0) {
+    return;
+  }
 
   const auto& cm = m;
 
@@ -2123,8 +2144,10 @@ STL_TEST("23.2.3 Table 100.1", nCopyConstruction,
 
   ASSERT_TRUE(Allocator() == u.get_allocator());
   ASSERT_EQ(n, u.size()) << "Vector(n, t).size() != n" << endl;
-  for (const auto& val : u) ASSERT_EQ(convertToInt(t), convertToInt(val))
-    << "not all elements of Vector(n, t) are equal to t";
+  for (const auto& val : u) {
+    ASSERT_EQ(convertToInt(t), convertToInt(val))
+        << "not all elements of Vector(n, t) are equal to t";
+  }
 }
 
 STL_TEST("23.2.3 Table 100.2", forwardIteratorConstruction,
@@ -2143,9 +2166,10 @@ STL_TEST("23.2.3 Table 100.2", forwardIteratorConstruction,
   ASSERT_LE(Counter::CountTotalOps, j-i);
 
   ASSERT_EQ(j - i, u.size()) << "u(i,j).size() != j-i";
-  for (auto it = u.begin(); it != u.end(); ++it, ++i)
+  for (auto it = u.begin(); it != u.end(); ++it, ++i) {
     ASSERT_EQ(*i, convertToInt(*it)) << "u(i,j) constructed incorrectly";
 }
+}
 
 STL_TEST("23.2.3 Table 100.2", inputIteratorConstruction,
          is_move_constructible, i, j) {
@@ -2162,16 +2186,19 @@ STL_TEST("23.2.3 Table 100.2", inputIteratorConstruction,
 
   ASSERT_TRUE(Allocator() == u.get_allocator());
   ASSERT_EQ(j - i, u.size()) << "u(i,j).size() != j-i";
-  for (auto it = u.begin(); it != u.end(); ++it, ++i)
+  for (auto it = u.begin(); it != u.end(); ++it, ++i) {
     ASSERT_EQ(*i, convertToInt(*it)) << "u(i,j) constructed incorrectly";
 }
+}
 
 STL_TEST("23.2.3 Table 100.3", ilConstruction, is_arithmetic) {
   // whitebox: ensure that Vector(il) is implemented in terms of
   // Vector(il.begin(), il.end())
 
   // gcc fail
-  if (Ticker::TicksLeft >= 0) return;
+  if (Ticker::TicksLeft >= 0) {
+    return;
+  }
 
   Vector u = { 1, 4, 7 };
 
@@ -2179,9 +2206,10 @@ STL_TEST("23.2.3 Table 100.3", ilConstruction, is_arithmetic) {
   ASSERT_EQ(3, u.size()) << "u(il).size() fail";
   int i = 1;
   auto it = u.begin();
-  for (; it != u.end(); ++it, i += 3)
+  for (; it != u.end(); ++it, i += 3) {
     ASSERT_EQ(i, convertToInt(*it)) << "u(il) constructed incorrectly";
 }
+}
 
 STL_TEST("23.2.3 Table 100.4", ilAssignment,
          is_arithmetic, a) {
@@ -2189,7 +2217,9 @@ STL_TEST("23.2.3 Table 100.4", ilAssignment,
   // assign(il.begin(), il.end())
 
   // gcc fail
-  if (Ticker::TicksLeft >= 0) return;
+  if (Ticker::TicksLeft >= 0) {
+    return;
+  }
 
   auto am = a.get_allocator();
 
@@ -2201,9 +2231,10 @@ STL_TEST("23.2.3 Table 100.4", ilAssignment,
   ASSERT_EQ(3, a.size()) << "u(il).size() fail";
   int i = 1;
   auto it = a.begin();
-  for (; it != a.end(); ++it, i += 3)
+  for (; it != a.end(); ++it, i += 3) {
     ASSERT_EQ(i, convertToInt(*it)) << "u(il) constructed incorrectly";
 }
+}
 
 //----------------------------
 // insert-and-erase subsection
@@ -2255,7 +2286,9 @@ STL_TEST("23.2.3 Table 100.6", iteratorInsertion,
 STL_TEST("23.2.3 Table 100.7", iteratorInsertionRV,
          is_move_constructibleAndAssignable, a, p, t) {
   // rvalue-references cannot have their address checked for aliased inserts
-  if (a.data() <= addressof(t) && addressof(t) < a.data() + a.size()) return;
+  if (a.data() <= addressof(t) && addressof(t) < a.data() + a.size()) {
+    return;
+  }
 
   DataState<Vector> dsa(a);
   int idx = distance(a.begin(), p);
@@ -2360,7 +2393,9 @@ STL_TEST("23.2.3 Table 100.9", iteratorInsertionInputIterator,
 STL_TEST("23.2.3 Table 100.10", iteratorInsertIL,
          is_arithmetic, a, p) {
   // gcc fail
-  if (Ticker::TicksLeft >= 0) return;
+  if (Ticker::TicksLeft >= 0) {
+    return;
+  }
 
   // whitebox: ensure that insert(p, il) is implemented in terms of
   // insert(p, il.begin(), il.end())
@@ -2392,13 +2427,17 @@ void eraseCheck(Vector& a, DataState<Vector>& dsa, int idx, int n) {
   int i = 0;
   auto it = a.begin();
   for (; it != a.end(); ++it, ++i) {
-    if (i == idx) i += n;
+    if (i == idx) {
+      i += n;
+    }
     ASSERT_EQ(dsa[i], convertToInt(*it));
   }
 }
 
 STL_TEST("23.2.3 Table 100.11", iteratorErase, is_move_assignable, a, p) {
-  if (p == a.end()) return;
+  if (p == a.end()) {
+    return;
+  }
 
   DataState<Vector> dsa(a);
   int idx = distance(a.begin(), p);
@@ -2413,7 +2452,9 @@ STL_TEST("23.2.3 Table 100.11", iteratorErase, is_move_assignable, a, p) {
 
 STL_TEST("23.2.3 Table 100.12", iteratorEraseRange,
          is_move_assignable, a, p, q) {
-  if (p == a.end()) return;
+  if (p == a.end()) {
+    return;
+  }
 
   DataState<Vector> dsa(a);
   int idx = distance(a.begin(), p);
@@ -2454,9 +2495,10 @@ STL_TEST("23.2.3 Table 100.14", assignRange, is_move_assignable, a, i, j) {
 
   ASSERT_TRUE(am == a.get_allocator());
   ASSERT_EQ(distance(i, j), a.size());
-  for (auto it = a.begin(); it != a.end(); ++it, ++i)
+  for (auto it = a.begin(); it != a.end(); ++it, ++i) {
     ASSERT_EQ(*i, convertToInt(*it));
 }
+}
 
 STL_TEST("23.2.3 Table 100.14", assignInputRange,
          is_move_constructibleAndAssignable, a, i, j) {
@@ -2470,9 +2512,10 @@ STL_TEST("23.2.3 Table 100.14", assignInputRange,
 
   ASSERT_TRUE(am == a.get_allocator());
   ASSERT_EQ(distance(i, j), a.size());
-  for (auto it = a.begin(); it != a.end(); ++it, ++i)
+  for (auto it = a.begin(); it != a.end(); ++it, ++i) {
     ASSERT_EQ(*i, convertToInt(*it));
 }
+}
 
 STL_TEST("23.2.3 Table 100.15", assignIL,
          is_arithmetic, a) {
@@ -2481,7 +2524,9 @@ STL_TEST("23.2.3 Table 100.15", assignIL,
   // assign(il.begin(), il.end())
 
   // gcc fail
-  if (Ticker::TicksLeft >= 0) return;
+  if (Ticker::TicksLeft >= 0) {
+    return;
+  }
 
   auto am = a.get_allocator();
 
@@ -2492,9 +2537,10 @@ STL_TEST("23.2.3 Table 100.15", assignIL,
   int* i = ila;
 
   ASSERT_EQ(3, a.size());
-  for (auto it = a.begin(); it != a.end(); ++it, ++i)
+  for (auto it = a.begin(); it != a.end(); ++it, ++i) {
     ASSERT_EQ(*i, convertToInt(*it));
 }
+}
 
 STL_TEST("23.2.3 Table 100.16", assignN,
          is_copy_constructibleAndAssignable, a, n, t) {
@@ -2506,12 +2552,15 @@ STL_TEST("23.2.3 Table 100.16", assignN,
 
   ASSERT_TRUE(am == a.get_allocator());
   ASSERT_EQ(n, a.size());
-  for (auto it = a.begin(); it != a.end(); ++it)
+  for (auto it = a.begin(); it != a.end(); ++it) {
     ASSERT_EQ(tval, convertToInt(*it));
 }
+}
 
 STL_TEST("23.2.3 Table 101.1", front, is_destructible, a) {
-  if (a.empty()) return;
+  if (a.empty()) {
+    return;
+  }
 
   ASSERT_TRUE(addressof(a.front()) == a.data());
 
@@ -2525,7 +2574,9 @@ STL_TEST("23.2.3 Table 101.1", front, is_destructible, a) {
 }
 
 STL_TEST("23.2.3 Table 101.2", back, is_destructible, a) {
-  if (a.empty()) return;
+  if (a.empty()) {
+    return;
+  }
 
   ASSERT_TRUE(addressof(a.back()) == a.data() + a.size() - 1);
 
@@ -2553,12 +2604,15 @@ STL_TEST("23.2.3 Table 101.4", emplaceBack,
   }
 
   ASSERT_TRUE(am == a.get_allocator());
-  if (excess > 0) ASSERT_TRUE(a.data() == adata) << "unnecessary relocation";
+  if (excess > 0) {
+    ASSERT_TRUE(a.data() == adata) << "unnecessary relocation";
+  }
   ASSERT_EQ(dsa.size() + 1, a.size());
   size_t i = 0;
   auto it = a.begin();
-  for (; i < dsa.size(); ++i, ++it)
+  for (; i < dsa.size(); ++i, ++it) {
     ASSERT_EQ(dsa[i], convertToInt(*it));
+  }
   ASSERT_EQ(44, convertToInt(a.back()));
 }
 
@@ -2578,12 +2632,15 @@ STL_TEST("23.2.3 Table 101.7", pushBack, is_copy_constructible, a, t) {
   }
 
   ASSERT_TRUE(am == a.get_allocator());
-  if (excess > 0) ASSERT_TRUE(a.data() == adata) << "unnecessary relocation";
+  if (excess > 0) {
+    ASSERT_TRUE(a.data() == adata) << "unnecessary relocation";
+  }
   ASSERT_EQ(dsa.size() + 1, a.size());
   size_t i = 0;
   auto it = a.begin();
-  for (; i < dsa.size(); ++i, ++it)
+  for (; i < dsa.size(); ++i, ++it) {
     ASSERT_EQ(dsa[i], convertToInt(*it));
+  }
   ASSERT_EQ(tval, convertToInt(a.back()));
 }
 
@@ -2603,17 +2660,22 @@ STL_TEST("23.2.3 Table 101.8", pushBackRV,
   }
 
   ASSERT_TRUE(am == a.get_allocator());
-  if (excess > 0) ASSERT_TRUE(a.data() == adata) << "unnecessary relocation";
+  if (excess > 0) {
+    ASSERT_TRUE(a.data() == adata) << "unnecessary relocation";
+  }
   ASSERT_EQ(dsa.size() + 1, a.size());
   size_t i = 0;
   auto it = a.begin();
-  for (; i < dsa.size(); ++i, ++it)
+  for (; i < dsa.size(); ++i, ++it) {
     ASSERT_EQ(dsa[i], convertToInt(*it));
+  }
   ASSERT_EQ(tval, convertToInt(a.back()));
 }
 
 STL_TEST("23.2.3 Table 100.10", popBack, is_destructible, a) {
-  if (a.empty()) return;
+  if (a.empty()) {
+    return;
+  }
 
   DataState<Vector> dsa(a);
   auto am = a.get_allocator();
@@ -2624,14 +2686,16 @@ STL_TEST("23.2.3 Table 100.10", popBack, is_destructible, a) {
   ASSERT_EQ(dsa.size() - 1, a.size());
   size_t i = 0;
   auto it = a.begin();
-  for (; it != a.end(); ++it, ++i)
+  for (; it != a.end(); ++it, ++i) {
     ASSERT_EQ(dsa[i], convertToInt(*it));
 }
+}
 
 STL_TEST("23.2.3 Table 100.11", operatorBrace, is_destructible, a) {
   const auto& ca = a;
-  for (size_t i = 0; i < ca.size(); ++i)
+  for (size_t i = 0; i < ca.size(); ++i) {
     ASSERT_TRUE(addressof(ca[i]) == ca.data()+i);
+  }
 
   ASSERT_EQ(0, Counter::CountTotalOps);
 
@@ -2642,8 +2706,9 @@ STL_TEST("23.2.3 Table 100.11", operatorBrace, is_destructible, a) {
 
 STL_TEST("23.2.3 Table 100.12", at, is_destructible, a) {
   const auto& ca = a;
-  for (size_t i = 0; i < ca.size(); ++i)
+  for (size_t i = 0; i < ca.size(); ++i) {
     ASSERT_TRUE(addressof(ca.at(i)) == ca.data()+i);
+  }
 
   ASSERT_EQ(0, Counter::CountTotalOps);
 
@@ -2710,7 +2775,9 @@ STL_TEST("23.3.6.3", reserve, is_move_constructible, a, n) {
 STL_TEST("23.3.6.3", lengthError, is_move_constructible) {
   auto mx = Vector().max_size();
   auto big = mx+1;
-  if (mx >= big) return; // max_size is the biggest size_type; overflowed
+  if (mx >= big) {
+    return; // max_size is the biggest size_type; overflowed
+  }
 
   Vector u;
   try {