folly/AtomicHashArray: use an unsigned type for each of two counters
authorJim Meyering <meyering@fb.com>
Tue, 6 Jan 2015 20:40:30 +0000 (12:40 -0800)
committerViswanath Sivakumar <viswanath@fb.com>
Tue, 13 Jan 2015 19:01:04 +0000 (11:01 -0800)
Summary:
* folly/AtomicHashArray.h (numEntries_, numPendingEntries_):
Use an unsigned type for each of these.  They count things, can
never go below 0, and are compared to unsigned values.
Otherwise, gcc-4.9 would emit this:
folly/AtomicHashArray-inl.h:153:38: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]

Test Plan:
Run this and note there are fewer errors than before:
fbconfig --platform-all=gcc-4.9-glibc-2.20 -r folly && fbmake dbgo

Reviewed By: philipp@fb.com

Subscribers: trunkagent, folly-diffs@

FB internal diff: D1770695

Tasks: 5941250

Signature: t1:1770695:1420683354:bfa4775bc2f8aab74e34772308a5c8b1779243b8

folly/AtomicHashArray.h

index f00e3074ea06e18cfbdc94d766a21f64d47f5930..373e7c5eded3b4776b3fab369f5a4eda5257a179 100644 (file)
@@ -265,8 +265,8 @@ class AtomicHashArray : boost::noncopyable {
   // reading the value, so be careful of calling size() too frequently.  This
   // increases insertion throughput several times over while keeping the count
   // accurate.
-  ThreadCachedInt<int64_t> numEntries_;  // Successful key inserts
-  ThreadCachedInt<int64_t> numPendingEntries_; // Used by insertInternal
+  ThreadCachedInt<uint64_t> numEntries_;  // Successful key inserts
+  ThreadCachedInt<uint64_t> numPendingEntries_; // Used by insertInternal
   std::atomic<int64_t> isFull_; // Used by insertInternal
   std::atomic<int64_t> numErases_;   // Successful key erases