Author: hbelusca
Date: Sat Mar 4 01:09:28 2017
New Revision: 74045
URL:
http://svn.reactos.org/svn/reactos?rev=74045&view=rev
Log:
[WS2_32]
- Turn the "!memcmp(ptr1, ptr2, sizeof(GUID))" into IsEqualGUID(ptr1, ptr2)
macro calls (aka. make code readable);
this also allowed me to discover a logical bug in the GUID comparison in
WsNcUpdateNamespaceList.
- Fix few comments, and rename some goto labels to make their meaning clearer (they are
not only taken for error code paths,
but also on regular path, for cleanup before returning from the function).
CORE-12880
Modified:
trunk/reactos/dll/win32/ws2_32/src/dcatalog.c
trunk/reactos/dll/win32/ws2_32/src/nscatalo.c
trunk/reactos/dll/win32/ws2_32/src/nsquery.c
trunk/reactos/dll/win32/ws2_32/src/qshelpr.c
Modified: trunk/reactos/dll/win32/ws2_32/src/dcatalog.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/ws2_32/src/dcata…
==============================================================================
--- trunk/reactos/dll/win32/ws2_32/src/dcatalog.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/ws2_32/src/dcatalog.c [iso-8859-1] Sat Mar 4 01:09:28 2017
@@ -591,10 +591,8 @@
Provider = CatalogEntry->Provider;
/* Check for a match */
- if ((Provider) &&
- !(memcmp(&CatalogEntry->ProtocolInfo.ProviderId,
- ProviderId,
- sizeof(GUID))))
+ if (Provider &&
+ IsEqualGUID(&CatalogEntry->ProtocolInfo.ProviderId, ProviderId))
{
/* Found a match */
return Provider;
@@ -879,10 +877,8 @@
/* Get this entry */
CatalogEntry = CONTAINING_RECORD(Entry, TCATALOG_ENTRY, CatalogLink);
- /* Remove it */
+ /* Remove it and dereference it */
WsTcRemoveCatalogItem(Catalog, CatalogEntry);
-
- /* Dereference it */
WsTcEntryDereference(CatalogEntry);
/* Move to the next entry */
Modified: trunk/reactos/dll/win32/ws2_32/src/nscatalo.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/ws2_32/src/nscat…
==============================================================================
--- trunk/reactos/dll/win32/ws2_32/src/nscatalo.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/ws2_32/src/nscatalo.c [iso-8859-1] Sat Mar 4 01:09:28 2017
@@ -459,9 +459,8 @@
Entry = Entry->Flink;
/* Check if they match */
- if (memcmp(&CatalogEntry->ProviderId,
- &OldCatalogEntry->ProviderId,
- sizeof(GUID)))
+ if (IsEqualGUID(&CatalogEntry->ProviderId,
+ &OldCatalogEntry->ProviderId))
{
/* We have a match, use the old item instead */
WsNcEntryDereference(CatalogEntry);
@@ -513,7 +512,7 @@
NextEntry = NextEntry->Flink;
/* Check if this is the Catalog Entry ID we want */
- if (!(memcmp(&Entry->ProviderId, ProviderId, sizeof(GUID))))
+ if (IsEqualGUID(&Entry->ProviderId, ProviderId))
{
/* Check if it doesn't already have a provider */
if (!Entry->Provider)
@@ -619,10 +618,8 @@
/* Get this entry */
CatalogEntry = CONTAINING_RECORD(Entry, NSCATALOG_ENTRY, CatalogLink);
- /* Remove it */
+ /* Remove it and dereference it */
WsNcRemoveCatalogItem(Catalog, CatalogEntry);
-
- /* Dereference it */
WsNcEntryDereference(CatalogEntry);
/* Move to the next entry */
Modified: trunk/reactos/dll/win32/ws2_32/src/nsquery.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/ws2_32/src/nsque…
==============================================================================
--- trunk/reactos/dll/win32/ws2_32/src/nsquery.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/ws2_32/src/nsquery.c [iso-8859-1] Sat Mar 4 01:09:28 2017
@@ -373,7 +373,7 @@
SetLastError(ErrorCode);
ErrorCode = SOCKET_ERROR;
NsQuery->TryAgain = FALSE;
- goto error;
+ goto Exit;
}
/* Cache the information for a restart */
@@ -384,17 +384,17 @@
/* Check if we have a specific ID */
if (Restrictions->lpNSProviderId)
{
- /* Get the provider */
+ /* Get the catalog entry */
ErrorCode = WsNcGetCatalogFromProviderId(Catalog,
Restrictions->lpNSProviderId,
&CatalogEntry);
- /* Check for success */
+ /* Check for failure */
if (ErrorCode != ERROR_SUCCESS)
{
/* Fail */
SetLastError(WSAEINVAL);
ErrorCode = SOCKET_ERROR;
- goto error;
+ goto Exit;
}
else
{
@@ -422,7 +422,7 @@
/* Fail */
SetLastError(WSAEINVAL);
ErrorCode = SOCKET_ERROR;
- goto error;
+ goto Exit;
}
}
@@ -447,7 +447,7 @@
/* We don't have any providers to handle this! */
ErrorCode = SOCKET_ERROR;
SetLastError(WSASERVICE_NOT_FOUND);
- goto error;
+ goto Exit;
}
/* Get the first provider and loop */
@@ -476,7 +476,7 @@
}
}
-error:
+Exit:
/* Check if we had an error somewhere */
if (ErrorCode == SOCKET_ERROR)
{
Modified: trunk/reactos/dll/win32/ws2_32/src/qshelpr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/ws2_32/src/qshel…
==============================================================================
--- trunk/reactos/dll/win32/ws2_32/src/qshelpr.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/ws2_32/src/qshelpr.c [iso-8859-1] Sat Mar 4 01:09:28 2017
@@ -823,12 +823,12 @@
{
/* Fail, couldn't allocate memory */
ErrorCode = WSA_NOT_ENOUGH_MEMORY;
- goto error;
+ goto Exit;
}
/* Build the relative buffer version */
ErrorCode = WSABuildQuerySetBufferA(AnsiSet, AnsiSize, AnsiCopy);
- if (ErrorCode != ERROR_SUCCESS) goto error;
+ if (ErrorCode != ERROR_SUCCESS) goto Exit;
/* Re-use the ANSI version since the fields match */
UnicodeCopy = (LPWSAQUERYSETW)AnsiCopy;
@@ -842,7 +842,7 @@
{
/* Fail */
ErrorCode = WSA_NOT_ENOUGH_MEMORY;
- goto error;
+ goto Exit;
}
/* Set the new string pointer */
@@ -858,7 +858,7 @@
{
/* Fail */
ErrorCode = WSA_NOT_ENOUGH_MEMORY;
- goto error;
+ goto Exit;
}
/* Set the new string pointer */
@@ -874,7 +874,7 @@
{
/* Fail */
ErrorCode = WSA_NOT_ENOUGH_MEMORY;
- goto error;
+ goto Exit;
}
/* Set the new string pointer */
@@ -890,7 +890,7 @@
{
/* Fail */
ErrorCode = WSA_NOT_ENOUGH_MEMORY;
- goto error;
+ goto Exit;
}
/* Set the new string pointer */
@@ -904,13 +904,13 @@
/* The buffer wasn't large enough; return how much we need */
*SetSize = UnicodeSize;
ErrorCode = WSAEFAULT;
- goto error;
+ goto Exit;
}
/* Build the relative unicode buffer */
ErrorCode = WSABuildQuerySetBufferW(UnicodeCopy, *SetSize, UnicodeSet);
-error:
+Exit:
/* Free the Ansi copy if we had one */
if (AnsiCopy) HeapFree(WsSockHeap, 0, AnsiCopy);
@@ -944,12 +944,12 @@
{
/* Fail, couldn't allocate memory */
ErrorCode = WSA_NOT_ENOUGH_MEMORY;
- goto error;
+ goto Exit;
}
/* Build the relative buffer version */
ErrorCode = WSABuildQuerySetBufferW(UnicodeSet, UnicodeSize, UnicodeCopy);
- if (ErrorCode != ERROR_SUCCESS) goto error;
+ if (ErrorCode != ERROR_SUCCESS) goto Exit;
/* Re-use the Unicode version since the fields match */
AnsiCopy = (LPWSAQUERYSETA)UnicodeCopy;
@@ -963,7 +963,7 @@
{
/* Fail */
ErrorCode = WSA_NOT_ENOUGH_MEMORY;
- goto error;
+ goto Exit;
}
/* Set the new string pointer */
@@ -979,7 +979,7 @@
{
/* Fail */
ErrorCode = WSA_NOT_ENOUGH_MEMORY;
- goto error;
+ goto Exit;
}
/* Set the new string pointer */
@@ -995,7 +995,7 @@
{
/* Fail */
ErrorCode = WSA_NOT_ENOUGH_MEMORY;
- goto error;
+ goto Exit;
}
/* Set the new string pointer */
@@ -1011,7 +1011,7 @@
{
/* Fail */
ErrorCode = WSA_NOT_ENOUGH_MEMORY;
- goto error;
+ goto Exit;
}
/* Set the new string pointer */
@@ -1025,13 +1025,13 @@
/* The buffer wasn't large enough; return how much we need */
*SetSize = AnsiSize;
ErrorCode = WSAEFAULT;
- goto error;
+ goto Exit;
}
/* Build the relative unicode buffer */
ErrorCode = WSABuildQuerySetBufferA(AnsiCopy, *SetSize, AnsiSet);
-error:
+Exit:
/* Free the Ansi copy if we had one */
if (UnicodeCopy) HeapFree(WsSockHeap, 0, UnicodeCopy);