You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by ro...@apache.org on 2014/07/08 07:30:16 UTC

git commit: THRIFT-2605 TSocket warning on gcc 4.8.3

Repository: thrift
Updated Branches:
  refs/heads/master f83c0e13b -> 3e50a9a1d


THRIFT-2605 TSocket warning on gcc 4.8.3

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/3e50a9a1
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/3e50a9a1
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/3e50a9a1

Branch: refs/heads/master
Commit: 3e50a9a1d01950f356242aaab0cbf5fae778b81c
Parents: f83c0e1
Author: Roger Meier <ro...@apache.org>
Authored: Tue Jul 8 07:29:12 2014 +0200
Committer: Roger Meier <ro...@apache.org>
Committed: Tue Jul 8 07:29:12 2014 +0200

----------------------------------------------------------------------
 lib/cpp/src/thrift/transport/TServerSocket.cpp |  7 +++----
 lib/cpp/src/thrift/transport/TSocket.cpp       | 21 ++++++++++-----------
 2 files changed, 13 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/3e50a9a1/lib/cpp/src/thrift/transport/TServerSocket.cpp
----------------------------------------------------------------------
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 @@ void TServerSocket::listen() {
 #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));

http://git-wip-us.apache.org/repos/asf/thrift/blob/3e50a9a1/lib/cpp/src/thrift/transport/TSocket.cpp
----------------------------------------------------------------------
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 @@ void TSocket::openConnection(struct addrinfo *res) {
 
 #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 @@ void TSocket::local_open(){
 
   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());