From 7b89ff88e85a95f1e16420d25654887c71adcc6b Mon Sep 17 00:00:00 2001 From: James Hawkins Date: Fri, 6 Oct 2006 18:06:26 -0700 Subject: [PATCH] janitorial: Remove redundant NULL checks before SHFree. --- dlls/shell32/brsfolder.c | 4 +--- dlls/shell32/changenotify.c | 4 ++-- dlls/shell32/cpanelfolder.c | 3 +-- dlls/shell32/dataobject.c | 5 +---- dlls/shell32/pidl.c | 13 ++++--------- dlls/shell32/shell.c | 8 ++++---- dlls/shell32/shell32_main.c | 3 +-- dlls/shell32/shfldr_desktop.c | 6 ++---- dlls/shell32/shfldr_fs.c | 16 +++++----------- dlls/shell32/shfldr_mycomp.c | 3 +-- dlls/shell32/shlexec.c | 14 +++++++------- dlls/shell32/shlmenu.c | 11 +++-------- dlls/shell32/shlview.c | 8 ++------ dlls/shell32/shv_item_cmenu.c | 3 +-- dlls/shell32/trash.c | 3 +-- 15 files changed, 36 insertions(+), 68 deletions(-) diff --git a/dlls/shell32/brsfolder.c b/dlls/shell32/brsfolder.c index 30ee718d2b7..aa53ff0c407 100644 --- a/dlls/shell32/brsfolder.c +++ b/dlls/shell32/brsfolder.c @@ -354,9 +354,7 @@ static void FillTreeView( browse_info *info, IShellFolder * lpsf, done: ReleaseCapture(); SetCursor(LoadCursorW(0, (LPWSTR)IDC_ARROW)); - - if (pidlTemp) - SHFree(pidlTemp); + SHFree(pidlTemp); } static inline BOOL PIDLIsType(LPCITEMIDLIST pidl, PIDLTYPE type) diff --git a/dlls/shell32/changenotify.c b/dlls/shell32/changenotify.c index 3f3b612a63b..e257aa21e4a 100644 --- a/dlls/shell32/changenotify.c +++ b/dlls/shell32/changenotify.c @@ -402,8 +402,8 @@ void WINAPI SHChangeNotify(LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID /* if we allocated it, free it. The ANSI flag is also set in its Unicode sibling. */ if ((typeFlag & SHCNF_PATHA) || (typeFlag & SHCNF_PRINTERA)) { - if (Pidls[0]) SHFree((LPITEMIDLIST)Pidls[0]); - if (Pidls[1]) SHFree((LPITEMIDLIST)Pidls[1]); + SHFree((LPITEMIDLIST)Pidls[0]); + SHFree((LPITEMIDLIST)Pidls[1]); } } diff --git a/dlls/shell32/cpanelfolder.c b/dlls/shell32/cpanelfolder.c index 7767b8d3efb..7601e8d0cf5 100644 --- a/dlls/shell32/cpanelfolder.c +++ b/dlls/shell32/cpanelfolder.c @@ -203,8 +203,7 @@ static ULONG WINAPI ISF_ControlPanel_fnRelease(IShellFolder2 * iface) if (!refCount) { TRACE("-- destroying IShellFolder(%p)\n", This); - if (This->pidlRoot) - SHFree(This->pidlRoot); + SHFree(This->pidlRoot); LocalFree((HLOCAL) This); } return refCount; diff --git a/dlls/shell32/dataobject.c b/dlls/shell32/dataobject.c index 0dcd9b4fc5a..1d9c2c3f8ed 100644 --- a/dlls/shell32/dataobject.c +++ b/dlls/shell32/dataobject.c @@ -97,10 +97,7 @@ static ULONG WINAPI IEnumFORMATETC_fnRelease(LPENUMFORMATETC iface) if (!refCount) { TRACE(" destroying IEnumFORMATETC(%p)\n",This); - if (This->pFmt) - { - SHFree (This->pFmt); - } + SHFree (This->pFmt); HeapFree(GetProcessHeap(),0,This); return 0; } diff --git a/dlls/shell32/pidl.c b/dlls/shell32/pidl.c index 10d87bb4d95..b5a59af764b 100644 --- a/dlls/shell32/pidl.c +++ b/dlls/shell32/pidl.c @@ -291,11 +291,8 @@ HRESULT WINAPI ILLoadFromStream (IStream * pStream, LPITEMIDLIST * ppPidl) TRACE_(shell)("%p %p\n", pStream , ppPidl); - if (*ppPidl) - { - SHFree(*ppPidl); - *ppPidl = NULL; - } + SHFree(*ppPidl); + *ppPidl = NULL; IStream_AddRef (pStream); @@ -865,8 +862,7 @@ LPITEMIDLIST WINAPI ILAppend(LPITEMIDLIST pidl, LPCITEMIDLIST item, BOOL bEnd) if (_ILIsDesktop(pidl)) { idlRet = ILClone(item); - if (pidl) - SHFree (pidl); + SHFree (pidl); return idlRet; } @@ -896,8 +892,7 @@ LPITEMIDLIST WINAPI ILAppend(LPITEMIDLIST pidl, LPCITEMIDLIST item, BOOL bEnd) void WINAPI ILFree(LPITEMIDLIST pidl) { TRACE("(pidl=%p)\n",pidl); - if (pidl) - SHFree(pidl); + SHFree(pidl); } /************************************************************************* diff --git a/dlls/shell32/shell.c b/dlls/shell32/shell.c index 533ccdb63ee..eaa1974995f 100644 --- a/dlls/shell32/shell.c +++ b/dlls/shell32/shell.c @@ -628,10 +628,10 @@ HINSTANCE16 WINAPI ShellExecute16( HWND16 hWnd, LPCSTR lpOperation, SHELL_execute( &seiW, SHELL_Execute16 ); - if (wVerb) SHFree(wVerb); - if (wFile) SHFree(wFile); - if (wParameters) SHFree(wParameters); - if (wDirectory) SHFree(wDirectory); + SHFree(wVerb); + SHFree(wFile); + SHFree(wParameters); + SHFree(wDirectory); return HINSTANCE_16(seiW.hInstApp); } diff --git a/dlls/shell32/shell32_main.c b/dlls/shell32/shell32_main.c index 5c6dc61fed0..641e263efb9 100644 --- a/dlls/shell32/shell32_main.c +++ b/dlls/shell32/shell32_main.c @@ -614,8 +614,7 @@ DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes, if (hr != S_OK) ret = FALSE; - if (pidlLast) - SHFree(pidlLast); + SHFree(pidlLast); #ifdef MORE_DEBUG TRACE ("icon=%p index=0x%08x attr=0x%08lx name=%s type=%s ret=0x%08lx\n", diff --git a/dlls/shell32/shfldr_desktop.c b/dlls/shell32/shfldr_desktop.c index 3d717d9558b..f2be4beec93 100644 --- a/dlls/shell32/shfldr_desktop.c +++ b/dlls/shell32/shfldr_desktop.c @@ -137,10 +137,8 @@ static ULONG WINAPI ISF_Desktop_fnRelease (IShellFolder2 * iface) if (!refCount) { TRACE ("-- destroying IShellFolder(%p)\n", This); - if (This->pidlRoot) - SHFree (This->pidlRoot); - if (This->sPathTarget) - SHFree (This->sPathTarget); + SHFree (This->pidlRoot); + SHFree (This->sPathTarget); LocalFree ((HLOCAL) This); return 0; } diff --git a/dlls/shell32/shfldr_fs.c b/dlls/shell32/shfldr_fs.c index 8bd6eaf6ebe..3c05e710063 100644 --- a/dlls/shell32/shfldr_fs.c +++ b/dlls/shell32/shfldr_fs.c @@ -194,10 +194,8 @@ static ULONG WINAPI IUnknown_fnRelease (IUnknown * iface) if (!refCount) { TRACE ("-- destroying IShellFolder(%p)\n", This); - if (This->pidlRoot) - SHFree (This->pidlRoot); - if (This->sPathTarget) - SHFree (This->sPathTarget); + SHFree (This->pidlRoot); + SHFree (This->sPathTarget); LocalFree ((HLOCAL) This); } return refCount; @@ -1380,15 +1378,11 @@ IFSFldr_PersistFolder3_Initialize (IPersistFolder3 * iface, LPCITEMIDLIST pidl) TRACE ("(%p)->(%p)\n", This, pidl); - if (This->pidlRoot) - SHFree (This->pidlRoot); /* free the old pidl */ + SHFree (This->pidlRoot); /* free the old pidl */ This->pidlRoot = ILClone (pidl); /* set my pidl */ - if (This->sPathTarget) - { - SHFree (This->sPathTarget); - This->sPathTarget = NULL; - } + SHFree (This->sPathTarget); + This->sPathTarget = NULL; /* set my path */ if (SHGetPathFromIDListW (pidl, wszTemp)) { diff --git a/dlls/shell32/shfldr_mycomp.c b/dlls/shell32/shfldr_mycomp.c index c9a5c07e49b..c842c7e4027 100644 --- a/dlls/shell32/shfldr_mycomp.c +++ b/dlls/shell32/shfldr_mycomp.c @@ -186,8 +186,7 @@ static ULONG WINAPI ISF_MyComputer_fnRelease (IShellFolder2 * iface) if (!refCount) { TRACE ("-- destroying IShellFolder(%p)\n", This); - if (This->pidlRoot) - SHFree (This->pidlRoot); + SHFree (This->pidlRoot); LocalFree ((HLOCAL) This); } return refCount; diff --git a/dlls/shell32/shlexec.c b/dlls/shell32/shlexec.c index 6ca0b1988f3..f5704c3e4ec 100644 --- a/dlls/shell32/shlexec.c +++ b/dlls/shell32/shlexec.c @@ -882,8 +882,8 @@ HINSTANCE WINAPI FindExecutableA(LPCSTR lpFile, LPCSTR lpDirectory, LPSTR lpResu retval = FindExecutableW(wFile, wDirectory, wResult); WideCharToMultiByte(CP_ACP, 0, wResult, -1, lpResult, MAX_PATH, NULL, NULL); - if (wFile) SHFree( wFile ); - if (wDirectory) SHFree( wDirectory ); + SHFree( wFile ); + SHFree( wDirectory ); TRACE("returning %s\n", lpResult); return retval; @@ -1580,11 +1580,11 @@ BOOL WINAPI ShellExecuteExA (LPSHELLEXECUTEINFOA sei) if (sei->fMask & SEE_MASK_NOCLOSEPROCESS) sei->hProcess = seiW.hProcess; - if (wVerb) SHFree(wVerb); - if (wFile) SHFree(wFile); - if (wParameters) SHFree(wParameters); - if (wDirectory) SHFree(wDirectory); - if (wClass) SHFree(wClass); + SHFree(wVerb); + SHFree(wFile); + SHFree(wParameters); + SHFree(wDirectory); + SHFree(wClass); return ret; } diff --git a/dlls/shell32/shlmenu.c b/dlls/shell32/shlmenu.c index 42cec7a7f23..065e3c14de5 100644 --- a/dlls/shell32/shlmenu.c +++ b/dlls/shell32/shlmenu.c @@ -115,9 +115,7 @@ static LPFMINFO FM_SetMenuParameter( menudata = FM_GetMenuInfo(hmenu); - if ( menudata->pidl) - { SHFree(menudata->pidl); - } + SHFree(menudata->pidl); menudata->uID = uID; menudata->pidl = ILClone(pidl); @@ -299,9 +297,7 @@ void WINAPI FileMenu_Destroy (HMENU hmenu) menudata = FM_GetMenuInfo(hmenu); - if ( menudata->pidl) - { SHFree( menudata->pidl); - } + SHFree( menudata->pidl); HeapFree(GetProcessHeap(), 0, menudata); DestroyMenu (hmenu); @@ -692,8 +688,7 @@ BOOL WINAPI FileMenu_DeleteAllItems (HMENU hmenu) for (i = 0; i < GetMenuItemCount( hmenu ); i++) { GetMenuItemInfoW(hmenu, i, TRUE, &mii ); - if (mii.dwItemData) - SHFree((LPFMINFO)mii.dwItemData); + SHFree((LPFMINFO)mii.dwItemData); if (mii.hSubMenu) FileMenu_Destroy(mii.hSubMenu); diff --git a/dlls/shell32/shlview.c b/dlls/shell32/shlview.c index d605fca068f..914071be5c2 100644 --- a/dlls/shell32/shlview.c +++ b/dlls/shell32/shlview.c @@ -811,10 +811,7 @@ static UINT ShellView_GetSelections(IShellViewImpl * This) LVITEMA lvItem; UINT i = 0; - if (This->apidl) - { - SHFree(This->apidl); - } + SHFree(This->apidl); This->cidl = ListView_GetSelectedCount(This->hWndList); This->apidl = (LPITEMIDLIST*)SHAlloc(This->cidl * sizeof(LPITEMIDLIST)); @@ -1713,8 +1710,7 @@ static ULONG WINAPI IShellView_fnRelease(IShellView * iface) if(This->pSF2Parent) IShellFolder2_Release(This->pSF2Parent); - if(This->apidl) - SHFree(This->apidl); + SHFree(This->apidl); if(This->pAdvSink) IAdviseSink_Release(This->pAdvSink); diff --git a/dlls/shell32/shv_item_cmenu.c b/dlls/shell32/shv_item_cmenu.c index 7d3d08cc491..ca2d593fcd5 100644 --- a/dlls/shell32/shv_item_cmenu.c +++ b/dlls/shell32/shv_item_cmenu.c @@ -166,8 +166,7 @@ static ULONG WINAPI ISvItemCm_fnRelease(IContextMenu2 *iface) if(This->pSFParent) IShellFolder_Release(This->pSFParent); - if(This->pidl) - SHFree(This->pidl); + SHFree(This->pidl); /*make sure the pidl is freed*/ _ILFreeaPidl(This->apidl, This->cidl); diff --git a/dlls/shell32/trash.c b/dlls/shell32/trash.c index fc0ce42b24a..4fe43e56026 100644 --- a/dlls/shell32/trash.c +++ b/dlls/shell32/trash.c @@ -377,8 +377,7 @@ HRESULT TRASH_UnpackItemID(LPCSHITEMID id, TRASH_ELEMENT *element, WIN32_FIND_DA void TRASH_DisposeElement(TRASH_ELEMENT *element) { - if (element) - SHFree(element->filename); + SHFree(element->filename); } HRESULT TRASH_GetDetails(const TRASH_ELEMENT *element, WIN32_FIND_DATAW *data)