From 5f55f154bf5609507757f174bd3bf5ce22495067 Mon Sep 17 00:00:00 2001 From: Michael Stefaniuc Date: Wed, 5 Nov 2008 23:04:51 +0100 Subject: [PATCH] shlwapi: Remove superfluous casts of/to void pointers. --- dlls/shlwapi/clist.c | 24 ++++++++++-------------- dlls/shlwapi/istream.c | 2 +- dlls/shlwapi/ordinal.c | 2 +- dlls/shlwapi/reg.c | 22 +++++++++++----------- dlls/shlwapi/string.c | 4 ++-- dlls/shlwapi/tests/string.c | 4 ++-- dlls/shlwapi/thread.c | 2 +- 7 files changed, 28 insertions(+), 32 deletions(-) diff --git a/dlls/shlwapi/clist.c b/dlls/shlwapi/clist.c index 2fa53cd67ab..52bee37c9e4 100644 --- a/dlls/shlwapi/clist.c +++ b/dlls/shlwapi/clist.c @@ -91,8 +91,7 @@ HRESULT WINAPI SHAddDataBlock(LPDBLIST* lppList, const DATABLOCK_HEADER *lpNewIt if(!*lppList) { /* An empty list. Allocate space for terminal ulSize also */ - *lppList = (LPDATABLOCK_HEADER)LocalAlloc(LMEM_ZEROINIT, - ulSize + sizeof(ULONG)); + *lppList = LocalAlloc(LMEM_ZEROINIT, ulSize + sizeof(ULONG)); lpInsertAt = *lppList; } else @@ -109,8 +108,7 @@ HRESULT WINAPI SHAddDataBlock(LPDBLIST* lppList, const DATABLOCK_HEADER *lpNewIt } /* Increase the size of the list */ - lpIter = (LPDATABLOCK_HEADER)LocalReAlloc((HLOCAL)*lppList, - ulTotalSize + ulSize+sizeof(ULONG), + lpIter = LocalReAlloc(*lppList, ulTotalSize + ulSize+sizeof(ULONG), LMEM_ZEROINIT | LMEM_MOVEABLE); if(lpIter) { @@ -247,7 +245,7 @@ HRESULT WINAPI SHReadDataBlockList(IStream* lpStream, LPDBLIST* lppList) if(*lppList) { /* Free any existing list */ - LocalFree((HLOCAL)*lppList); + LocalFree(*lppList); *lppList = NULL; } @@ -283,10 +281,9 @@ HRESULT WINAPI SHReadDataBlockList(IStream* lpStream, LPDBLIST* lppList) LPDATABLOCK_HEADER lpTemp; if (pItem == bBuff) - lpTemp = (LPDATABLOCK_HEADER)LocalAlloc(LMEM_ZEROINIT, ulSize); + lpTemp = LocalAlloc(LMEM_ZEROINIT, ulSize); else - lpTemp = (LPDATABLOCK_HEADER)LocalReAlloc((HLOCAL)pItem, ulSize, - LMEM_ZEROINIT|LMEM_MOVEABLE); + lpTemp = LocalReAlloc(pItem, ulSize, LMEM_ZEROINIT|LMEM_MOVEABLE); if(!lpTemp) { @@ -312,7 +309,7 @@ HRESULT WINAPI SHReadDataBlockList(IStream* lpStream, LPDBLIST* lppList) /* If we allocated space, free it */ if(pItem != bBuff) - LocalFree((HLOCAL)pItem); + LocalFree(pItem); return hRet; } @@ -336,7 +333,7 @@ VOID WINAPI SHFreeDataBlockList(LPDBLIST lpList) TRACE("(%p)\n", lpList); if (lpList) - LocalFree((HLOCAL)lpList); + LocalFree(lpList); } /************************************************************************* @@ -389,20 +386,19 @@ BOOL WINAPI SHRemoveDataBlock(LPDBLIST* lppList, DWORD dwSignature) lpList = NextItem(lpList); /* Resize the list */ - ulNewSize = LocalSize((HLOCAL)*lppList) - lpItem->cbSize; + ulNewSize = LocalSize(*lppList) - lpItem->cbSize; /* Copy following elements over lpItem */ memmove(lpItem, lpNext, (char *)lpList - (char *)lpNext + sizeof(ULONG)); if(ulNewSize <= sizeof(ULONG)) { - LocalFree((HLOCAL)*lppList); + LocalFree(*lppList); *lppList = NULL; /* Removed the last element */ } else { - lpList = (LPDATABLOCK_HEADER)LocalReAlloc((HLOCAL)*lppList, ulNewSize, - LMEM_ZEROINIT|LMEM_MOVEABLE); + lpList = LocalReAlloc(*lppList, ulNewSize, LMEM_ZEROINIT|LMEM_MOVEABLE); if(lpList) *lppList = lpList; } diff --git a/dlls/shlwapi/istream.c b/dlls/shlwapi/istream.c index c5c8c06b158..1d11c373117 100644 --- a/dlls/shlwapi/istream.c +++ b/dlls/shlwapi/istream.c @@ -101,7 +101,7 @@ static ULONG WINAPI IStream_fnRelease(IStream *iface) if (!refCount) { IStream_fnCommit(iface, 0); /* If ever buffered, this will be needed */ - LocalFree((HLOCAL)This->lpszPath); + LocalFree(This->lpszPath); CloseHandle(This->hFile); HeapFree(GetProcessHeap(), 0, This); } diff --git a/dlls/shlwapi/ordinal.c b/dlls/shlwapi/ordinal.c index be6b0da8c80..1d3d6419eca 100644 --- a/dlls/shlwapi/ordinal.c +++ b/dlls/shlwapi/ordinal.c @@ -4335,7 +4335,7 @@ INT WINAPIV ShellMessageBoxWrapW(HINSTANCE hInstance, HWND hWnd, LPCWSTR lpText, va_end(args); ret = MessageBoxW(hWnd, pszTemp, pszTitle, uType); - LocalFree((HLOCAL)pszTemp); + LocalFree(pszTemp); return ret; } diff --git a/dlls/shlwapi/reg.c b/dlls/shlwapi/reg.c index 9239824b1a5..07384ea5900 100644 --- a/dlls/shlwapi/reg.c +++ b/dlls/shlwapi/reg.c @@ -68,8 +68,8 @@ HRESULT WINAPI SHRegGetCLSIDKeyW(REFGUID,LPCWSTR,BOOL,BOOL,PHKEY); */ static HKEY WINAPI REG_GetHKEYFromHUSKEY(HUSKEY hUSKey, BOOL which) { - HKEY test = (HKEY) hUSKey; - LPSHUSKEY mihk = (LPSHUSKEY) hUSKey; + HKEY test = hUSKey; + LPSHUSKEY mihk = hUSKey; if ((test == HKEY_CLASSES_ROOT) || (test == HKEY_CURRENT_CONFIG) || @@ -174,7 +174,7 @@ LONG WINAPI SHRegOpenUSKeyW(LPCWSTR Path, REGSAM AccessType, HUSKEY hRelativeUSK TRACE("HUSKEY=%p\n", hKey); if (phNewUSKey) - *phNewUSKey = (HUSKEY)hKey; + *phNewUSKey = hKey; return ERROR_SUCCESS; } @@ -1398,21 +1398,21 @@ DWORD WINAPI SHQueryValueExA( HKEY hKey, LPCSTR lpszValue, char cNull = '\0'; nBytesToAlloc = dwUnExpDataLen; - szData = (LPSTR) LocalAlloc(LMEM_ZEROINIT, nBytesToAlloc); + szData = LocalAlloc(LMEM_ZEROINIT, nBytesToAlloc); RegQueryValueExA (hKey, lpszValue, lpReserved, NULL, (LPBYTE)szData, &nBytesToAlloc); dwExpDataLen = ExpandEnvironmentStringsA(szData, &cNull, 1); dwUnExpDataLen = max(nBytesToAlloc, dwExpDataLen); - LocalFree((HLOCAL) szData); + LocalFree(szData); } else { nBytesToAlloc = (lstrlenA(pvData)+1) * sizeof (CHAR); - szData = (LPSTR) LocalAlloc(LMEM_ZEROINIT, nBytesToAlloc ); + szData = LocalAlloc(LMEM_ZEROINIT, nBytesToAlloc); lstrcpyA(szData, pvData); dwExpDataLen = ExpandEnvironmentStringsA(szData, pvData, *pcbData / sizeof(CHAR)); if (dwExpDataLen > *pcbData) dwRet = ERROR_MORE_DATA; dwUnExpDataLen = max(nBytesToAlloc, dwExpDataLen); - LocalFree((HLOCAL) szData); + LocalFree(szData); } } @@ -1459,21 +1459,21 @@ DWORD WINAPI SHQueryValueExW(HKEY hKey, LPCWSTR lpszValue, WCHAR cNull = '\0'; nBytesToAlloc = dwUnExpDataLen; - szData = (LPWSTR) LocalAlloc(LMEM_ZEROINIT, nBytesToAlloc); + szData = LocalAlloc(LMEM_ZEROINIT, nBytesToAlloc); RegQueryValueExW (hKey, lpszValue, lpReserved, NULL, (LPBYTE)szData, &nBytesToAlloc); dwExpDataLen = ExpandEnvironmentStringsW(szData, &cNull, 1); dwUnExpDataLen = max(nBytesToAlloc, dwExpDataLen); - LocalFree((HLOCAL) szData); + LocalFree(szData); } else { nBytesToAlloc = (lstrlenW(pvData) + 1) * sizeof(WCHAR); - szData = (LPWSTR) LocalAlloc(LMEM_ZEROINIT, nBytesToAlloc ); + szData = LocalAlloc(LMEM_ZEROINIT, nBytesToAlloc); lstrcpyW(szData, pvData); dwExpDataLen = ExpandEnvironmentStringsW(szData, pvData, *pcbData/sizeof(WCHAR) ); if (dwExpDataLen > *pcbData) dwRet = ERROR_MORE_DATA; dwUnExpDataLen = max(nBytesToAlloc, dwExpDataLen); - LocalFree((HLOCAL) szData); + LocalFree(szData); } } diff --git a/dlls/shlwapi/string.c b/dlls/shlwapi/string.c index 89cf5efc237..bc961dadb8c 100644 --- a/dlls/shlwapi/string.c +++ b/dlls/shlwapi/string.c @@ -911,7 +911,7 @@ LPSTR WINAPI StrDupA(LPCSTR lpszStr) TRACE("(%s)\n",debugstr_a(lpszStr)); iLen = lpszStr ? strlen(lpszStr) + 1 : 1; - lpszRet = (LPSTR)LocalAlloc(LMEM_FIXED, iLen); + lpszRet = LocalAlloc(LMEM_FIXED, iLen); if (lpszRet) { @@ -936,7 +936,7 @@ LPWSTR WINAPI StrDupW(LPCWSTR lpszStr) TRACE("(%s)\n",debugstr_w(lpszStr)); iLen = (lpszStr ? strlenW(lpszStr) + 1 : 1) * sizeof(WCHAR); - lpszRet = (LPWSTR)LocalAlloc(LMEM_FIXED, iLen); + lpszRet = LocalAlloc(LMEM_FIXED, iLen); if (lpszRet) { diff --git a/dlls/shlwapi/tests/string.c b/dlls/shlwapi/tests/string.c index 4d9c17c2c77..34ab7ba9a70 100644 --- a/dlls/shlwapi/tests/string.c +++ b/dlls/shlwapi/tests/string.c @@ -486,7 +486,7 @@ static void test_StrDupA(void) if (lpszStr) { ok(!strcmp(result->byte_size_64, lpszStr), "Copied string wrong\n"); - LocalFree((HLOCAL)lpszStr); + LocalFree(lpszStr); } result++; } @@ -496,7 +496,7 @@ static void test_StrDupA(void) */ lpszStr = StrDupA(NULL); ok(lpszStr == NULL || *lpszStr == '\0', "NULL string returned %p\n", lpszStr); - LocalFree((HLOCAL)lpszStr); + LocalFree(lpszStr); } static void test_StrFormatByteSize64A(void) diff --git a/dlls/shlwapi/thread.c b/dlls/shlwapi/thread.c index 9aa56b50f5a..cfe6615cd69 100644 --- a/dlls/shlwapi/thread.c +++ b/dlls/shlwapi/thread.c @@ -140,7 +140,7 @@ HRESULT WINAPI SHGetThreadRef(IUnknown **lppUnknown) if (!lppUnknown || SHLWAPI_ThreadRef_index == TLS_OUT_OF_INDEXES) return E_NOINTERFACE; - *lppUnknown = (IUnknown*)TlsGetValue(SHLWAPI_ThreadRef_index); + *lppUnknown = TlsGetValue(SHLWAPI_ThreadRef_index); if (!*lppUnknown) return E_NOINTERFACE;