Kill compiler warning

This commit is contained in:
Yang Tse 2012-06-14 21:19:48 +02:00
parent 1972aad19e
commit 38b69b7269
4 changed files with 30 additions and 9 deletions

View File

@ -355,8 +355,8 @@ int ares_save_options(ares_channel channel, struct ares_options *options,
options->timeout = channel->timeout;
options->tries = channel->tries;
options->ndots = channel->ndots;
options->udp_port = (unsigned short)ntohs(channel->udp_port);
options->tcp_port = (unsigned short)ntohs(channel->tcp_port);
options->udp_port = ntohs(aresx_sitous(channel->udp_port));
options->tcp_port = ntohs(aresx_sitous(channel->tcp_port));
options->sock_state_cb = channel->sock_state_cb;
options->sock_state_cb_data = channel->sock_state_cb_data;

View File

@ -1,5 +1,5 @@
/* Copyright (C) 2010-2011 by Daniel Stenberg
/* Copyright (C) 2010-2012 by Daniel Stenberg
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
@ -214,6 +214,25 @@ unsigned int aresx_sztoui(ssize_t sznum)
#endif
}
/*
** signed int to unsigned short
*/
unsigned short aresx_sitous(int sinum)
{
#ifdef __INTEL_COMPILER
# pragma warning(push)
# pragma warning(disable:810) /* conversion may lose significant bits */
#endif
DEBUGASSERT(sinum >= 0);
return (unsigned short)(sinum & (int) CARES_MASK_USHORT);
#ifdef __INTEL_COMPILER
# pragma warning(pop)
#endif
}
#if defined(__INTEL_COMPILER) && defined(__unix__)
int aresx_FD_ISSET(int fd, fd_set *fdset)

View File

@ -2,7 +2,7 @@
#define HEADER_CARES_NOWARN_H
/* Copyright (C) 2010-2011 by Daniel Stenberg
/* Copyright (C) 2010-2012 by Daniel Stenberg
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
@ -29,6 +29,8 @@ int aresx_sztosi(ssize_t sznum);
unsigned int aresx_sztoui(ssize_t sznum);
unsigned short aresx_sitous(int sinum);
#if defined(__INTEL_COMPILER) && defined(__unix__)
int aresx_FD_ISSET(int fd, fd_set *fdset);

View File

@ -1,6 +1,6 @@
/* Copyright 1998 by the Massachusetts Institute of Technology.
* Copyright (C) 2004-2011 by Daniel Stenberg
* Copyright (C) 2004-2012 by Daniel Stenberg
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
@ -946,7 +946,7 @@ static int open_tcp_socket(ares_channel channel, struct server_state *server)
salen = sizeof(saddr.sa4);
memset(sa, 0, salen);
saddr.sa4.sin_family = AF_INET;
saddr.sa4.sin_port = (unsigned short)(channel->tcp_port & 0xffff);
saddr.sa4.sin_port = aresx_sitous(channel->tcp_port);
memcpy(&saddr.sa4.sin_addr, &server->addr.addrV4,
sizeof(server->addr.addrV4));
break;
@ -955,7 +955,7 @@ static int open_tcp_socket(ares_channel channel, struct server_state *server)
salen = sizeof(saddr.sa6);
memset(sa, 0, salen);
saddr.sa6.sin6_family = AF_INET6;
saddr.sa6.sin6_port = (unsigned short)(channel->tcp_port & 0xffff);
saddr.sa6.sin6_port = aresx_sitous(channel->tcp_port);
memcpy(&saddr.sa6.sin6_addr, &server->addr.addrV6,
sizeof(server->addr.addrV6));
break;
@ -1038,7 +1038,7 @@ static int open_udp_socket(ares_channel channel, struct server_state *server)
salen = sizeof(saddr.sa4);
memset(sa, 0, salen);
saddr.sa4.sin_family = AF_INET;
saddr.sa4.sin_port = (unsigned short)(channel->udp_port & 0xffff);
saddr.sa4.sin_port = aresx_sitous(channel->udp_port);
memcpy(&saddr.sa4.sin_addr, &server->addr.addrV4,
sizeof(server->addr.addrV4));
break;
@ -1047,7 +1047,7 @@ static int open_udp_socket(ares_channel channel, struct server_state *server)
salen = sizeof(saddr.sa6);
memset(sa, 0, salen);
saddr.sa6.sin6_family = AF_INET6;
saddr.sa6.sin6_port = (unsigned short)(channel->udp_port & 0xffff);
saddr.sa6.sin6_port = aresx_sitous(channel->udp_port);
memcpy(&saddr.sa6.sin6_addr, &server->addr.addrV6,
sizeof(server->addr.addrV6));
break;