Easy: fix signed/unsigned comparisons
authorAnton Likhtarov <alikhtarov@fb.com>
Thu, 27 Feb 2014 01:51:49 +0000 (17:51 -0800)
committerDave Watson <davejwatson@fb.com>
Fri, 28 Feb 2014 22:03:20 +0000 (14:03 -0800)
Test Plan: build with -Wsign-compare, no warnings

Reviewed By: njormrod@fb.com

FB internal diff: D1193502

folly/FBString.h
folly/detail/ThreadLocalDetail.h

index 7a1aa8b00f54b46edf2c62b13e3ccdaf28014851..3d4ceecc53798bfb81a9c1d02783766ce0523b0d 100644 (file)
@@ -867,7 +867,9 @@ private:
   }
 
   size_t smallSize() const {
-    assert(category() == isSmall && small_[maxSmallSize] <= maxSmallSize);
+    assert(category() == isSmall &&
+           static_cast<size_t>(small_[maxSmallSize])
+           <= static_cast<size_t>(maxSmallSize));
     return static_cast<size_t>(maxSmallSize)
       - static_cast<size_t>(small_[maxSmallSize]);
   }
index 86910f0df8e754f0688d64294ebb305dad7a6199..dc4cf76e60ca5361c560ddeac8f835c3a0a73959 100644 (file)
@@ -263,7 +263,7 @@ struct StaticMeta {
     return id;
   }
 
-  static void destroy(int id) {
+  static void destroy(size_t id) {
     try {
       auto & meta = instance();
       // Elements in other threads that use this id.
@@ -401,7 +401,7 @@ struct StaticMeta {
 #endif
   }
 
-  static ElementWrapper& get(int id) {
+  static ElementWrapper& get(size_t id) {
     ThreadEntry* threadEntry = getThreadEntry();
     if (UNLIKELY(threadEntry->elementsCapacity <= id)) {
       reserve(id);
@@ -420,4 +420,3 @@ template <class Tag> StaticMeta<Tag>* StaticMeta<Tag>::inst_ = nullptr;
 }  // namespace folly
 
 #endif /* FOLLY_DETAIL_THREADLOCALDETAIL_H_ */
-