(svn r16034) -Fix: compile warnings generated by 64 bits MSVC.

This commit is contained in:
rubidium 2009-04-11 20:26:25 +00:00
parent 4f5bd05db6
commit b78820a361
2 changed files with 10 additions and 10 deletions

View File

@ -206,20 +206,20 @@ SOCKET NetworkAddress::Resolve(int family, int socktype, int flags, SocketList *
* connect to one with exactly the same address twice. That's * connect to one with exactly the same address twice. That's
* ofcourse totally unneeded ;) */ * ofcourse totally unneeded ;) */
if (sockets != NULL) { if (sockets != NULL) {
NetworkAddress address(runp->ai_addr, runp->ai_addrlen); NetworkAddress address(runp->ai_addr, (int)runp->ai_addrlen);
if (sockets->Find(address) != sockets->End()) continue; if (sockets->Find(address) != sockets->End()) continue;
} }
sock = func(runp); sock = func(runp);
if (sock == INVALID_SOCKET) continue; if (sock == INVALID_SOCKET) continue;
if (sockets == NULL) { if (sockets == NULL) {
this->address_length = runp->ai_addrlen; this->address_length = (int)runp->ai_addrlen;
assert(sizeof(this->address) >= runp->ai_addrlen); assert(sizeof(this->address) >= runp->ai_addrlen);
memcpy(&this->address, runp->ai_addr, runp->ai_addrlen); memcpy(&this->address, runp->ai_addr, runp->ai_addrlen);
break; break;
} }
NetworkAddress addr(runp->ai_addr, runp->ai_addrlen); NetworkAddress addr(runp->ai_addr, (int)runp->ai_addrlen);
(*sockets)[addr] = sock; (*sockets)[addr] = sock;
sock = INVALID_SOCKET; sock = INVALID_SOCKET;
} }
@ -243,7 +243,7 @@ static SOCKET ConnectLoopProc(addrinfo *runp)
if (!SetNoDelay(sock)) DEBUG(net, 1, "Setting TCP_NODELAY failed"); if (!SetNoDelay(sock)) DEBUG(net, 1, "Setting TCP_NODELAY failed");
if (connect(sock, runp->ai_addr, runp->ai_addrlen) != 0) { if (connect(sock, runp->ai_addr, (int)runp->ai_addrlen) != 0) {
DEBUG(net, 1, "Could not connect socket: %s", strerror(errno)); DEBUG(net, 1, "Could not connect socket: %s", strerror(errno));
closesocket(sock); closesocket(sock);
return INVALID_SOCKET; return INVALID_SOCKET;
@ -270,7 +270,7 @@ SOCKET NetworkAddress::Connect()
static SOCKET ListenLoopProc(addrinfo *runp) static SOCKET ListenLoopProc(addrinfo *runp)
{ {
const char *type = runp->ai_socktype == SOCK_STREAM ? "tcp" : "udp"; const char *type = runp->ai_socktype == SOCK_STREAM ? "tcp" : "udp";
const char *address = NetworkAddress(runp->ai_addr, runp->ai_addrlen).GetAddressAsString(); const char *address = NetworkAddress(runp->ai_addr, (int)runp->ai_addrlen).GetAddressAsString();
SOCKET sock = socket(runp->ai_family, runp->ai_socktype, runp->ai_protocol); SOCKET sock = socket(runp->ai_family, runp->ai_socktype, runp->ai_protocol);
if (sock == INVALID_SOCKET) { if (sock == INVALID_SOCKET) {
@ -293,7 +293,7 @@ static SOCKET ListenLoopProc(addrinfo *runp)
DEBUG(net, 3, "[%s] Could not disable IPv4 over IPv6 on port %s: %s", type, address, strerror(errno)); DEBUG(net, 3, "[%s] Could not disable IPv4 over IPv6 on port %s: %s", type, address, strerror(errno));
} }
if (bind(sock, runp->ai_addr, runp->ai_addrlen) != 0) { if (bind(sock, runp->ai_addr, (int)runp->ai_addrlen) != 0) {
DEBUG(net, 1, "[%s] Could not bind on port %s: %s", type, address, strerror(errno)); DEBUG(net, 1, "[%s] Could not bind on port %s: %s", type, address, strerror(errno));
closesocket(sock); closesocket(sock);
return INVALID_SOCKET; return INVALID_SOCKET;

View File

@ -24,7 +24,7 @@ typedef SmallMap<NetworkAddress, SOCKET, 4> SocketList;
class NetworkAddress { class NetworkAddress {
private: private:
char hostname[NETWORK_HOSTNAME_LENGTH]; ///< The hostname char hostname[NETWORK_HOSTNAME_LENGTH]; ///< The hostname
size_t address_length; ///< The length of the resolved address int address_length; ///< The length of the resolved address
sockaddr_storage address; ///< The resolved address sockaddr_storage address; ///< The resolved address
/** /**
@ -49,7 +49,7 @@ public:
* Create a network address based on a resolved IP and port * Create a network address based on a resolved IP and port
* @param address the IP address with port * @param address the IP address with port
*/ */
NetworkAddress(struct sockaddr_storage &address, size_t address_length) : NetworkAddress(struct sockaddr_storage &address, int address_length) :
address_length(address_length), address_length(address_length),
address(address) address(address)
{ {
@ -60,7 +60,7 @@ public:
* Create a network address based on a resolved IP and port * Create a network address based on a resolved IP and port
* @param address the IP address with port * @param address the IP address with port
*/ */
NetworkAddress(sockaddr *address, size_t address_length) : NetworkAddress(sockaddr *address, int address_length) :
address_length(address_length) address_length(address_length)
{ {
*this->hostname = '\0'; *this->hostname = '\0';
@ -131,7 +131,7 @@ public:
* Get the (valid) length of the address. * Get the (valid) length of the address.
* @return the length * @return the length
*/ */
size_t GetAddressLength() int GetAddressLength()
{ {
/* Resolve it if we didn't do it already */ /* Resolve it if we didn't do it already */
if (!this->IsResolved()) this->GetAddress(); if (!this->IsResolved()) this->GetAddress();