From cbf87cb89cf0b1e7cd3656262c642209fef235ef Mon Sep 17 00:00:00 2001 From: Christian Lavoie Date: Sun, 28 Nov 2010 14:34:26 +0000 Subject: [PATCH] THRIFT-916: Commit THRIFT-916_fix_no-overflow.patch -- remove overflow coming from a few constants. git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1039885 13f79535-47bb-0310-9956-ffa450edef68 --- lib/cpp/src/protocol/TCompactProtocol.h | 4 ++-- lib/cpp/test/Benchmark.cpp | 2 +- lib/cpp/test/DebugProtoTest.cpp | 2 +- lib/cpp/test/JSONProtoTest.cpp | 4 ++-- lib/cpp/test/SpecializationTest.cpp | 4 ++-- test/DebugProtoTest.thrift | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/cpp/src/protocol/TCompactProtocol.h b/lib/cpp/src/protocol/TCompactProtocol.h index 19a0160a..c4d1f08a 100644 --- a/lib/cpp/src/protocol/TCompactProtocol.h +++ b/lib/cpp/src/protocol/TCompactProtocol.h @@ -35,10 +35,10 @@ class TCompactProtocolT : public TVirtualProtocol< TCompactProtocolT > { protected: - static const int8_t PROTOCOL_ID = 0x82; + static const int8_t PROTOCOL_ID = (int8_t)0x82; static const int8_t VERSION_N = 1; static const int8_t VERSION_MASK = 0x1f; // 0001 1111 - static const int8_t TYPE_MASK = 0xE0; // 1110 0000 + static const int8_t TYPE_MASK = (int8_t)0xE0; // 1110 0000 static const int32_t TYPE_SHIFT_AMOUNT = 5; Transport_* trans_; diff --git a/lib/cpp/test/Benchmark.cpp b/lib/cpp/test/Benchmark.cpp index a9859d87..f4cd3925 100644 --- a/lib/cpp/test/Benchmark.cpp +++ b/lib/cpp/test/Benchmark.cpp @@ -56,7 +56,7 @@ int main() { OneOfEach ooe; ooe.im_true = true; ooe.im_false = false; - ooe.a_bite = 0xd6; + ooe.a_bite = 0x7f; ooe.integer16 = 27000; ooe.integer32 = 1<<24; ooe.integer64 = (uint64_t)6000 * 1000 * 1000; diff --git a/lib/cpp/test/DebugProtoTest.cpp b/lib/cpp/test/DebugProtoTest.cpp index ed23d1ac..4f456f31 100644 --- a/lib/cpp/test/DebugProtoTest.cpp +++ b/lib/cpp/test/DebugProtoTest.cpp @@ -31,7 +31,7 @@ int main() { OneOfEach ooe; ooe.im_true = true; ooe.im_false = false; - ooe.a_bite = 0xd6; + ooe.a_bite = 0x7f; ooe.integer16 = 27000; ooe.integer32 = 1<<24; ooe.integer64 = (uint64_t)6000 * 1000 * 1000; diff --git a/lib/cpp/test/JSONProtoTest.cpp b/lib/cpp/test/JSONProtoTest.cpp index 24796388..a9268a2b 100644 --- a/lib/cpp/test/JSONProtoTest.cpp +++ b/lib/cpp/test/JSONProtoTest.cpp @@ -33,7 +33,7 @@ int main() { OneOfEach ooe; ooe.im_true = true; ooe.im_false = false; - ooe.a_bite = 0xd6; + ooe.a_bite = 0x7f; ooe.integer16 = 27000; ooe.integer32 = 1<<24; ooe.integer64 = (uint64_t)6000 * 1000 * 1000; @@ -123,7 +123,7 @@ int main() { assert(hm == hm2); - hm2.big[0].a_bite = 0xFF; + hm2.big[0].a_bite = 0x00; assert(hm != hm2); diff --git a/lib/cpp/test/SpecializationTest.cpp b/lib/cpp/test/SpecializationTest.cpp index 954585a5..fae1d324 100644 --- a/lib/cpp/test/SpecializationTest.cpp +++ b/lib/cpp/test/SpecializationTest.cpp @@ -18,7 +18,7 @@ int main() { OneOfEach ooe; ooe.im_true = true; ooe.im_false = false; - ooe.a_bite = 0xd6; + ooe.a_bite = 0x7f; ooe.integer16 = 27000; ooe.integer32 = 1<<24; ooe.integer64 = (uint64_t)6000 * 1000 * 1000; @@ -100,7 +100,7 @@ int main() { assert(hm == hm2); - hm2.big[0].a_bite = 0xFF; + hm2.big[0].a_bite = 0x00; assert(hm != hm2); diff --git a/test/DebugProtoTest.thrift b/test/DebugProtoTest.thrift index 79800475..23d5d973 100644 --- a/test/DebugProtoTest.thrift +++ b/test/DebugProtoTest.thrift @@ -35,8 +35,8 @@ struct Doubles { struct OneOfEach { 1: bool im_true, 2: bool im_false, - 3: byte a_bite = 200, - 4: i16 integer16 = 33000, + 3: byte a_bite = 0x7f, + 4: i16 integer16 = 0x7fff, 5: i32 integer32, 6: i64 integer64 = 10000000000, 7: double double_precision, -- 2.17.1