mirror of
https://github.com/moparisthebest/curl
synced 2024-12-22 08:08:50 -05:00
fix compiler warning
This commit is contained in:
parent
71edaf4d01
commit
10035c898b
@ -410,22 +410,22 @@ static CURLcode bindlocal(struct connectdata *conn,
|
|||||||
/* if a local port number is requested but no local IP, extract the
|
/* if a local port number is requested but no local IP, extract the
|
||||||
address from the socket */
|
address from the socket */
|
||||||
if(af == AF_INET) {
|
if(af == AF_INET) {
|
||||||
memset(&me, 0, sizeof(struct sockaddr));
|
memset(&me, 0, sizeof(me));
|
||||||
me.sin_family = AF_INET;
|
me.sin_family = AF_INET;
|
||||||
me.sin_addr.s_addr = INADDR_ANY;
|
me.sin_addr.s_addr = INADDR_ANY;
|
||||||
|
|
||||||
sock = (struct sockaddr *)&me;
|
sock = (struct sockaddr *)&me;
|
||||||
socksize = sizeof(struct sockaddr);
|
socksize = sizeof(me);
|
||||||
|
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_IPV6
|
#ifdef ENABLE_IPV6
|
||||||
else { /* AF_INET6 */
|
else { /* AF_INET6 */
|
||||||
memset(&me6, 0, sizeof(struct sockaddr));
|
memset(&me6, 0, sizeof(me6));
|
||||||
me6.sin6_family = AF_INET6;
|
me6.sin6_family = AF_INET6;
|
||||||
me6.sin6_addr = in6addr_any;
|
me6.sin6_addr = in6addr_any;
|
||||||
|
|
||||||
sock = (struct sockaddr *)&me6;
|
sock = (struct sockaddr *)&me6;
|
||||||
socksize = sizeof(struct sockaddr);
|
socksize = sizeof(me6);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -437,16 +437,17 @@ static CURLcode bindlocal(struct connectdata *conn,
|
|||||||
|
|
||||||
/* Set port number to bind to, 0 makes the system pick one */
|
/* Set port number to bind to, 0 makes the system pick one */
|
||||||
if(sock->sa_family == AF_INET)
|
if(sock->sa_family == AF_INET)
|
||||||
((struct sockaddr_in *)sock)->sin_port = htons(port);
|
me.sin_port = htons(port);
|
||||||
#ifdef ENABLE_IPV6
|
#ifdef ENABLE_IPV6
|
||||||
else
|
else
|
||||||
((struct sockaddr_in6 *)sock)->sin6_port = htons(port);
|
me6.sin6_port = htons(port);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if( bind(sockfd, sock, socksize) >= 0) {
|
if( bind(sockfd, sock, socksize) >= 0) {
|
||||||
/* we succeeded to bind */
|
/* we succeeded to bind */
|
||||||
struct Curl_sockaddr_storage add;
|
struct Curl_sockaddr_storage add;
|
||||||
socklen_t size = sizeof(add);
|
socklen_t size = sizeof(add);
|
||||||
|
memset(&add, 0, sizeof(struct Curl_sockaddr_storage));
|
||||||
if(getsockname(sockfd, (struct sockaddr *) &add, &size) < 0) {
|
if(getsockname(sockfd, (struct sockaddr *) &add, &size) < 0) {
|
||||||
data->state.os_errno = error = SOCKERRNO;
|
data->state.os_errno = error = SOCKERRNO;
|
||||||
failf(data, "getsockname() failed with errno %d: %s",
|
failf(data, "getsockname() failed with errno %d: %s",
|
||||||
@ -764,6 +765,10 @@ singleipconnect(struct connectdata *conn,
|
|||||||
curl_socket_t sockfd;
|
curl_socket_t sockfd;
|
||||||
CURLcode res;
|
CURLcode res;
|
||||||
const void *iptoprint;
|
const void *iptoprint;
|
||||||
|
struct sockaddr_in * const sa4 = (void *)&addr.sa_addr;
|
||||||
|
#ifdef ENABLE_IPV6
|
||||||
|
struct sockaddr_in6 * const sa6 = (void *)&addr.sa_addr;
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The Curl_sockaddr_ex structure is basically libcurl's external API
|
* The Curl_sockaddr_ex structure is basically libcurl's external API
|
||||||
@ -804,9 +809,9 @@ singleipconnect(struct connectdata *conn,
|
|||||||
/* no socket, no connection */
|
/* no socket, no connection */
|
||||||
return CURL_SOCKET_BAD;
|
return CURL_SOCKET_BAD;
|
||||||
|
|
||||||
#ifdef CURLRES_IPV6
|
#ifdef ENABLE_IPV6
|
||||||
if (conn->scope && (addr.family == AF_INET6))
|
if (conn->scope && (addr.family == AF_INET6))
|
||||||
((struct sockaddr_in6 *)(&addr.sa_addr))->sin6_scope_id = conn->scope;
|
sa6->sin6_scope_id = conn->scope;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* FIXME: do we have Curl_printable_address-like with struct sockaddr* as
|
/* FIXME: do we have Curl_printable_address-like with struct sockaddr* as
|
||||||
@ -823,10 +828,10 @@ singleipconnect(struct connectdata *conn,
|
|||||||
{
|
{
|
||||||
#ifdef ENABLE_IPV6
|
#ifdef ENABLE_IPV6
|
||||||
if(addr.family == AF_INET6)
|
if(addr.family == AF_INET6)
|
||||||
iptoprint = &((const struct sockaddr_in6*)(&addr.sa_addr))->sin6_addr;
|
iptoprint = &sa6->sin6_addr;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
iptoprint = &((const struct sockaddr_in*)(&addr.sa_addr))->sin_addr;
|
iptoprint = &sa4->sin_addr;
|
||||||
|
|
||||||
if(Curl_inet_ntop(addr.family, iptoprint, addr_buf,
|
if(Curl_inet_ntop(addr.family, iptoprint, addr_buf,
|
||||||
sizeof(addr_buf)) != NULL) {
|
sizeof(addr_buf)) != NULL) {
|
||||||
|
10
lib/ftp.c
10
lib/ftp.c
@ -879,6 +879,8 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
|
|||||||
socklen_t sslen;
|
socklen_t sslen;
|
||||||
char hbuf[NI_MAXHOST];
|
char hbuf[NI_MAXHOST];
|
||||||
struct sockaddr *sa=(struct sockaddr *)&ss;
|
struct sockaddr *sa=(struct sockaddr *)&ss;
|
||||||
|
struct sockaddr_in * const sa4 = (void *)sa;
|
||||||
|
struct sockaddr_in6 * const sa6 = (void *)sa;
|
||||||
char tmp[1024];
|
char tmp[1024];
|
||||||
static const char mode[][5] = { "EPRT", "PORT" };
|
static const char mode[][5] = { "EPRT", "PORT" };
|
||||||
int rc;
|
int rc;
|
||||||
@ -974,9 +976,9 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
|
|||||||
|
|
||||||
/* set port number to zero to make bind() pick "any" */
|
/* set port number to zero to make bind() pick "any" */
|
||||||
if(sa->sa_family == AF_INET)
|
if(sa->sa_family == AF_INET)
|
||||||
((struct sockaddr_in *)sa)->sin_port=0;
|
sa4->sin_port = 0;
|
||||||
else
|
else
|
||||||
((struct sockaddr_in6 *)sa)->sin6_port =0;
|
sa6->sin6_port = 0;
|
||||||
|
|
||||||
if(sslen > (socklen_t)sizeof(ss))
|
if(sslen > (socklen_t)sizeof(ss))
|
||||||
sslen = sizeof(ss);
|
sslen = sizeof(ss);
|
||||||
@ -1027,10 +1029,10 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
|
|||||||
|
|
||||||
switch (sa->sa_family) {
|
switch (sa->sa_family) {
|
||||||
case AF_INET:
|
case AF_INET:
|
||||||
port = ntohs(((struct sockaddr_in *)sa)->sin_port);
|
port = ntohs(sa4->sin_port);
|
||||||
break;
|
break;
|
||||||
case AF_INET6:
|
case AF_INET6:
|
||||||
port = ntohs(((struct sockaddr_in6 *)sa)->sin6_port);
|
port = ntohs(sa6->sin6_port);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user