THRIFT-2027: Minor 64-bit and NOMINMAX issues in C++ library
Client: cpp
Patch: Ben Craig
diff --git a/lib/cpp/src/thrift/server/TNonblockingServer.cpp b/lib/cpp/src/thrift/server/TNonblockingServer.cpp
index b9553c4..1552e89 100644
--- a/lib/cpp/src/thrift/server/TNonblockingServer.cpp
+++ b/lib/cpp/src/thrift/server/TNonblockingServer.cpp
@@ -893,7 +893,7 @@
// pick an IO thread to handle this connection -- currently round robin
assert(nextIOThread_ < ioThreads_.size());
int selectedThreadIdx = nextIOThread_;
- nextIOThread_ = (nextIOThread_ + 1) % ioThreads_.size();
+ nextIOThread_ = static_cast<uint32_t>((nextIOThread_ + 1) % ioThreads_.size());
TNonblockingIOThread* ioThread = ioThreads_[selectedThreadIdx].get();
@@ -1421,7 +1421,7 @@
while (true) {
TNonblockingServer::TConnection* connection = 0;
const int kSize = sizeof(connection);
- int nBytes = recv(fd, cast_sockopt(&connection), kSize, 0);
+ long nBytes = recv(fd, cast_sockopt(&connection), kSize, 0);
if (nBytes == kSize) {
if (connection == NULL) {
// this is the command to stop our thread, exit the handler!
diff --git a/lib/cpp/src/thrift/transport/THttpServer.cpp b/lib/cpp/src/thrift/transport/THttpServer.cpp
index 1135270..e5b3327 100644
--- a/lib/cpp/src/thrift/transport/THttpServer.cpp
+++ b/lib/cpp/src/thrift/transport/THttpServer.cpp
@@ -92,7 +92,7 @@
string header = h.str();
// Write the header, then the data, then flush
- transport_->write((const uint8_t*)header.c_str(), header.size());
+ transport_->write((const uint8_t*)header.c_str(), static_cast<uint32_t>(header.size()));
transport_->write(buf, len);
transport_->flush();
diff --git a/lib/cpp/src/thrift/transport/TZlibTransport.cpp b/lib/cpp/src/thrift/transport/TZlibTransport.cpp
index d77eedd..cdde7c3 100644
--- a/lib/cpp/src/thrift/transport/TZlibTransport.cpp
+++ b/lib/cpp/src/thrift/transport/TZlibTransport.cpp
@@ -143,7 +143,7 @@
while (true) {
// Copy out whatever we have available, then give them the min of
// what we have and what they want, then advance indices.
- int give = std::min((uint32_t) readAvail(), need);
+ int give = (std::min)((uint32_t) readAvail(), need);
memcpy(buf, urbuf_ + urpos_, give);
need -= give;
buf += give;