harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r720190 - in /harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port: unix/hysock.c windows/hysock.c
Date Mon, 24 Nov 2008 13:15:27 GMT
Author: tellison
Date: Mon Nov 24 05:15:27 2008
New Revision: 720190

URL: http://svn.apache.org/viewvc?rev=720190&view=rev
Log:
Code tidy-up, no functional changes.

Modified:
    harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/hysock.c
    harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/windows/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?rev=720190&r1=720189&r2=720190&view=diff
==============================================================================
--- 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
Nov 24 05:15:27 2008
@@ -2489,17 +2489,13 @@
   I_32 bytesRec = 0;
 
   bytesRec = recv (SOCKET_CAST (sock), buf, nbyte, flags);
-  if (-1 == bytesRec)
-    {
-      I_32 err = errno;
-      HYSOCKDEBUG ("<recv failed, err=%d>\n", err);
-      return portLibrary->error_set_last_error (portLibrary, err,
-                                                findError (err));
-    }
-  else
-    {
-      return bytesRec;
-    }
+  if (-1 == bytesRec) {
+    I_32 err = errno;
+    HYSOCKDEBUG ("<recv failed, err=%d>\n", err);
+    return portLibrary->error_set_last_error (portLibrary, err, findError(err));
+  } else {
+    return bytesRec;
+  }
 }
 
 #undef CDEV_CURRENT_FUNCTION

Modified: harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/windows/hysock.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/windows/hysock.c?rev=720190&r1=720189&r2=720190&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/windows/hysock.c
(original)
+++ harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/windows/hysock.c
Mon Nov 24 05:15:27 2008
@@ -2457,41 +2457,35 @@
   I_32 bytesRec = 0;
   int socketTypeLen = sizeof (DWORD);
 
-  if (sock->flags & SOCKET_USE_IPV4_MASK
-      || !(sock->flags & SOCKET_IPV6_OPEN_MASK))
-    {
+  if (sock->flags & SOCKET_USE_IPV4_MASK ||
+     !(sock->flags & SOCKET_IPV6_OPEN_MASK)) {
+
       bytesRec = recv (sock->ipv4, (char *) buf, nbyte, flags);
-    }
-  else
-    {				/* If IPv6 is open */
+  } else {
+      /* If IPv6 is open */
       bytesRec = recv (sock->ipv6, (char *) buf, nbyte, flags);
-    }
+  }
+
+  if (SOCKET_ERROR == bytesRec) {
+    rc = WSAGetLastError();
+    HYSOCKDEBUG ("<recv failed, err=%d>\n", rc);
+    switch (rc) {
+      case WSAEINVAL :
+        return portLibrary->error_set_last_error (
+            portLibrary, rc, HYPORT_ERROR_SOCKET_NOTBOUND);
+      case WSAEMSGSIZE :
+        rc = portLibrary->error_set_last_error (portLibrary, rc, WSAEMSGSIZE);
+        if (flags == MSG_PEEK) {
+            return nbyte;
+        }
+      default :
+        return portLibrary->error_set_last_error (
+            portLibrary, rc, findError (rc));
+      }
+  } else {
+    rc = bytesRec;
+  }
 
-  if (SOCKET_ERROR == bytesRec)
-    {
-      rc = WSAGetLastError ();
-      HYSOCKDEBUG ("<recv failed, err=%d>\n", rc);
-      switch (rc)
-	{
-	case WSAEINVAL:
-	  return portLibrary->error_set_last_error (portLibrary, rc,
-						    HYPORT_ERROR_SOCKET_NOTBOUND);
-	case WSAEMSGSIZE:
-	  rc =
-	    portLibrary->error_set_last_error (portLibrary, rc, WSAEMSGSIZE);
-	  if (flags == MSG_PEEK)
-	    {
-	      return nbyte;
-	    }
-	default:
-	  return portLibrary->error_set_last_error (portLibrary, rc,
-						    findError (rc));
-	}
-    }
-  else
-    {
-      rc = bytesRec;
-    }
   return rc;
 }
 
@@ -2613,43 +2607,30 @@
   I_32 rc = 0;
   I_32 result = 0;
 
-  if (NULL == timeout)
-    {
-      result =
-	select (nfds, &readfds->handle, &writefds->handle, &exceptfds->handle,
-		NULL);
-    }
-  else
-    {
-      result =
-	select (nfds, &readfds->handle, &writefds->handle, &exceptfds->handle,
-		&timeout->time);
-    }
-  if (SOCKET_ERROR == result)
-    {
-      rc = WSAGetLastError ();
-      HYSOCKDEBUG ("<select failed, err=%d>\n", rc);
-      switch (rc)
-	{
-	case WSAEINVAL:
-	  return portLibrary->error_set_last_error (portLibrary, rc,
-						    HYPORT_ERROR_SOCKET_INVALIDTIMEOUT);
-	default:
-	  return portLibrary->error_set_last_error (portLibrary, rc,
-						    findError (rc));
-	}
-    }
-  else
-    {
-      if (0 == result)
-	{
-	  rc = HYPORT_ERROR_SOCKET_TIMEOUT;
-	}
-      else
-	{
-	  rc = result;
-	}
+  if (NULL == timeout) {
+    result =
+	  select(nfds, &readfds->handle, &writefds->handle, &exceptfds->handle,
NULL);
+  } else {
+    result =
+	  select(nfds, &readfds->handle, &writefds->handle, &exceptfds->handle,
&timeout->time);
+  }
+  if (SOCKET_ERROR == result) {
+    rc = WSAGetLastError ();
+    HYSOCKDEBUG ("<select failed, err=%d>\n", rc);
+    switch (rc) {
+      case WSAEINVAL :
+        return portLibrary->error_set_last_error(
+          portLibrary, rc, HYPORT_ERROR_SOCKET_INVALIDTIMEOUT);
+      default :
+        return portLibrary->error_set_last_error (portLibrary, rc, findError (rc));
+	}
+  } else {
+    if (0 == result) {
+      rc = HYPORT_ERROR_SOCKET_TIMEOUT;
+    } else {
+      rc = result;
     }
+  }
   return rc;
 }
 



Mime
View raw message