Updated Branches: refs/heads/master 1ed799156 -> 64a799d28
THRIFT-1987 TCompactProtocol.tcc/h warnings on Visual Patch: Konrad Grochowski Project: http://git-wip-us.apache.org/repos/asf/thrift/repo Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/64a799d2 Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/64a799d2 Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/64a799d2 Branch: refs/heads/master Commit: 64a799d28e60073e29ecebeed06d86e91e65b6cf Parents: 1ed7991 Author: Roger Meier <[email protected]> Authored: Tue Jun 4 20:59:01 2013 +0200 Committer: Roger Meier <[email protected]> Committed: Tue Jun 4 20:59:01 2013 +0200 ---------------------------------------------------------------------- lib/cpp/src/thrift/protocol/TCompactProtocol.h | 4 +- lib/cpp/src/thrift/protocol/TCompactProtocol.tcc | 32 ++++++++++------- 2 files changed, 21 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/thrift/blob/64a799d2/lib/cpp/src/thrift/protocol/TCompactProtocol.h ---------------------------------------------------------------------- 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 @@ class TCompactProtocolT 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, http://git-wip-us.apache.org/repos/asf/thrift/blob/64a799d2/lib/cpp/src/thrift/protocol/TCompactProtocol.tcc ---------------------------------------------------------------------- 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 @@ uint32_t TCompactProtocolT<Transport_>::writeBool(const bool value) { 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 @@ int32_t TCompactProtocolT<Transport_>::writeFieldBeginInternal( // 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 @@ int32_t TCompactProtocolT<Transport_>::writeFieldBeginInternal( * 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 @@ uint32_t TCompactProtocolT<Transport_>::i32ToZigzag(const int32_t n) { * 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 @@ uint32_t TCompactProtocolT<Transport_>::readVarint64(int64_t& i64) { */ 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 @@ int32_t TCompactProtocolT<Transport_>::zigzagToI32(uint32_t n) { */ 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_>
