[前][次][番号順一覧][スレッド一覧]

ruby-changes:27199

From: nobu <ko1@a...>
Date: Fri, 15 Feb 2013 16:54:48 +0900 (JST)
Subject: [ruby-changes:27199] nobu:r39251 (trunk): socket: ai_addrlen is socklen_t

nobu	2013-02-15 16:54:38 +0900 (Fri, 15 Feb 2013)

  New Revision: 39251

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=39251

  Log:
    socket: ai_addrlen is socklen_t
    
    * ext/socket/raddrinfo.c (rsock_make_hostent): ai_addrlen is not
      size_t but socklen_t.

  Modified files:
    trunk/ext/socket/raddrinfo.c
    trunk/ext/socket/rubysocket.h
    trunk/ext/socket/socket.c
    trunk/ext/socket/tcpsocket.c

Index: ext/socket/tcpsocket.c
===================================================================
--- ext/socket/tcpsocket.c	(revision 39250)
+++ ext/socket/tcpsocket.c	(revision 39251)
@@ -32,7 +32,7 @@ tcp_init(int argc, VALUE *argv, VALUE so https://github.com/ruby/ruby/blob/trunk/ext/socket/tcpsocket.c#L32
 }
 
 static VALUE
-tcp_sockaddr(struct sockaddr *addr, size_t len)
+tcp_sockaddr(struct sockaddr *addr, socklen_t len)
 {
     return rsock_make_ipaddr(addr, len);
 }
Index: ext/socket/rubysocket.h
===================================================================
--- ext/socket/rubysocket.h	(revision 39250)
+++ ext/socket/rubysocket.h	(revision 39251)
@@ -237,7 +237,7 @@ VALUE rsock_addrinfo_new(struct sockaddr https://github.com/ruby/ruby/blob/trunk/ext/socket/rubysocket.h#L237
 
 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);
 
Index: ext/socket/raddrinfo.c
===================================================================
--- ext/socket/raddrinfo.c	(revision 39250)
+++ ext/socket/raddrinfo.c	(revision 39251)
@@ -465,7 +465,7 @@ rsock_unix_sockaddr_len(VALUE path) https://github.com/ruby/ruby/blob/trunk/ext/socket/raddrinfo.c#L465
 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 https://github.com/ruby/ruby/blob/trunk/ext/socket/raddrinfo.c#L473
 {
     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 https://github.com/ruby/ruby/blob/trunk/ext/socket/raddrinfo.c#L519
 }
 
 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;
 
Index: ext/socket/socket.c
===================================================================
--- ext/socket/socket.c	(revision 39250)
+++ ext/socket/socket.c	(revision 39251)
@@ -950,19 +950,19 @@ make_addrinfo(struct addrinfo *res0, int https://github.com/ruby/ruby/blob/trunk/ext/socket/socket.c#L950
 }
 
 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 https://github.com/ruby/ruby/blob/trunk/ext/socket/socket.c#L1239
 	    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, VA https://github.com/ruby/ruby/blob/trunk/ext/socket/socket.c#L1403
         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, sock https://github.com/ruby/ruby/blob/trunk/ext/socket/socket.c#L1518
 
     if (addr == NULL)
         return Qnil;
-    
+
     len = sockaddr_len(addr);
 
 #if defined(__KAME__) && defined(AF_INET6)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]