From a96826a2080d41d42f0c3c77c1989008f3c90fad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Jos=C3=A9=20Guti=C3=A9rrez=20de=20Quevedo=20P=C3=A9?= =?UTF-8?q?rez?= Date: Sun, 29 Jun 2014 21:24:59 +0200 Subject: [PATCH] FIX: add braces to remove warnings --- src/Socket.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/Socket.cpp b/src/Socket.cpp index 56ab3c4..549309e 100644 --- a/src/Socket.cpp +++ b/src/Socket.cpp @@ -228,21 +228,33 @@ ssize_t Socket::readBytes(void *buf,ssize_t lon) #ifdef HAVE_SSL if(ssl_enabled) + { retval=SSL_read(ssl,buf,lon); + } else #endif //HAVE_SSL + { retval=recv(fd,(char *)buf,lon,MSG_NOSIGNAL); + } if(!retval) + { throw NetworkException(_("Peer closed connection"),__FILE__,__LINE__); + } if(retval<0) + { #ifdef HAVE_SSL if(ssl_enabled) + { throw NetworkException(_("SSL error number: ")+Utils::inttostr(SSL_get_error(ssl,retval)),__FILE__,__LINE__); + } else #endif //HAVE_SSL + { throw NetworkException(_(Utils::errnotostrerror(errno)),__FILE__,__LINE__); + } + } readed+=lon; } @@ -308,12 +320,18 @@ void Socket::writeBytes(void *bytes,ssize_t len) throw NetworkException(_("Peer closed connection"),__FILE__,__LINE__); if(retval<0) + { #ifdef HAVE_SSL if(ssl_enabled) + { throw NetworkException(_("SSL error number: ")+Utils::inttostr(SSL_get_error(ssl,retval)),__FILE__,__LINE__); + } else #endif //HAVE_SSL + { throw NetworkException(_(Utils::errnotostrerror(errno)),__FILE__,__LINE__); + } + } written+=len; } } @@ -465,9 +483,13 @@ string Socket::resolveInverselyToString(string ip) error=getnameinfo(&addr,sizeof(struct sockaddr),hostname,NI_MAXHOST,NULL,0,NI_NAMEREQD); if(error) + { if(error==EAI_NONAME) //if the problem is that we didn't get a hostname, return empty string + { hostname[0]='\0'; + } else + { #ifdef HAVE_GAI_STRERROR throw Exception(gai_strerror(error)+Utils::inttostr(error),__FILE__,__LINE__); #else @@ -477,6 +499,8 @@ string Socket::resolveInverselyToString(string ip) throw Exception("Socket error number "+Utils::inttostr(error),__FILE__,__LINE__); #endif //WIN32 #endif //HAVE_GAI_STRERROR + } + } return string(hostname); }