Allow folly to compile cleanly with most of the rest of MSVC's sign mismatch warnings
authorChristopher Dykes <cdykes@fb.com>
Fri, 16 Dec 2016 04:09:21 +0000 (20:09 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Fri, 16 Dec 2016 04:18:06 +0000 (20:18 -0800)
Summary:
This allows folly to compile with warnings 4245, 4287 and 4365 enabled, all of which are sign mismatch warnings.
This is labeled as 'mostly' because I'll probably have to clean up a few more of these.

Reviewed By: yfeldblum

Differential Revision: D4263259

fbshipit-source-id: 0db618f0405817503a63094edd75b24ec1e5c9ad

31 files changed:
folly/Bits.h
folly/Conv.h
folly/CpuId.h
folly/FBString.h
folly/FBVector.h
folly/Format-inl.h
folly/Format.h
folly/FormatArg.h
folly/GroupVarint.h
folly/MPMCQueue.h
folly/RWSpinLock.h
folly/Random.cpp
folly/Range.h
folly/SpookyHashV1.h
folly/SpookyHashV2.h
folly/String.cpp
folly/detail/BitsDetail.h
folly/detail/FileUtilDetail.h
folly/detail/GroupVarintDetail.h
folly/detail/RangeCommon.cpp
folly/detail/RangeCommon.h
folly/detail/TurnSequencer.h
folly/dynamic-inl.h
folly/experimental/Instructions.h
folly/experimental/JSONSchema.cpp
folly/fibers/Baton.cpp
folly/fibers/Semaphore.h
folly/gen/File-inl.h
folly/io/IOBuf.h
folly/io/RecordIO.cpp
folly/json.cpp

index 6c794b12cd4082d391c6dff0a25d2f8faa220abb..04a1b8eca0dd015f561ba28e0b056aa5909a0717 100644 (file)
@@ -263,8 +263,11 @@ our_bswap16(Int16 x) {
 
 #endif
 
 
 #endif
 
-#define FB_GEN(t, fn) \
-template<> inline t EndianIntBase<t>::swap(t x) { return fn(x); }
+#define FB_GEN(t, fn)                             \
+  template <>                                     \
+  inline t EndianIntBase<t>::swap(t x) {          \
+    return t(fn(std::make_unsigned<t>::type(x))); \
+  }
 
 // fn(x) expands to (x) if the second argument is empty, which is exactly
 // what we want for [u]int8_t. Also, gcc 4.7 on Intel doesn't have
 
 // fn(x) expands to (x) if the second argument is empty, which is exactly
 // what we want for [u]int8_t. Also, gcc 4.7 on Intel doesn't have
index 37764d2434cfdb8725eafabb0c98aa520fe0d780..b034e2ef27f3517078abcbc70d87aced4219c65a 100644 (file)
@@ -557,9 +557,10 @@ toAppend(Src value, Tgt * result) {
   char buffer[20];
   if (value < 0) {
     result->push_back('-');
   char buffer[20];
   if (value < 0) {
     result->push_back('-');
-    result->append(buffer, uint64ToBufferUnsafe(-uint64_t(value), buffer));
+    result->append(
+        buffer, uint64ToBufferUnsafe(uint64_t(-uint64_t(value)), buffer));
   } else {
   } else {
-    result->append(buffer, uint64ToBufferUnsafe(value, buffer));
+    result->append(buffer, uint64ToBufferUnsafe(uint64_t(value), buffer));
   }
 }
 
   }
 }
 
@@ -681,14 +682,14 @@ toAppend(
       conv.ToShortest(value, &builder);
       break;
     case DoubleToStringConverter::FIXED:
       conv.ToShortest(value, &builder);
       break;
     case DoubleToStringConverter::FIXED:
-      conv.ToFixed(value, numDigits, &builder);
+      conv.ToFixed(value, int(numDigits), &builder);
       break;
     default:
       CHECK(mode == DoubleToStringConverter::PRECISION);
       break;
     default:
       CHECK(mode == DoubleToStringConverter::PRECISION);
-      conv.ToPrecision(value, numDigits, &builder);
+      conv.ToPrecision(value, int(numDigits), &builder);
       break;
   }
       break;
   }
-  const size_t length = builder.position();
+  const size_t length = size_t(builder.position());
   builder.Finalize();
   result->append(buffer, length);
 }
   builder.Finalize();
   result->append(buffer, length);
 }
@@ -730,7 +731,9 @@ estimateSpaceNeeded(Src value) {
       // so 21 is the longest non-exponential number > 1.
       detail::kConvMaxDecimalInShortestHigh
     });
       // so 21 is the longest non-exponential number > 1.
       detail::kConvMaxDecimalInShortestHigh
     });
-  return kMaxPositiveSpace + (value < 0);  // +1 for minus sign, if negative
+  return size_t(
+      kMaxPositiveSpace +
+      (value < 0 ? 1 : 0)); // +1 for minus sign, if negative
 }
 
 /**
 }
 
 /**
index 908480411ffdf69dfb5fffa7b819dd13a4df5711..26fa1979ba24fbab2462e37f5395ab3c8b2262b2 100644 (file)
@@ -45,13 +45,13 @@ class CpuId {
     const int n = reg[0];
     if (n >= 1) {
       __cpuid(static_cast<int*>(reg), 1);
     const int n = reg[0];
     if (n >= 1) {
       __cpuid(static_cast<int*>(reg), 1);
-      f1c_ = reg[2];
-      f1d_ = reg[3];
+      f1c_ = uint32_t(reg[2]);
+      f1d_ = uint32_t(reg[3]);
     }
     if (n >= 7) {
       __cpuidex(static_cast<int*>(reg), 7, 0);
     }
     if (n >= 7) {
       __cpuidex(static_cast<int*>(reg), 7, 0);
-      f7b_ = reg[1];
-      f7c_ = reg[2];
+      f7b_ = uint32_t(reg[1]);
+      f7c_ = uint32_t(reg[2]);
     }
 #elif defined(__i386__) && defined(__PIC__) && !defined(__clang__) && \
     defined(__GNUC__)
     }
 #elif defined(__i386__) && defined(__PIC__) && !defined(__clang__) && \
     defined(__GNUC__)
index 7a9252d7aeef9a202350e747a9f650a6e729e574..43f4e33e1340d19e10f043779a242033caa0f81d 100644 (file)
@@ -136,7 +136,7 @@ template <class Pod, class T>
 inline void podFill(Pod* b, Pod* e, T c) {
   FBSTRING_ASSERT(b && e && b <= e);
   /*static*/ if (sizeof(T) == 1) {
 inline void podFill(Pod* b, Pod* e, T c) {
   FBSTRING_ASSERT(b && e && b <= e);
   /*static*/ if (sizeof(T) == 1) {
-    memset(b, c, e - b);
+    memset(b, c, size_t(e - b));
   } else {
     auto const ee = b + ((e - b) & ~7u);
     for (; b != ee; b += 8) {
   } else {
     auto const ee = b + ((e - b) & ~7u);
     for (; b != ee; b += 8) {
@@ -1184,7 +1184,7 @@ public:
   // Specialization for const char*, const char*
   FOLLY_MALLOC_NOINLINE
   basic_fbstring(const value_type* b, const value_type* e, const A& /*a*/ = A())
   // Specialization for const char*, const char*
   FOLLY_MALLOC_NOINLINE
   basic_fbstring(const value_type* b, const value_type* e, const A& /*a*/ = A())
-      : store_(b, e - b) {
+      : store_(b, size_type(e - b)) {
   }
 
   // Nonstandard constructor
   }
 
   // Nonstandard constructor
@@ -2705,7 +2705,7 @@ operator<<(
   }
 #elif defined(_MSC_VER)
   // MSVC doesn't define __ostream_insert
   }
 #elif defined(_MSC_VER)
   // MSVC doesn't define __ostream_insert
-  os.write(str.data(), str.size());
+  os.write(str.data(), std::streamsize(str.size()));
 #else
   std::__ostream_insert(os, str.data(), str.size());
 #endif
 #else
   std::__ostream_insert(os, str.data(), str.size());
 #endif
index 0979f8836a04563cce31c7c9df3f6799ad1f69f0..1bcc76513a793e42534756a176e9fe1784cfe16f 100644 (file)
@@ -149,7 +149,7 @@ private:
           S_destroy_range_a(*this, b_, e_);
         }
 
           S_destroy_range_a(*this, b_, e_);
         }
 
-        D_deallocate(b_, z_ - b_);
+        D_deallocate(b_, size_type(z_ - b_));
       }
     }
 
       }
     }
 
@@ -915,7 +915,7 @@ public:
 public:
 
   size_type size() const noexcept {
 public:
 
   size_type size() const noexcept {
-    return impl_.e_ - impl_.b_;
+    return size_type(impl_.e_ - impl_.b_);
   }
 
   size_type max_size() const noexcept {
   }
 
   size_type max_size() const noexcept {
@@ -946,7 +946,7 @@ public:
   }
 
   size_type capacity() const noexcept {
   }
 
   size_type capacity() const noexcept {
-    return impl_.z_ - impl_.b_;
+    return size_type(impl_.z_ - impl_.b_);
   }
 
   bool empty() const noexcept {
   }
 
   bool empty() const noexcept {
@@ -966,7 +966,7 @@ public:
       throw;
     }
     if (impl_.b_)
       throw;
     }
     if (impl_.b_)
-      M_deallocate(impl_.b_, impl_.z_ - 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;
     impl_.z_ = newB + newCap;
     impl_.e_ = newB + (impl_.e_ - impl_.b_);
     impl_.b_ = newB;
index 7b717363152cd0d2b67219805ebff951c0638789..d116f5a23e409744e6fb79a4e99f5668c8b1eb4a 100644 (file)
@@ -174,7 +174,7 @@ void BaseFormatter<Derived, containerMode, Args...>::operator()(Output& out)
     auto p = s.begin();
     auto end = s.end();
     while (p != end) {
     auto p = s.begin();
     auto end = s.end();
     while (p != end) {
-      auto q = static_cast<const char*>(memchr(p, '}', end - p));
+      auto q = static_cast<const char*>(memchr(p, '}', size_t(end - p)));
       if (!q) {
         out(StringPiece(p, end));
         break;
       if (!q) {
         out(StringPiece(p, end));
         break;
@@ -197,7 +197,7 @@ void BaseFormatter<Derived, containerMode, Args...>::operator()(Output& out)
   bool hasDefaultArgIndex = false;
   bool hasExplicitArgIndex = false;
   while (p != end) {
   bool hasDefaultArgIndex = false;
   bool hasExplicitArgIndex = false;
   while (p != end) {
-    auto q = static_cast<const char*>(memchr(p, '{', end - p));
+    auto q = static_cast<const char*>(memchr(p, '{', size_t(end - p)));
     if (!q) {
       outputString(StringPiece(p, end));
       break;
     if (!q) {
       outputString(StringPiece(p, end));
       break;
@@ -217,7 +217,7 @@ void BaseFormatter<Derived, containerMode, Args...>::operator()(Output& out)
     }
 
     // Format string
     }
 
     // Format string
-    q = static_cast<const char*>(memchr(p, '}', end - p));
+    q = static_cast<const char*>(memchr(p, '}', size_t(end - p)));
     if (q == nullptr) {
       throw BadFormatArg("folly::format: missing ending '}'");
     }
     if (q == nullptr) {
       throw BadFormatArg("folly::format: missing ending '}'");
     }
@@ -242,7 +242,7 @@ void BaseFormatter<Derived, containerMode, Args...>::operator()(Output& out)
           arg.enforce(arg.widthIndex == FormatArg::kNoIndex,
                       "cannot provide width arg index without value arg index");
           int sizeArg = nextArg++;
           arg.enforce(arg.widthIndex == FormatArg::kNoIndex,
                       "cannot provide width arg index without value arg index");
           int sizeArg = nextArg++;
-          arg.width = getSizeArg(sizeArg, arg);
+          arg.width = getSizeArg(size_t(sizeArg), arg);
         }
 
         argIndex = nextArg++;
         }
 
         argIndex = nextArg++;
@@ -251,7 +251,7 @@ void BaseFormatter<Derived, containerMode, Args...>::operator()(Output& out)
         if (arg.width == FormatArg::kDynamicWidth) {
           arg.enforce(arg.widthIndex != FormatArg::kNoIndex,
                       "cannot provide value arg index without width arg index");
         if (arg.width == FormatArg::kDynamicWidth) {
           arg.enforce(arg.widthIndex != FormatArg::kNoIndex,
                       "cannot provide value arg index without width arg index");
-          arg.width = getSizeArg(arg.widthIndex, arg);
+          arg.width = getSizeArg(size_t(arg.widthIndex), arg);
         }
 
         try {
         }
 
         try {
@@ -269,7 +269,7 @@ void BaseFormatter<Derived, containerMode, Args...>::operator()(Output& out)
           "folly::format: may not have both default and explicit arg indexes");
     }
 
           "folly::format: may not have both default and explicit arg indexes");
     }
 
-    doFormat(argIndex, arg, out);
+    doFormat(size_t(argIndex), arg, out);
   }
 }
 
   }
 }
 
@@ -302,7 +302,7 @@ void formatString(StringPiece val, FormatArg& arg, FormatCallback& cb) {
 
   if (arg.precision != FormatArg::kDefaultPrecision &&
       val.size() > static_cast<size_t>(arg.precision)) {
 
   if (arg.precision != FormatArg::kDefaultPrecision &&
       val.size() > static_cast<size_t>(arg.precision)) {
-    val.reset(val.data(), arg.precision);
+    val.reset(val.data(), size_t(arg.precision));
   }
 
   constexpr int padBufSize = 128;
   }
 
   constexpr int padBufSize = 128;
@@ -312,7 +312,7 @@ void formatString(StringPiece val, FormatArg& arg, FormatCallback& cb) {
   auto pad = [&padBuf, &cb, padBufSize] (int chars) {
     while (chars) {
       int n = std::min(chars, padBufSize);
   auto pad = [&padBuf, &cb, padBufSize] (int chars) {
     while (chars) {
       int n = std::min(chars, padBufSize);
-      cb(StringPiece(padBuf, n));
+      cb(StringPiece(padBuf, size_t(n)));
       chars -= n;
     }
   };
       chars -= n;
     }
   };
@@ -322,7 +322,7 @@ void formatString(StringPiece val, FormatArg& arg, FormatCallback& cb) {
       val.size() < static_cast<size_t>(arg.width)) {
     char fill = arg.fill == FormatArg::kDefaultFill ? ' ' : arg.fill;
     int padChars = static_cast<int> (arg.width - val.size());
       val.size() < static_cast<size_t>(arg.width)) {
     char fill = arg.fill == FormatArg::kDefaultFill ? ' ' : arg.fill;
     int padChars = static_cast<int> (arg.width - val.size());
-    memset(padBuf, fill, std::min(padBufSize, padChars));
+    memset(padBuf, fill, size_t(std::min(padBufSize, padChars)));
 
     switch (arg.align) {
     case FormatArg::Align::DEFAULT:
 
     switch (arg.align) {
     case FormatArg::Align::DEFAULT:
@@ -359,8 +359,8 @@ void formatNumber(StringPiece val, int prefixLen, FormatArg& arg,
     arg.align = FormatArg::Align::RIGHT;
   } else if (prefixLen && arg.align == FormatArg::Align::PAD_AFTER_SIGN) {
     // Split off the prefix, then do any padding if necessary
     arg.align = FormatArg::Align::RIGHT;
   } else if (prefixLen && arg.align == FormatArg::Align::PAD_AFTER_SIGN) {
     // Split off the prefix, then do any padding if necessary
-    cb(val.subpiece(0, prefixLen));
-    val.advance(prefixLen);
+    cb(val.subpiece(0, size_t(prefixLen)));
+    val.advance(size_t(prefixLen));
     arg.width = std::max(arg.width - prefixLen, 0);
   }
   format_value::formatString(val, arg, cb);
     arg.width = std::max(arg.width - prefixLen, 0);
   }
   format_value::formatString(val, arg, cb);
@@ -444,7 +444,7 @@ class FormatValue<
     char sign;
     if (std::is_signed<T>::value) {
       if (folly::is_negative(val_)) {
     char sign;
     if (std::is_signed<T>::value) {
       if (folly::is_negative(val_)) {
-        uval = -static_cast<UT>(val_);
+        uval = UT(-static_cast<UT>(val_));
         sign = '-';
       } else {
         uval = static_cast<UT>(val_);
         sign = '-';
       } else {
         uval = static_cast<UT>(val_);
@@ -461,7 +461,7 @@ class FormatValue<
         }
       }
     } else {
         }
       }
     } else {
-      uval = val_;
+      uval = static_cast<UT>(val_);
       sign = '\0';
 
       arg.enforce(arg.sign == FormatArg::Sign::DEFAULT,
       sign = '\0';
 
       arg.enforce(arg.sign == FormatArg::Sign::DEFAULT,
@@ -496,8 +496,11 @@ class FormatValue<
       int len = snprintf(valBufBegin, (valBuf + valBufSize) - valBufBegin,
                          "%" PRIuMAX, static_cast<uintmax_t>(uval));
 #else
       int len = snprintf(valBufBegin, (valBuf + valBufSize) - valBufBegin,
                          "%" PRIuMAX, static_cast<uintmax_t>(uval));
 #else
-      int len = snprintf(valBufBegin, (valBuf + valBufSize) - valBufBegin,
-                         "%ju", static_cast<uintmax_t>(uval));
+      int len = snprintf(
+          valBufBegin,
+          size_t((valBuf + valBufSize) - valBufBegin),
+          "%ju",
+          static_cast<uintmax_t>(uval));
 #endif
       // valBufSize should always be big enough, so this should never
       // happen.
 #endif
       // valBufSize should always be big enough, so this should never
       // happen.
@@ -673,7 +676,7 @@ class FormatValue<
                   "invalid specifier '", arg.presentation, "'");
       format_value::formatString(val_, arg, cb);
     } else {
                   "invalid specifier '", arg.presentation, "'");
       format_value::formatString(val_, arg, cb);
     } else {
-      FormatValue<char>(val_.at(arg.splitIntKey())).format(arg, cb);
+      FormatValue<char>(val_.at(size_t(arg.splitIntKey()))).format(arg, cb);
     }
   }
 
     }
   }
 
index c34f333978d3bd4f7a06f6c8483f14d881c5e3c5..1b6c8718552e2d4449313ee27c9c4518367bc39c 100644 (file)
@@ -211,7 +211,9 @@ class Formatter : public BaseFormatter<Formatter<containerMode, Args...>,
 template<bool containerMode, class... Args>
 std::ostream& operator<<(std::ostream& out,
                          const Formatter<containerMode, Args...>& formatter) {
 template<bool containerMode, class... Args>
 std::ostream& operator<<(std::ostream& out,
                          const Formatter<containerMode, Args...>& formatter) {
-  auto writer = [&out] (StringPiece sp) { out.write(sp.data(), sp.size()); };
+  auto writer = [&out](StringPiece sp) {
+    out.write(sp.data(), std::streamsize(sp.size()));
+  };
   formatter(writer);
   return out;
 }
   formatter(writer);
   return out;
 }
index 89c7e9337b5a3486f2841ba1da2b00889d5dd827..33eb262489234dda4a32af0d7384fb73ba4b9740 100644 (file)
@@ -243,10 +243,10 @@ inline StringPiece FormatArg::doSplitKey() {
   const char* p;
   if (e[-1] == ']') {
     --e;
   const char* p;
   if (e[-1] == ']') {
     --e;
-    p = static_cast<const char*>(memchr(b, '[', e - b));
+    p = static_cast<const char*>(memchr(b, '[', size_t(e - b)));
     enforce(p, "unmatched ']'");
   } else {
     enforce(p, "unmatched ']'");
   } else {
-    p = static_cast<const char*>(memchr(b, '.', e - b));
+    p = static_cast<const char*>(memchr(b, '.', size_t(e - b)));
   }
   if (p) {
     key_.assign(p + 1, e);
   }
   if (p) {
     key_.assign(p + 1, e);
index 70a6fc3c3b2a90f4f6f1dc2a90509f9c96687798..ae3afdb8d3f683ca737b5e648cbd4ad637563ebf 100644 (file)
@@ -102,7 +102,7 @@ class GroupVarint<uint32_t> : public detail::GroupVarintBase<uint32_t> {
    * buffer of size bytes.
    */
   static size_t partialCount(const char* p, size_t size) {
    * buffer of size bytes.
    */
   static size_t partialCount(const char* p, size_t size) {
-    char v = *p;
+    uint8_t v = uint8_t(*p);
     size_t s = kHeaderSize;
     s += 1 + b0key(v);
     if (s > size) return 0;
     size_t s = kHeaderSize;
     s += 1 + b0key(v);
     if (s > size) return 0;
@@ -120,8 +120,9 @@ class GroupVarint<uint32_t> : public detail::GroupVarintBase<uint32_t> {
    * return the number of bytes used by the encoding.
    */
   static size_t encodedSize(const char* p) {
    * return the number of bytes used by the encoding.
    */
   static size_t encodedSize(const char* p) {
-    return (kHeaderSize + kGroupSize +
-            b0key(*p) + b1key(*p) + b2key(*p) + b3key(*p));
+    return kHeaderSize + kGroupSize +
+           b0key(uint8_t(*p)) + b1key(uint8_t(*p)) +
+           b2key(uint8_t(*p)) + b3key(uint8_t(*p));
   }
 
   /**
   }
 
   /**
@@ -194,7 +195,7 @@ class GroupVarint<uint32_t> : public detail::GroupVarintBase<uint32_t> {
    * that we must be able to read at least 17 bytes from the input pointer, p.
    */
   static const char* decode(const char* p, uint32_t* dest) {
    * that we must be able to read at least 17 bytes from the input pointer, p.
    */
   static const char* decode(const char* p, uint32_t* dest) {
-    uint8_t key = p[0];
+    uint8_t key = uint8_t(p[0]);
     __m128i val = _mm_loadu_si128((const __m128i*)(p+1));
     __m128i mask =
         _mm_load_si128((const __m128i*)&detail::groupVarintSSEMasks[key * 2]);
     __m128i val = _mm_loadu_si128((const __m128i*)(p+1));
     __m128i mask =
         _mm_load_si128((const __m128i*)&detail::groupVarintSSEMasks[key * 2]);
@@ -209,7 +210,7 @@ class GroupVarint<uint32_t> : public detail::GroupVarintBase<uint32_t> {
    */
   static const char* decode(const char* p, uint32_t* a, uint32_t* b,
                             uint32_t* c, uint32_t* d) {
    */
   static const char* decode(const char* p, uint32_t* a, uint32_t* b,
                             uint32_t* c, uint32_t* d) {
-    uint8_t key = p[0];
+    uint8_t key = uint8_t(p[0]);
     __m128i val = _mm_loadu_si128((const __m128i*)(p+1));
     __m128i mask =
         _mm_load_si128((const __m128i*)&detail::groupVarintSSEMasks[key * 2]);
     __m128i val = _mm_loadu_si128((const __m128i*)(p+1));
     __m128i mask =
         _mm_load_si128((const __m128i*)&detail::groupVarintSSEMasks[key * 2]);
@@ -217,10 +218,10 @@ class GroupVarint<uint32_t> : public detail::GroupVarintBase<uint32_t> {
 
     // Extracting 32 bits at a time out of an XMM register is a SSE4 feature
 #if FOLLY_SSE >= 4
 
     // Extracting 32 bits at a time out of an XMM register is a SSE4 feature
 #if FOLLY_SSE >= 4
-    *a = _mm_extract_epi32(r, 0);
-    *b = _mm_extract_epi32(r, 1);
-    *c = _mm_extract_epi32(r, 2);
-    *d = _mm_extract_epi32(r, 3);
+    *a = uint32_t(_mm_extract_epi32(r, 0));
+    *b = uint32_t(_mm_extract_epi32(r, 1));
+    *c = uint32_t(_mm_extract_epi32(r, 2));
+    *d = uint32_t(_mm_extract_epi32(r, 3));
 #else  /* !__SSE4__ */
     *a = _mm_extract_epi16(r, 0) + (_mm_extract_epi16(r, 1) << 16);
     *b = _mm_extract_epi16(r, 2) + (_mm_extract_epi16(r, 3) << 16);
 #else  /* !__SSE4__ */
     *a = _mm_extract_epi16(r, 0) + (_mm_extract_epi16(r, 1) << 16);
     *b = _mm_extract_epi16(r, 2) + (_mm_extract_epi16(r, 3) << 16);
@@ -274,8 +275,8 @@ class GroupVarint<uint64_t> : public detail::GroupVarintBase<uint64_t> {
    */
   static size_t size(uint64_t a, uint64_t b, uint64_t c, uint64_t d,
                      uint64_t e) {
    */
   static size_t size(uint64_t a, uint64_t b, uint64_t c, uint64_t d,
                      uint64_t e) {
-    return (kHeaderSize + kGroupSize +
-            key(a) + key(b) + key(c) + key(d) + key(e));
+    return kHeaderSize + kGroupSize +
+           key(a) + key(b) + key(c) + key(d) + key(e);
   }
 
   /**
   }
 
   /**
@@ -327,8 +328,8 @@ class GroupVarint<uint64_t> : public detail::GroupVarintBase<uint64_t> {
    */
   static size_t encodedSize(const char* p) {
     uint16_t n = loadUnaligned<uint16_t>(p);
    */
   static size_t encodedSize(const char* p) {
     uint16_t n = loadUnaligned<uint16_t>(p);
-    return (kHeaderSize + kGroupSize +
-            b0key(n) + b1key(n) + b2key(n) + b3key(n) + b4key(n));
+    return kHeaderSize + kGroupSize +
+            b0key(n) + b1key(n) + b2key(n) + b3key(n) + b4key(n);
   }
 
   /**
   }
 
   /**
@@ -338,14 +339,19 @@ class GroupVarint<uint64_t> : public detail::GroupVarintBase<uint64_t> {
    */
   static char* encode(char* p, uint64_t a, uint64_t b, uint64_t c,
                       uint64_t d, uint64_t e) {
    */
   static char* encode(char* p, uint64_t a, uint64_t b, uint64_t c,
                       uint64_t d, uint64_t e) {
-    uint8_t b0key = key(a);
-    uint8_t b1key = key(b);
-    uint8_t b2key = key(c);
-    uint8_t b3key = key(d);
-    uint8_t b4key = key(e);
+    uint16_t b0key = key(a);
+    uint16_t b1key = key(b);
+    uint16_t b2key = key(c);
+    uint16_t b3key = key(d);
+    uint16_t b4key = key(e);
     storeUnaligned<uint16_t>(
         p,
     storeUnaligned<uint16_t>(
         p,
-        (b4key << 12) | (b3key << 9) | (b2key << 6) | (b1key << 3) | b0key);
+        uint16_t(
+            (b4key << 12) |
+            (b3key << 9) |
+            (b2key << 6) |
+            (b1key << 3) |
+            b0key));
     p += 2;
     storeUnaligned(p, a);
     p += b0key+1;
     p += 2;
     storeUnaligned(p, a);
     p += b0key+1;
@@ -412,11 +418,11 @@ class GroupVarint<uint64_t> : public detail::GroupVarintBase<uint64_t> {
     return uint8_t(7 - (__builtin_clzll(x | 1) / 8));
   }
 
     return uint8_t(7 - (__builtin_clzll(x | 1) / 8));
   }
 
-  static uint8_t b0key(uint16_t x) { return x & 7; }
-  static uint8_t b1key(uint16_t x) { return (x >> 3) & 7; }
-  static uint8_t b2key(uint16_t x) { return (x >> 6) & 7; }
-  static uint8_t b3key(uint16_t x) { return (x >> 9) & 7; }
-  static uint8_t b4key(uint16_t x) { return (x >> 12) & 7; }
+  static uint8_t b0key(uint16_t x) { return x & 7u; }
+  static uint8_t b1key(uint16_t x) { return (x >> 3) & 7u; }
+  static uint8_t b2key(uint16_t x) { return (x >> 6) & 7u; }
+  static uint8_t b3key(uint16_t x) { return (x >> 9) & 7u; }
+  static uint8_t b4key(uint16_t x) { return (x >> 12) & 7u; }
 
   static const uint64_t kMask[];
 };
 
   static const uint64_t kMask[];
 };
index ce6e54a0b177aa71e2391a5289db23146e421bc4..74899ae80d2b720f05eabb468750537c6c965a05 100644 (file)
@@ -729,14 +729,14 @@ class MPMCQueueBase<Derived<T, Atom, Dynamic>> : boost::noncopyable {
       if (pushes == nextPushes) {
         // pushTicket_ didn't change from A (or the previous C) to C,
         // so we can linearize at B (or D)
       if (pushes == nextPushes) {
         // pushTicket_ didn't change from A (or the previous C) to C,
         // so we can linearize at B (or D)
-        return pushes - pops;
+        return ssize_t(pushes - pops);
       }
       pushes = nextPushes;
       uint64_t nextPops = popTicket_.load(std::memory_order_acquire); // D
       if (pops == nextPops) {
         // popTicket_ didn't chance from B (or the previous D), so we
         // can linearize at C
       }
       pushes = nextPushes;
       uint64_t nextPops = popTicket_.load(std::memory_order_acquire); // D
       if (pops == nextPops) {
         // popTicket_ didn't chance from B (or the previous D), so we
         // can linearize at C
-        return pushes - pops;
+        return ssize_t(pushes - pops);
       }
       pops = nextPops;
     }
       }
       pops = nextPops;
     }
index eea433cfd0d38374598596f05883873f89f3bfe3..b5effd722ba2a1acc4f72c149fb8ad1cf9d2dad3 100644 (file)
@@ -479,13 +479,14 @@ struct RWTicketIntTrait<64> {
 
 #ifdef RW_SPINLOCK_USE_SSE_INSTRUCTIONS_
   static __m128i make128(const uint16_t v[4]) {
 
 #ifdef RW_SPINLOCK_USE_SSE_INSTRUCTIONS_
   static __m128i make128(const uint16_t v[4]) {
-    return _mm_set_epi16(0, 0, 0, 0, v[3], v[2], v[1], v[0]);
+    return _mm_set_epi16(0, 0, 0, 0,
+        short(v[3]), short(v[2]), short(v[1]), short(v[0]));
   }
   static inline __m128i fromInteger(uint64_t from) {
   }
   static inline __m128i fromInteger(uint64_t from) {
-    return _mm_cvtsi64_si128(from);
+    return _mm_cvtsi64_si128(int64_t(from));
   }
   static inline uint64_t toInteger(__m128i in) {
   }
   static inline uint64_t toInteger(__m128i in) {
-    return _mm_cvtsi128_si64(in);
+    return uint64_t(_mm_cvtsi128_si64(in));
   }
   static inline uint64_t addParallel(__m128i in, __m128i kDelta) {
     return toInteger(_mm_add_epi16(in, kDelta));
   }
   static inline uint64_t addParallel(__m128i in, __m128i kDelta) {
     return toInteger(_mm_add_epi16(in, kDelta));
@@ -501,14 +502,17 @@ struct RWTicketIntTrait<32> {
 
 #ifdef RW_SPINLOCK_USE_SSE_INSTRUCTIONS_
   static __m128i make128(const uint8_t v[4]) {
 
 #ifdef RW_SPINLOCK_USE_SSE_INSTRUCTIONS_
   static __m128i make128(const uint8_t v[4]) {
-    return _mm_set_epi8(0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, v[3], v[2], v[1], v[0]);
+    return _mm_set_epi8(
+        0, 0, 0, 0,
+        0, 0, 0, 0,
+        0, 0, 0, 0,
+        char(v[3]), char(v[2]), char(v[1]), char(v[0]));
   }
   static inline __m128i fromInteger(uint32_t from) {
   }
   static inline __m128i fromInteger(uint32_t from) {
-    return _mm_cvtsi32_si128(from);
+    return _mm_cvtsi32_si128(int32_t(from));
   }
   static inline uint32_t toInteger(__m128i in) {
   }
   static inline uint32_t toInteger(__m128i in) {
-    return _mm_cvtsi128_si32(in);
+    return uint32_t(_mm_cvtsi128_si32(in));
   }
   static inline uint32_t addParallel(__m128i in, __m128i kDelta) {
     return toInteger(_mm_add_epi8(in, kDelta));
   }
   static inline uint32_t addParallel(__m128i in, __m128i kDelta) {
     return toInteger(_mm_add_epi8(in, kDelta));
index d991990e28b60944287529cbd5afa5ca9749b5b5..8d172fe613678238c171cfa64728bcf351a155c7 100644 (file)
@@ -89,7 +89,7 @@ class BufferedRandomDevice {
   void getSlow(unsigned char* data, size_t size);
 
   inline size_t remaining() const {
   void getSlow(unsigned char* data, size_t size);
 
   inline size_t remaining() const {
-    return buffer_.get() + bufferSize_ - ptr_;
+    return size_t(buffer_.get() + bufferSize_ - ptr_);
   }
 
   const size_t bufferSize_;
   }
 
   const size_t bufferSize_;
index 8ab8ae5769869fa060f8793bf0d45468cb8ed8be..e5af94a6fe19de45b0ff1b96608d13b86ab3eefb 100644 (file)
@@ -361,7 +361,7 @@ public:
     // Unfortunately current gcc versions have a bug causing it to reject
     // this check in a constexpr function:
     // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71448
     // Unfortunately current gcc versions have a bug causing it to reject
     // this check in a constexpr function:
     // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71448
-    return e_ - b_;
+    return size_type(e_ - b_);
   }
   constexpr size_type walk_size() const {
     return std::distance(b_, e_);
   }
   constexpr size_type walk_size() const {
     return std::distance(b_, e_);
@@ -912,13 +912,13 @@ typedef Range<unsigned char*> MutableByteRange;
 
 inline std::ostream& operator<<(std::ostream& os,
                                 const StringPiece piece) {
 
 inline std::ostream& operator<<(std::ostream& os,
                                 const StringPiece piece) {
-  os.write(piece.start(), piece.size());
+  os.write(piece.start(), std::streamsize(piece.size()));
   return os;
 }
 
 inline std::ostream& operator<<(std::ostream& os,
                                 const MutableStringPiece piece) {
   return os;
 }
 
 inline std::ostream& operator<<(std::ostream& os,
                                 const MutableStringPiece piece) {
-  os.write(piece.start(), piece.size());
+  os.write(piece.start(), std::streamsize(piece.size()));
   return os;
 }
 
   return os;
 }
 
@@ -1058,7 +1058,7 @@ size_t qfind(const Range<T>& haystack,
       // Check if done searching
       if (++j == nsize) {
         // Yay
       // Check if done searching
       if (++j == nsize) {
         // Yay
-        return i - haystack.begin();
+        return size_t(i - haystack.begin());
       }
     }
   }
       }
     }
   }
index 2a3d86706421085380c059de878f57ce83e23ef0..9cfe02995423d5fd0fc8d6173f59e9f1d1cf73fa 100644 (file)
@@ -291,7 +291,7 @@ private:
     //  * is a not-very-regular mix of 1's and 0's
     //  * does not need any other special mathematical properties
     //
     //  * is a not-very-regular mix of 1's and 0's
     //  * does not need any other special mathematical properties
     //
-    static const uint64_t sc_const = 0xdeadbeefdeadbeefLL;
+    static const uint64_t sc_const = 0xdeadbeefdeadbeefULL;
 
     uint64_t m_data[2*sc_numVars];  // unhashed data, for partial messages
     uint64_t m_state[sc_numVars];   // internal state of the hash
 
     uint64_t m_data[2*sc_numVars];  // unhashed data, for partial messages
     uint64_t m_state[sc_numVars];   // internal state of the hash
index 804191d15fb47d0a4cacd7069d71c7f140ba6e1f..7d14069f012a44c0491a674a5ed5eb32410af976 100644 (file)
@@ -296,7 +296,7 @@ private:
     //  * is a not-very-regular mix of 1's and 0's
     //  * does not need any other special mathematical properties
     //
     //  * is a not-very-regular mix of 1's and 0's
     //  * does not need any other special mathematical properties
     //
-    static constexpr uint64_t sc_const = 0xdeadbeefdeadbeefLL;
+    static constexpr uint64_t sc_const = 0xdeadbeefdeadbeefULL;
 
     uint64_t m_data[2*sc_numVars];   // unhashed data, for partial messages
     uint64_t m_state[sc_numVars];  // internal state of the hash
 
     uint64_t m_data[2*sc_numVars];   // unhashed data, for partial messages
     uint64_t m_state[sc_numVars];  // internal state of the hash
index 06a7d968c6c29e512835ea64603ef4561641b5d8..37bc231fc4cea9def5dfc181ad04fcb09a6a9483 100644 (file)
@@ -575,7 +575,7 @@ std::string stripLeftMargin(std::string s) {
                           piece->end(),
                           [](char c) { return c != ' ' && c != '\t'; });
     if (needle != piece->end()) {
                           piece->end(),
                           [](char c) { return c != ' ' && c != '\t'; });
     if (needle != piece->end()) {
-      indent = std::min<size_t>(indent, needle - piece->begin());
+      indent = std::min<size_t>(indent, size_t(needle - piece->begin()));
     } else {
       max_length = std::max<size_t>(piece->size(), max_length);
     }
     } else {
       max_length = std::max<size_t>(piece->size(), max_length);
     }
index 0613654721581ce8bedea4283e23fd76aac89978..19b0ecbbd04d40b3b65efe5a2516820a93e812e3 100644 (file)
@@ -25,7 +25,7 @@ namespace detail {
 // (see Bits.cpp)
 #ifdef _MSC_VER
 inline int popcount(unsigned int x) {
 // (see Bits.cpp)
 #ifdef _MSC_VER
 inline int popcount(unsigned int x) {
-  return __popcnt(x);
+  return int(__popcnt(x));
 }
 inline int popcountll(unsigned long long x) {
   return int(__popcnt64(x));
 }
 inline int popcountll(unsigned long long x) {
   return int(__popcnt64(x));
index 5b70d65f28261d5c3f9479155fd81f782f8214e7..7ce1f67ea4d6d262ed094e97b65227fdedb522c0 100644 (file)
@@ -73,10 +73,10 @@ ssize_t wrapFull(F f, int fd, void* buf, size_t count, Offset... offset) {
 template <class F, class... Offset>
 ssize_t wrapvFull(F f, int fd, iovec* iov, int count, Offset... offset) {
   ssize_t totalBytes = 0;
 template <class F, class... Offset>
 ssize_t wrapvFull(F f, int fd, iovec* iov, int count, Offset... offset) {
   ssize_t totalBytes = 0;
-  size_t r;
+  ssize_t r;
   do {
     r = f(fd, iov, std::min<int>(count, kIovMax), offset...);
   do {
     r = f(fd, iov, std::min<int>(count, kIovMax), offset...);
-    if (r == (size_t)-1) {
+    if (r == -1) {
       if (errno == EINTR) {
         continue;
       }
       if (errno == EINTR) {
         continue;
       }
@@ -90,8 +90,8 @@ ssize_t wrapvFull(F f, int fd, iovec* iov, int count, Offset... offset) {
     totalBytes += r;
     incr(r, offset...);
     while (r != 0 && count != 0) {
     totalBytes += r;
     incr(r, offset...);
     while (r != 0 && count != 0) {
-      if (r >= iov->iov_len) {
-        r -= iov->iov_len;
+      if (r >= ssize_t(iov->iov_len)) {
+        r -= ssize_t(iov->iov_len);
         ++iov;
         --count;
       } else {
         ++iov;
         --count;
       } else {
index d44e79959d27549400fdc486e6eb3f4d478d02f9..4a94c7d43416ef547e199de055e4efc428b2eaa4 100644 (file)
@@ -30,7 +30,7 @@ struct GroupVarintTraits;
 
 template <>
 struct GroupVarintTraits<uint32_t> {
 
 template <>
 struct GroupVarintTraits<uint32_t> {
-  enum {
+  enum : uint32_t {
     kGroupSize = 4,
     kHeaderSize = 1,
   };
     kGroupSize = 4,
     kHeaderSize = 1,
   };
@@ -38,7 +38,7 @@ struct GroupVarintTraits<uint32_t> {
 
 template <>
 struct GroupVarintTraits<uint64_t> {
 
 template <>
 struct GroupVarintTraits<uint64_t> {
-  enum {
+  enum : uint32_t {
     kGroupSize = 5,
     kHeaderSize = 2,
   };
     kGroupSize = 5,
     kHeaderSize = 2,
   };
@@ -48,7 +48,7 @@ template <typename T>
 class GroupVarintBase {
  protected:
   typedef GroupVarintTraits<T> Traits;
 class GroupVarintBase {
  protected:
   typedef GroupVarintTraits<T> Traits;
-  enum { kHeaderSize = Traits::kHeaderSize };
+  enum : uint32_t { kHeaderSize = Traits::kHeaderSize };
 
  public:
   typedef T type;
 
  public:
   typedef T type;
@@ -56,12 +56,12 @@ class GroupVarintBase {
   /**
    * Number of integers encoded / decoded in one pass.
    */
   /**
    * Number of integers encoded / decoded in one pass.
    */
-  enum { kGroupSize = Traits::kGroupSize };
+  enum : uint32_t { kGroupSize = Traits::kGroupSize };
 
   /**
    * Maximum encoded size.
    */
 
   /**
    * Maximum encoded size.
    */
-  enum { kMaxSize = kHeaderSize + sizeof(type) * kGroupSize };
+  enum : uint32_t { kMaxSize = kHeaderSize + sizeof(type) * kGroupSize };
 
   /**
    * Maximum size for n values.
 
   /**
    * Maximum size for n values.
index bcab002ab0c9cac06667c312fb3b83f516c95c49..95c66dc6be3678722c5aff189dd8680515a3f242 100644 (file)
@@ -41,10 +41,10 @@ size_t qfind_first_byte_of_byteset(const StringPieceLite haystack,
                                    const StringPieceLite needles) {
   SparseByteSet s;
   for (auto needle: needles) {
                                    const StringPieceLite needles) {
   SparseByteSet s;
   for (auto needle: needles) {
-    s.add(needle);
+    s.add(uint8_t(needle));
   }
   for (size_t index = 0; index < haystack.size(); ++index) {
   }
   for (size_t index = 0; index < haystack.size(); ++index) {
-    if (s.contains(haystack[index])) {
+    if (s.contains(uint8_t(haystack[index]))) {
       return index;
     }
   }
       return index;
     }
   }
index f7c8a4a50d050eff90b2b9043e32880355a35457..8eba63e9d5ce4028904f562f93df9ed39a28b1ee 100644 (file)
@@ -41,7 +41,7 @@ class StringPieceLite {
   const char* data() const { return b_; }
   const char* begin() const { return b_; }
   const char* end() const { return e_; }
   const char* data() const { return b_; }
   const char* begin() const { return b_; }
   const char* end() const { return e_; }
-  size_t size() const { return e_ - b_; }
+  size_t size() const { return size_t(e_ - b_); }
   bool empty() const { return size() == 0; }
   const char& operator[](size_t i) const { DCHECK_GT(size(), i); return b_[i]; }
   template <typename Range>
   bool empty() const { return size() == 0; }
   const char& operator[](size_t i) const { DCHECK_GT(size(), i); return b_[i]; }
   template <typename Range>
index 536c2a493ae17eabde1c617f80e7c389ca054434..9845eab6d75ad1961fc3a7a13566e5b40f310b0c 100644 (file)
@@ -245,7 +245,9 @@ struct TurnSequencer {
 
   /// Returns the bitmask to pass futexWait or futexWake when communicating
   /// about the specified turn
 
   /// Returns the bitmask to pass futexWait or futexWake when communicating
   /// about the specified turn
-  int futexChannel(uint32_t turn) const noexcept { return 1 << (turn & 31); }
+  uint32_t futexChannel(uint32_t turn) const noexcept {
+    return 1u << (turn & 31);
+  }
 
   uint32_t decodeCurrentSturn(uint32_t state) const noexcept {
     return state & ~kWaitersMask;
 
   uint32_t decodeCurrentSturn(uint32_t state) const noexcept {
     return state & ~kWaitersMask;
index c1be95b94dc71111103a0f9f7e4c7dd22e236fb3..09c1b6a74f5aedc5a9f858bfa186bd05d4c4c54a 100644 (file)
@@ -288,7 +288,7 @@ struct dynamic::NumericTypeHelper<double> {
 template<class T, class NumericType /* = typename NumericTypeHelper<T>::type */>
 dynamic::dynamic(T t) {
   type_ = TypeInfo<NumericType>::type;
 template<class T, class NumericType /* = typename NumericTypeHelper<T>::type */>
 dynamic::dynamic(T t) {
   type_ = TypeInfo<NumericType>::type;
-  new (getAddress<NumericType>()) NumericType(t);
+  new (getAddress<NumericType>()) NumericType(NumericType(t));
 }
 
 template <class Iterator>
 }
 
 template <class Iterator>
@@ -507,7 +507,7 @@ inline bool dynamic::empty() const {
 }
 
 inline std::size_t dynamic::count(dynamic const& key) const {
 }
 
 inline std::size_t dynamic::count(dynamic const& key) const {
-  return find(key) != items().end();
+  return find(key) != items().end() ? 1u : 0u;
 }
 
 inline dynamic::const_item_iterator dynamic::find(dynamic const& key) const {
 }
 
 inline dynamic::const_item_iterator dynamic::find(dynamic const& key) const {
index e9ce723f8259f2b1e6465117fc055dcb72df9a1c..cc768d55019496cd1b8ac669379f8a370a935000 100644 (file)
@@ -69,7 +69,7 @@ struct Nehalem : public Default {
     asm ("popcntq %1, %0" : "=r" (result) : "r" (value));
     return result;
 #else
     asm ("popcntq %1, %0" : "=r" (result) : "r" (value));
     return result;
 #else
-    return _mm_popcnt_u64(value);
+    return uint64_t(_mm_popcnt_u64(value));
 #endif
   }
 };
 #endif
   }
 };
index d73d76b3c6ec5292aa6356d3502a6eadec7826fe..81c708dce3b65195283e09eb9ad476c5b1bcf1ac 100644 (file)
@@ -219,7 +219,7 @@ struct SizeValidator final : IValidator {
     if (value.type() != type_) {
       return none;
     }
     if (value.type() != type_) {
       return none;
     }
-    if (!Comparison()(length_, value.size())) {
+    if (!Comparison()(size_t(length_), value.size())) {
       return makeError("different length string/array/object", value);
     }
     return none;
       return makeError("different length string/array/object", value);
     }
     return none;
index caaaa7f980a39ed359616a5cf0cf33e3ca9b031f..01eaf4dee10158c955bc872e6981d949abb622e9 100644 (file)
@@ -57,7 +57,8 @@ void Baton::waitThread() {
           fiber == NO_WAITER &&
           waitingFiber_.compare_exchange_strong(fiber, THREAD_WAITING))) {
     do {
           fiber == NO_WAITER &&
           waitingFiber_.compare_exchange_strong(fiber, THREAD_WAITING))) {
     do {
-      folly::detail::MemoryIdler::futexWait(futex_.futex, THREAD_WAITING);
+      folly::detail::MemoryIdler::futexWait(
+          futex_.futex, uint32_t(THREAD_WAITING));
       fiber = waitingFiber_.load(std::memory_order_acquire);
     } while (fiber == THREAD_WAITING);
   }
       fiber = waitingFiber_.load(std::memory_order_acquire);
     } while (fiber == THREAD_WAITING);
   }
@@ -109,7 +110,7 @@ bool Baton::timedWaitThread(TimeoutController::Duration timeout) {
     auto deadline = TimeoutController::Clock::now() + timeout;
     do {
       const auto wait_rv =
     auto deadline = TimeoutController::Clock::now() + timeout;
     do {
       const auto wait_rv =
-          futex_.futex.futexWaitUntil(THREAD_WAITING, deadline);
+          futex_.futex.futexWaitUntil(uint32_t(THREAD_WAITING), deadline);
       if (wait_rv == folly::detail::FutexResult::TIMEDOUT) {
         return false;
       }
       if (wait_rv == folly::detail::FutexResult::TIMEDOUT) {
         return false;
       }
index 047abee8d888c076ecb261c43d43d427b0dab6e8..51cca2ca0369e7d1d34df7f1996871928ee8a902 100644 (file)
@@ -28,7 +28,7 @@ namespace fibers {
 class Semaphore {
  public:
   explicit Semaphore(size_t tokenCount)
 class Semaphore {
  public:
   explicit Semaphore(size_t tokenCount)
-      : capacity_(tokenCount), tokens_(capacity_) {}
+      : capacity_(tokenCount), tokens_(int64_t(capacity_)) {}
 
   Semaphore(const Semaphore&) = delete;
   Semaphore(Semaphore&&) = delete;
 
   Semaphore(const Semaphore&) = delete;
   Semaphore(Semaphore&&) = delete;
index 98981ef9f143a9a709dd8e79c068a980b5ee5847..3d94f8a7103fa9780eb520a36187488914be8731 100644 (file)
@@ -47,7 +47,7 @@ class FileReader : public GenImpl<ByteRange, FileReader> {
       if (n == 0) {
         return true;
       }
       if (n == 0) {
         return true;
       }
-      if (!body(ByteRange(buffer_->tail(), n))) {
+      if (!body(ByteRange(buffer_->tail(), size_t(n)))) {
         return false;
       }
     }
         return false;
       }
     }
@@ -105,7 +105,7 @@ class FileWriter : public Operator<FileWriter> {
         throw std::system_error(errno, std::system_category(),
                                 "write() failed");
       }
         throw std::system_error(errno, std::system_category(),
                                 "write() failed");
       }
-      v.advance(n);
+      v.advance(size_t(n));
     }
   }
 
     }
   }
 
index 66c7cb168688d45b923f0e629742672b3620391a..6d9424cdf3e0cb0f6392b847aefc105244abd0ab 100644 (file)
@@ -507,7 +507,7 @@ class IOBuf {
    * Returns the number of bytes in the buffer before the start of the data.
    */
   uint64_t headroom() const {
    * Returns the number of bytes in the buffer before the start of the data.
    */
   uint64_t headroom() const {
-    return data_ - buffer();
+    return uint64_t(data_ - buffer());
   }
 
   /**
   }
 
   /**
@@ -516,7 +516,7 @@ class IOBuf {
    * Returns the number of bytes in the buffer after the end of the data.
    */
   uint64_t tailroom() const {
    * Returns the number of bytes in the buffer after the end of the data.
    */
   uint64_t tailroom() const {
-    return bufferEnd() - tail();
+    return uint64_t(bufferEnd() - tail());
   }
 
   /**
   }
 
   /**
index 37efc51a8a979989bb1083165735c21edb206fc0..8cb081c825cdac384af2e3e2d0e7606e3deacc8c 100644 (file)
@@ -95,7 +95,7 @@ void RecordIOReader::Iterator::advanceToValid() {
     recordAndPos_ = std::make_pair(ByteRange(), off_t(-1));
     range_.clear();  // at end
   } else {
     recordAndPos_ = std::make_pair(ByteRange(), off_t(-1));
     range_.clear();  // at end
   } else {
-    size_t skipped = record.begin() - range_.begin();
+    size_t skipped = size_t(record.begin() - range_.begin());
     DCHECK_GE(skipped, headerSize());
     skipped -= headerSize();
     range_.advance(skipped);
     DCHECK_GE(skipped, headerSize());
     skipped -= headerSize();
     range_.advance(skipped);
index 6e807229e2be2afed7e43586e46e421902f63c33..882d3bf0953e134675d1a3c295520045fb9dc18d 100644 (file)
@@ -735,7 +735,7 @@ void escapeString(
       out.push_back(hexDigit(v & 0x0f));
     } else if (*p == '\\' || *p == '\"') {
       out.push_back('\\');
       out.push_back(hexDigit(v & 0x0f));
     } else if (*p == '\\' || *p == '\"') {
       out.push_back('\\');
-      out.push_back(*p++);
+      out.push_back(char(*p++));
     } else if (*p <= 0x1f) {
       switch (*p) {
         case '\b': out.append("\\b"); p++; break;
     } else if (*p <= 0x1f) {
       switch (*p) {
         case '\b': out.append("\\b"); p++; break;