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

ruby-changes:28592

From: akr <ko1@a...>
Date: Sat, 11 May 2013 22:04:53 +0900 (JST)
Subject: [ruby-changes:28592] akr:r40644 (trunk): * ext/socket/raddrinfo.c (rsock_inspect_sockaddr): Add casts to

akr	2013-05-11 22:04:39 +0900 (Sat, 11 May 2013)

  New Revision: 40644

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

  Log:
    * ext/socket/raddrinfo.c (rsock_inspect_sockaddr): Add casts to
      suppress warnings.

  Modified files:
    trunk/ChangeLog
    trunk/ext/socket/raddrinfo.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 40643)
+++ ChangeLog	(revision 40644)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat May 11 21:56:34 2013  Tanaka Akira  <akr@f...>
+
+	* ext/socket/raddrinfo.c (rsock_inspect_sockaddr): Add casts to
+	  suppress warnings.
+
 Sat May 11 17:28:51 2013  Tanaka Akira  <akr@f...>
 
 	* ext/socket: New method, Socket.getifaddrs, implemented.
Index: ext/socket/raddrinfo.c
===================================================================
--- ext/socket/raddrinfo.c	(revision 40643)
+++ ext/socket/raddrinfo.c	(revision 40644)
@@ -980,24 +980,24 @@ rsock_inspect_sockaddr(struct sockaddr * https://github.com/ruby/ruby/blob/trunk/ext/socket/raddrinfo.c#L980
             struct sockaddr_in *addr;
             int port;
 	    addr = &sockaddr->in;
-	    if (((char*)&addr->sin_addr)-(char*)addr+0+1 <= socklen)
+	    if ((socklen_t)(((char*)&addr->sin_addr)-(char*)addr+0+1) <= socklen)
 		rb_str_catf(ret, "%d", ((unsigned char*)&addr->sin_addr)[0]);
 	    else
 		rb_str_cat2(ret, "?");
-	    if (((char*)&addr->sin_addr)-(char*)addr+1+1 <= socklen)
+	    if ((socklen_t)(((char*)&addr->sin_addr)-(char*)addr+1+1) <= socklen)
 		rb_str_catf(ret, ".%d", ((unsigned char*)&addr->sin_addr)[1]);
 	    else
 		rb_str_cat2(ret, ".?");
-	    if (((char*)&addr->sin_addr)-(char*)addr+2+1 <= socklen)
+	    if ((socklen_t)(((char*)&addr->sin_addr)-(char*)addr+2+1) <= socklen)
 		rb_str_catf(ret, ".%d", ((unsigned char*)&addr->sin_addr)[2]);
 	    else
 		rb_str_cat2(ret, ".?");
-	    if (((char*)&addr->sin_addr)-(char*)addr+3+1 <= socklen)
+	    if ((socklen_t)(((char*)&addr->sin_addr)-(char*)addr+3+1) <= socklen)
 		rb_str_catf(ret, ".%d", ((unsigned char*)&addr->sin_addr)[3]);
 	    else
 		rb_str_cat2(ret, ".?");
 
-	    if (((char*)&addr->sin_port)-(char*)addr+(int)sizeof(addr->sin_port) < socklen) {
+	    if ((socklen_t)(((char*)&addr->sin_port)-(char*)addr+(int)sizeof(addr->sin_port)) < socklen) {
 		port = ntohs(addr->sin_port);
 		if (port)
 		    rb_str_catf(ret, ":%d", port);
@@ -1095,11 +1095,11 @@ rsock_inspect_sockaddr(struct sockaddr * https://github.com/ruby/ruby/blob/trunk/ext/socket/raddrinfo.c#L1095
 
             rb_str_cat2(ret, "PACKET");
 
-            if (offsetof(struct sockaddr_ll, sll_protocol) + sizeof(addr->sll_protocol) <= socklen) {
+            if (offsetof(struct sockaddr_ll, sll_protocol) + sizeof(addr->sll_protocol) <= (size_t)socklen) {
                 CATSEP;
                 rb_str_catf(ret, "protocol=%d", ntohs(addr->sll_protocol));
             }
-            if (offsetof(struct sockaddr_ll, sll_ifindex) + sizeof(addr->sll_ifindex) <= socklen) {
+            if (offsetof(struct sockaddr_ll, sll_ifindex) + sizeof(addr->sll_ifindex) <= (size_t)socklen) {
                 char buf[IFNAMSIZ];
                 CATSEP;
                 if (if_indextoname(addr->sll_ifindex, buf) == NULL)
@@ -1107,11 +1107,11 @@ rsock_inspect_sockaddr(struct sockaddr * https://github.com/ruby/ruby/blob/trunk/ext/socket/raddrinfo.c#L1107
                 else
                     rb_str_catf(ret, "%s", buf);
             }
-            if (offsetof(struct sockaddr_ll, sll_hatype) + sizeof(addr->sll_hatype) <= socklen) {
+            if (offsetof(struct sockaddr_ll, sll_hatype) + sizeof(addr->sll_hatype) <= (size_t)socklen) {
                 CATSEP;
                 rb_str_catf(ret, "hatype=%d", addr->sll_hatype);
             }
-            if (offsetof(struct sockaddr_ll, sll_pkttype) + sizeof(addr->sll_pkttype) <= socklen) {
+            if (offsetof(struct sockaddr_ll, sll_pkttype) + sizeof(addr->sll_pkttype) <= (size_t)socklen) {
                 CATSEP;
                 if (addr->sll_pkttype == PACKET_HOST)
                     rb_str_cat2(ret, "HOST");
@@ -1128,16 +1128,16 @@ rsock_inspect_sockaddr(struct sockaddr * https://github.com/ruby/ruby/blob/trunk/ext/socket/raddrinfo.c#L1128
             }
             if (socklen != (socklen_t)(offsetof(struct sockaddr_ll, sll_addr) + addr->sll_halen)) {
                 CATSEP;
-                if (offsetof(struct sockaddr_ll, sll_halen) + sizeof(addr->sll_halen) <= socklen) {
+                if (offsetof(struct sockaddr_ll, sll_halen) + sizeof(addr->sll_halen) <= (size_t)socklen) {
                     rb_str_catf(ret, "halen=%d", addr->sll_halen);
                 }
             }
-            if (offsetof(struct sockaddr_ll, sll_addr) < socklen) {
+            if (offsetof(struct sockaddr_ll, sll_addr) < (size_t)socklen) {
                 socklen_t len, i;
                 CATSEP;
                 rb_str_cat2(ret, "hwaddr");
                 len = addr->sll_halen;
-                if (socklen < offsetof(struct sockaddr_ll, sll_addr) + len)
+                if ((size_t)socklen < offsetof(struct sockaddr_ll, sll_addr) + len)
                     len = socklen - offsetof(struct sockaddr_ll, sll_addr);
                 for (i = 0; i < len; i++) {
                     rb_str_cat2(ret, i == 0 ? "=" : ":");

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

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