harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r540129 - /harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/hysock.c
Date Mon, 21 May 2007 12:17:30 GMT
Author: hindessm
Date: Mon May 21 05:17:29 2007
New Revision: 540129

URL: http://svn.apache.org/viewvc?view=rev&rev=540129
Log:
Linux man for inet_addr says:

  This is an obsolete interface to inet_aton(), described immediately
  above; it is obsolete because -1 is a valid address
  (255.255.255.255), and inet_aton() provides a cleaner way to
  indicate error return.

so I've modified the code to use inet_aton instead.  I also fixed a
bug in the documentation.  (The [in] and [out] parameters where the
wrong way around.)

Modified:
    harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/hysock.c

Modified: harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/hysock.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/hysock.c?view=diff&rev=540129&r1=540128&r2=540129
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/hysock.c (original)
+++ harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/hysock.c Mon
May 21 05:17:29 2007
@@ -35,6 +35,7 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netinet/in.h>         /* for struct in_addr */
+#include <arpa/inet.h>          /* for inet_addr */
 #include <sys/ioctl.h>
 #include <net/if.h>             /* for struct ifconf */
 
@@ -2194,8 +2195,8 @@
  * Answer the dotted IP string as an Internet address.
  *
  * @param[in] portLibrary The port library.
- * @param[out] addrStr The dotted IP string.
- * @param[in] addr Pointer to the Internet address.
+ * @param[in] addrStr The dotted IP string.
+ * @param[out] addr Pointer to the Internet address.
  *
  * @return	0, if no errors occurred, otherwise the (negative) error code.
  */
@@ -2204,17 +2205,15 @@
                  U_32 * addr)
 {
   I_32 rc = 0;
-  U_32 val;
-
-  val = inet_addr (addrStr);
-  if (val == -1)
+  struct in_addr in;
+  if (inet_aton(addrStr, &in) == 0)
     {
-      HYSOCKDEBUGPRINT ("<inet_addr failed>\n");
+      HYSOCKDEBUGPRINT ("<inet_aton failed>\n");
       rc = HYPORT_ERROR_SOCKET_ADDRNOTAVAIL;
     }
   else
     {
-      *addr = val;
+      *addr = in.s_addr;
     }
   return rc;
 }



Mime
View raw message