Added (sock_t) to quiet compiler warnings in MinGW

pull/1/head
Ross Smith II 2009-06-02 03:18:07 +00:00
parent 3455fca9ca
commit 2e34ea1e42
2 changed files with 14 additions and 14 deletions

View File

@ -178,7 +178,7 @@ void SocketCore::bind(uint16_t port)
struct addrinfo* rp;
for(rp = res; rp; rp = rp->ai_next) {
sock_t fd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
if(fd == -1) {
if(fd == (sock_t) -1) {
continue;
}
int sockopt = 1;
@ -194,7 +194,7 @@ void SocketCore::bind(uint16_t port)
break;
}
freeaddrinfo(res);
if(sockfd == -1) {
if(sockfd == (sock_t) -1) {
throw DL_ABORT_EX(StringFormat(EX_SOCKET_BIND, "all addresses failed").str());
}
}
@ -211,8 +211,8 @@ SocketCore* SocketCore::acceptConnection() const
struct sockaddr_storage sockaddr;
socklen_t len = sizeof(sockaddr);
sock_t fd;
while((fd = accept(sockfd, reinterpret_cast<struct sockaddr*>(&sockaddr), &len)) == -1 && SOCKET_ERRNO == EINTR);
if(fd == -1) {
while((fd = accept(sockfd, reinterpret_cast<struct sockaddr*>(&sockaddr), &len)) == (sock_t) -1 && SOCKET_ERRNO == EINTR);
if(fd == (sock_t) -1) {
throw DL_ABORT_EX(StringFormat(EX_SOCKET_ACCEPT, errorMsg()).str());
}
return new SocketCore(fd, _sockType);
@ -260,7 +260,7 @@ void SocketCore::establishConnection(const std::string& host, uint16_t port)
struct addrinfo* rp;
for(rp = res; rp; rp = rp->ai_next) {
sock_t fd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
if(fd == -1) {
if(fd == (sock_t) -1) {
continue;
}
int sockopt = 1;
@ -274,7 +274,7 @@ void SocketCore::establishConnection(const std::string& host, uint16_t port)
if(connect(fd, rp->ai_addr, rp->ai_addrlen) == -1 &&
SOCKET_ERRNO != A2_EINPROGRESS) {
CLOSE(sockfd);
sockfd = -1;
sockfd = (sock_t) -1;
continue;
}
// TODO at this point, connection may not be established and it may fail
@ -282,7 +282,7 @@ void SocketCore::establishConnection(const std::string& host, uint16_t port)
break;
}
freeaddrinfo(res);
if(sockfd == -1) {
if(sockfd == (sock_t) -1) {
throw DL_ABORT_EX(StringFormat(EX_SOCKET_CONNECT, host.c_str(),
"all addresses failed").str());
}
@ -333,7 +333,7 @@ void SocketCore::closeConnection()
gnutls_bye(sslSession, GNUTLS_SHUT_RDWR);
}
#endif // HAVE_LIBGNUTLS
if(sockfd != -1) {
if(sockfd != (sock_t) -1) {
CLOSE(sockfd);
sockfd = -1;
}

View File

@ -141,7 +141,7 @@ public:
sock_t getSockfd() const { return sockfd; }
bool isOpen() const { return sockfd != -1; }
bool isOpen() const { return sockfd != (sock_t) -1; }
/**
* Creates a socket and bind it with locahost's address and port.
@ -161,7 +161,7 @@ public:
* @param addrinfo placeholder to store host address and port.
*/
void getAddrInfo(std::pair<std::string, uint16_t>& addrinfo) const;
/**
* Stores peer's address and port to peerinfo.
* @param peerinfo placeholder to store peer's address and port.
@ -280,7 +280,7 @@ public:
{
return readDataFrom(reinterpret_cast<char*>(data), len, sender);
}
/**
* Reads up to len bytes from this socket, but bytes are not removed from
* this socket.
@ -291,7 +291,7 @@ public:
* the number of bytes read to len.
*/
void peekData(char* data, size_t& len);
void peekData(unsigned char* data, size_t& len)
{
peekData(reinterpret_cast<char*>(data), len);
@ -311,11 +311,11 @@ public:
bool operator==(const SocketCore& s) {
return sockfd == s.sockfd;
}
bool operator!=(const SocketCore& s) {
return !(*this == s);
}
bool operator<(const SocketCore& s) {
return sockfd < s.sockfd;
}