THRIFT-2605 TSocket warning on gcc 4.8.3
Patch: Konrad Grochowski
diff --git a/lib/cpp/src/thrift/transport/TServerSocket.cpp b/lib/cpp/src/thrift/transport/TServerSocket.cpp
index b686c6c..e7d3ec6 100755
--- a/lib/cpp/src/thrift/transport/TServerSocket.cpp
+++ b/lib/cpp/src/thrift/transport/TServerSocket.cpp
@@ -310,15 +310,14 @@
#ifndef _WIN32
// Unix Domain Socket
- struct sockaddr_un address = {0};
- size_t len = path_.size()+1;
-
- if (len > sizeof(address.sun_path)) {
+ size_t len = path_.size() + 1;
+ if (len > sizeof(sockaddr_un::sun_path)) {
int errno_copy = THRIFT_GET_SOCKET_ERROR;
GlobalOutput.perror("TSocket::listen() Unix Domain socket path too long", errno_copy);
throw TTransportException(TTransportException::NOT_OPEN, " Unix Domain socket path too long");
}
+ struct sockaddr_un address;
address.sun_family = AF_UNIX;
memcpy(address.sun_path, path_.c_str(), len);
socklen_t structlen = static_cast<socklen_t>(sizeof(address));
diff --git a/lib/cpp/src/thrift/transport/TSocket.cpp b/lib/cpp/src/thrift/transport/TSocket.cpp
index 8595506..7dec442 100755
--- a/lib/cpp/src/thrift/transport/TSocket.cpp
+++ b/lib/cpp/src/thrift/transport/TSocket.cpp
@@ -253,15 +253,14 @@
#ifndef _WIN32
- struct sockaddr_un address = {0};
- size_t len = path_.size()+1;
-
- if (len > sizeof(address.sun_path)) {
+ size_t len = path_.size() + 1;
+ if (len > sizeof(sockaddr_un::sun_path)) {
int errno_copy = THRIFT_GET_SOCKET_ERROR;
GlobalOutput.perror("TSocket::open() Unix Domain socket path too long", errno_copy);
throw TTransportException(TTransportException::NOT_OPEN, " Unix Domain socket path too long");
}
+ struct sockaddr_un address;
address.sun_family = AF_UNIX;
memcpy(address.sun_path, path_.c_str(), len);
socklen_t structlen = static_cast<socklen_t>(sizeof(address));
@@ -378,13 +377,13 @@
error = getaddrinfo(host_.c_str(), port, &hints, &res0);
-#ifdef _WIN32
- if (error == WSANO_DATA) {
- hints.ai_flags &= ~AI_ADDRCONFIG;
- error = getaddrinfo(host_.c_str(), port, &hints, &res0);
- }
-#endif
-
+#ifdef _WIN32
+ if (error == WSANO_DATA) {
+ hints.ai_flags &= ~AI_ADDRCONFIG;
+ error = getaddrinfo(host_.c_str(), port, &hints, &res0);
+ }
+#endif
+
if (error) {
string errStr = "TSocket::open() getaddrinfo() " + getSocketInfo() + string(THRIFT_GAI_STRERROR(error));
GlobalOutput(errStr.c_str());