THRIFT-1987 TCompactProtocol.tcc/h warnings on Visual
Patch: Konrad Grochowski
diff --git a/lib/cpp/src/thrift/protocol/TCompactProtocol.h b/lib/cpp/src/thrift/protocol/TCompactProtocol.h
index c4d1f08..7311f85 100644
--- a/lib/cpp/src/thrift/protocol/TCompactProtocol.h
+++ b/lib/cpp/src/thrift/protocol/TCompactProtocol.h
@@ -161,12 +161,12 @@
                                   const TType fieldType,
                                   const int16_t fieldId,
                                   int8_t typeOverride);
-  uint32_t writeCollectionBegin(int8_t elemType, int32_t size);
+  uint32_t writeCollectionBegin(const TType elemType, int32_t size);
   uint32_t writeVarint32(uint32_t n);
   uint32_t writeVarint64(uint64_t n);
   uint64_t i64ToZigzag(const int64_t l);
   uint32_t i32ToZigzag(const int32_t n);
-  inline int8_t getCompactType(int8_t ttype);
+  inline int8_t getCompactType(const TType ttype);
 
  public:
   uint32_t readMessageBegin(std::string& name,
diff --git a/lib/cpp/src/thrift/protocol/TCompactProtocol.tcc b/lib/cpp/src/thrift/protocol/TCompactProtocol.tcc
index 1d93cba..62d6485 100644
--- a/lib/cpp/src/thrift/protocol/TCompactProtocol.tcc
+++ b/lib/cpp/src/thrift/protocol/TCompactProtocol.tcc
@@ -198,16 +198,20 @@
 
   if (booleanField_.name != NULL) {
     // we haven't written the field header yet
-    wsize += writeFieldBeginInternal(booleanField_.name,
-                                     booleanField_.fieldType,
-                                     booleanField_.fieldId,
-                                     value ? detail::compact::CT_BOOLEAN_TRUE :
-                                     detail::compact::CT_BOOLEAN_FALSE);
+    wsize
+      += writeFieldBeginInternal(booleanField_.name,
+                                 booleanField_.fieldType,
+                                 booleanField_.fieldId,
+                                 static_cast<int8_t>(value
+                                                     ? detail::compact::CT_BOOLEAN_TRUE
+                                                     : detail::compact::CT_BOOLEAN_FALSE));
     booleanField_.name = NULL;
   } else {
     // we're not part of a field, so just write the value
-    wsize += writeByte(value ? detail::compact::CT_BOOLEAN_TRUE :
-                       detail::compact::CT_BOOLEAN_FALSE);
+    wsize
+      += writeByte(static_cast<int8_t>(value
+                                       ? detail::compact::CT_BOOLEAN_TRUE
+                                       : detail::compact::CT_BOOLEAN_FALSE));
   }
   return wsize;
 }
@@ -296,7 +300,8 @@
   // check if we can use delta encoding for the field id
   if (fieldId > lastFieldId_ && fieldId - lastFieldId_ <= 15) {
     // write them together
-    wsize += writeByte((fieldId - lastFieldId_) << 4 | typeToWrite);
+    wsize += writeByte(static_cast<int8_t>((fieldId - lastFieldId_)
+                                           << 4 | typeToWrite));
   } else {
     // write them separate
     wsize += writeByte(typeToWrite);
@@ -312,11 +317,12 @@
  * the wire differ only by the type indicator.
  */
 template <class Transport_>
-uint32_t TCompactProtocolT<Transport_>::writeCollectionBegin(int8_t elemType,
+uint32_t TCompactProtocolT<Transport_>::writeCollectionBegin(const TType elemType,
                                                              int32_t size) {
   uint32_t wsize = 0;
   if (size <= 14) {
-    wsize += writeByte(size << 4 | getCompactType(elemType));
+    wsize += writeByte(static_cast<int8_t>(size
+                                           << 4 | getCompactType(elemType)));
   } else {
     wsize += writeByte(0xf0 | getCompactType(elemType));
     wsize += writeVarint32(size);
@@ -388,7 +394,7 @@
  * Given a TType value, find the appropriate detail::compact::Types value
  */
 template <class Transport_>
-int8_t TCompactProtocolT<Transport_>::getCompactType(int8_t ttype) {
+int8_t TCompactProtocolT<Transport_>::getCompactType(const TType ttype) {
   return detail::compact::TTypeToCType[ttype];
 }
 
@@ -762,7 +768,7 @@
  */
 template <class Transport_>
 int32_t TCompactProtocolT<Transport_>::zigzagToI32(uint32_t n) {
-  return (n >> 1) ^ -(n & 1);
+  return (n >> 1) ^ -static_cast<int32_t>(n & 1);
 }
 
 /**
@@ -770,7 +776,7 @@
  */
 template <class Transport_>
 int64_t TCompactProtocolT<Transport_>::zigzagToI64(uint64_t n) {
-  return (n >> 1) ^ -(n & 1);
+  return (n >> 1) ^ -static_cast<int32_t>(n & 1);
 }
 
 template <class Transport_>