From 66c1e7960ccd1320e2121ed356538a674493e083 Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 15 Feb 2013 07:54:38 +0000 Subject: [PATCH] socket: ai_addrlen is socklen_t * ext/socket/raddrinfo.c (rsock_make_hostent): ai_addrlen is not size_t but socklen_t. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39251 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/socket/raddrinfo.c | 6 +++--- ext/socket/rubysocket.h | 2 +- ext/socket/socket.c | 12 ++++++------ ext/socket/tcpsocket.c | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ext/socket/raddrinfo.c b/ext/socket/raddrinfo.c index a2b2029f0f..e8955d7acb 100644 --- a/ext/socket/raddrinfo.c +++ b/ext/socket/raddrinfo.c @@ -465,7 +465,7 @@ rsock_unix_sockaddr_len(VALUE path) struct hostent_arg { VALUE host; struct addrinfo* addr; - VALUE (*ipaddr)(struct sockaddr*, size_t); + VALUE (*ipaddr)(struct sockaddr*, socklen_t); }; static VALUE @@ -473,7 +473,7 @@ make_hostent_internal(struct hostent_arg *arg) { VALUE host = arg->host; struct addrinfo* addr = arg->addr; - VALUE (*ipaddr)(struct sockaddr*, size_t) = arg->ipaddr; + VALUE (*ipaddr)(struct sockaddr*, socklen_t) = arg->ipaddr; struct addrinfo *ai; struct hostent *h; @@ -519,7 +519,7 @@ rsock_freeaddrinfo(struct addrinfo *addr) } VALUE -rsock_make_hostent(VALUE host, struct addrinfo *addr, VALUE (*ipaddr)(struct sockaddr *, size_t)) +rsock_make_hostent(VALUE host, struct addrinfo *addr, VALUE (*ipaddr)(struct sockaddr *, socklen_t)) { struct hostent_arg arg; diff --git a/ext/socket/rubysocket.h b/ext/socket/rubysocket.h index 50f169823c..28d50d13cc 100644 --- a/ext/socket/rubysocket.h +++ b/ext/socket/rubysocket.h @@ -237,7 +237,7 @@ VALUE rsock_addrinfo_new(struct sockaddr *addr, socklen_t len, int family, int s VALUE rsock_make_ipaddr(struct sockaddr *addr, socklen_t addrlen); VALUE rsock_ipaddr(struct sockaddr *sockaddr, socklen_t sockaddrlen, int norevlookup); -VALUE rsock_make_hostent(VALUE host, struct addrinfo *addr, VALUE (*ipaddr)(struct sockaddr *, size_t)); +VALUE rsock_make_hostent(VALUE host, struct addrinfo *addr, VALUE (*ipaddr)(struct sockaddr *, socklen_t)); int rsock_revlookup_flag(VALUE revlookup, int *norevlookup); diff --git a/ext/socket/socket.c b/ext/socket/socket.c index be3f8cc4f1..495cae19e4 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -950,19 +950,19 @@ make_addrinfo(struct addrinfo *res0, int norevlookup) } static VALUE -sock_sockaddr(struct sockaddr *addr, size_t len) +sock_sockaddr(struct sockaddr *addr, socklen_t len) { char *ptr; switch (addr->sa_family) { case AF_INET: ptr = (char*)&((struct sockaddr_in*)addr)->sin_addr.s_addr; - len = sizeof(((struct sockaddr_in*)addr)->sin_addr.s_addr); + len = (socklen_t)sizeof(((struct sockaddr_in*)addr)->sin_addr.s_addr); break; #ifdef AF_INET6 case AF_INET6: ptr = (char*)&((struct sockaddr_in6*)addr)->sin6_addr.s6_addr; - len = sizeof(((struct sockaddr_in6*)addr)->sin6_addr.s6_addr); + len = (socklen_t)sizeof(((struct sockaddr_in6*)addr)->sin6_addr.s6_addr); break; #endif default: @@ -1239,7 +1239,7 @@ sock_s_getnameinfo(int argc, VALUE *argv) rb_raise(rb_eTypeError, "sockaddr size differs - should not happen"); } sap = (struct sockaddr*)&ss; - salen = RSTRING_LEN(sa); + salen = RSTRING_LENINT(sa); goto call_nameinfo; } tmp = rb_check_array_type(sa); @@ -1403,7 +1403,7 @@ sock_s_unpack_sockaddr_in(VALUE self, VALUE addr) rb_raise(rb_eArgError, "not an AF_INET sockaddr"); #endif } - host = rsock_make_ipaddr((struct sockaddr*)sockaddr, RSTRING_LEN(addr)); + host = rsock_make_ipaddr((struct sockaddr*)sockaddr, RSTRING_LENINT(addr)); OBJ_INFECT(host, addr); return rb_assoc_new(INT2NUM(ntohs(sockaddr->sin_port)), host); } @@ -1518,7 +1518,7 @@ sockaddr_obj(struct sockaddr *addr, socklen_t len) if (addr == NULL) return Qnil; - + len = sockaddr_len(addr); #if defined(__KAME__) && defined(AF_INET6) diff --git a/ext/socket/tcpsocket.c b/ext/socket/tcpsocket.c index 608156f1b2..6217e424d9 100644 --- a/ext/socket/tcpsocket.c +++ b/ext/socket/tcpsocket.c @@ -32,7 +32,7 @@ tcp_init(int argc, VALUE *argv, VALUE sock) } static VALUE -tcp_sockaddr(struct sockaddr *addr, size_t len) +tcp_sockaddr(struct sockaddr *addr, socklen_t len) { return rsock_make_ipaddr(addr, len); }