Author: gschneider
Date: Mon Dec 8 10:27:28 2008
New Revision: 37940
URL:
http://svn.reactos.org/svn/reactos?rev=37940&view=rev
Log:
- Remove unreachable code, CID 53
- Simplify parameter checks, fix return value, set last error correctly, fix typo
Modified:
trunk/reactos/dll/win32/ws2_32/misc/ns.c
Modified: trunk/reactos/dll/win32/ws2_32/misc/ns.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/ws2_32/misc/ns.c…
==============================================================================
--- trunk/reactos/dll/win32/ws2_32/misc/ns.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/ws2_32/misc/ns.c [iso-8859-1] Mon Dec 8 10:27:28 2008
@@ -382,7 +382,7 @@
/*
- * @implement
+ * @implemented
*/
INT
EXPORT
@@ -396,14 +396,15 @@
int res=0;
LONG inetaddr = 0;
LPWSTR *bp=NULL;
-
- SOCKADDR_IN *sockaddr = (SOCKADDR_IN *) lpAddress;
-
- if (!lpAddressLength || !lpAddress)
+ SOCKADDR_IN *sockaddr;
+
+ if (!lpAddressLength || !lpAddress || !AddressString)
+ {
+ WSASetLastError(WSAEINVAL);
return SOCKET_ERROR;
-
- if (AddressString==NULL)
- return WSAEINVAL;
+ }
+
+ sockaddr = (SOCKADDR_IN *) lpAddress;
/* Set right adress family */
if (lpProtocolInfo!=NULL)
@@ -421,45 +422,40 @@
}
else
{
- if (!lpAddress)
- res = WSAEINVAL;
+ // translate ip string to ip
+
+ /* rest sockaddr.sin_addr.s_addr
+ for we need to be sure it is zero when we come to while */
+ memset(lpAddress,0,sizeof(SOCKADDR_IN));
+
+ /* Set right adress family */
+ sockaddr->sin_family = AF_INET;
+
+ /* Get port number */
+ pos = wcscspn(AddressString,L":") + 1;
+
+ if (pos < (int)wcslen(AddressString))
+ sockaddr->sin_port = wcstol(&AddressString[pos],
+ bp,
+ 10);
+
else
+ sockaddr->sin_port = 0;
+
+ /* Get ip number */
+ pos=0;
+ inetaddr=0;
+
+ while (pos < (int)wcslen(AddressString))
{
- // translate now ip string to ip
-
- /* rest sockaddr.sin_addr.s_addr
- for we need to be sure it is zero when we come to while */
- memset(lpAddress,0,sizeof(SOCKADDR_IN));
-
- /* Set right adress family */
- sockaddr->sin_family = AF_INET;
-
- /* Get port number */
- pos = wcscspn(AddressString,L":") + 1;
-
- if (pos < (int)wcslen(AddressString))
- sockaddr->sin_port = wcstol(&AddressString[pos],
- bp,
- 10);
-
- else
- sockaddr->sin_port = 0;
-
- /* Get ip number */
- pos=0;
- inetaddr=0;
-
- while (pos < (int)wcslen(AddressString))
- {
- inetaddr = (inetaddr<<8) +
((UCHAR)wcstol(&AddressString[pos],
- bp,
- 10));
- pos += wcscspn( &AddressString[pos],L".") +1 ;
- }
-
- res = 0;
- sockaddr->sin_addr.s_addr = inetaddr;
+ inetaddr = (inetaddr<<8) + ((UCHAR)wcstol(&AddressString[pos],
+ bp,
+ 10));
+ pos += wcscspn( &AddressString[pos],L".") +1 ;
}
+
+ res = 0;
+ sockaddr->sin_addr.s_addr = inetaddr;
}
}