From 3f83dd2882d7249260a97f6f54cd9a107b548afd Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Wed, 25 Nov 2009 16:20:55 -0600 Subject: [PATCH 3/5] ole32: Change ReadDirEntry return type to HRESULT. --- dlls/ole32/stg_stream.c | 26 ++++++++-------- dlls/ole32/storage32.c | 72 +++++++++++++++++++++------------------------- dlls/ole32/storage32.h | 2 +- 3 files changed, 47 insertions(+), 53 deletions(-) diff --git a/dlls/ole32/stg_stream.c b/dlls/ole32/stg_stream.c index 5355594..94cd2ed 100644 --- a/dlls/ole32/stg_stream.c +++ b/dlls/ole32/stg_stream.c @@ -188,7 +188,7 @@ static void StgStreamImpl_OpenBlockChain( StgStreamImpl* This) { DirEntry currentEntry; - BOOL readSuccessful; + HRESULT hr; /* * Make sure no old object is left over. @@ -208,11 +208,11 @@ static void StgStreamImpl_OpenBlockChain( /* * Read the information from the directory entry. */ - readSuccessful = StorageImpl_ReadDirEntry(This->parentStorage->ancestorStorage, + hr = StorageImpl_ReadDirEntry(This->parentStorage->ancestorStorage, This->dirEntry, ¤tEntry); - if (readSuccessful) + if (SUCCEEDED(hr)) { This->streamSize = currentEntry.size; @@ -546,7 +546,7 @@ static HRESULT WINAPI StgStreamImpl_SetSize( StgStreamImpl* const This=(StgStreamImpl*)iface; DirEntry currentEntry; - BOOL Success; + HRESULT hr; TRACE("(%p, %d)\n", iface, libNewSize.u.LowPart); @@ -605,7 +605,7 @@ static HRESULT WINAPI StgStreamImpl_SetSize( /* * Read this stream's size to see if it's small blocks or big blocks */ - Success = StorageImpl_ReadDirEntry(This->parentStorage->ancestorStorage, + StorageImpl_ReadDirEntry(This->parentStorage->ancestorStorage, This->dirEntry, ¤tEntry); /* @@ -640,24 +640,24 @@ static HRESULT WINAPI StgStreamImpl_SetSize( if (This->smallBlockChain!=0) { - Success = SmallBlockChainStream_SetSize(This->smallBlockChain, libNewSize); + SmallBlockChainStream_SetSize(This->smallBlockChain, libNewSize); } else { - Success = BlockChainStream_SetSize(This->bigBlockChain, libNewSize); + BlockChainStream_SetSize(This->bigBlockChain, libNewSize); } /* * Write the new information about this stream to the directory entry */ - Success = StorageImpl_ReadDirEntry(This->parentStorage->ancestorStorage, + hr = StorageImpl_ReadDirEntry(This->parentStorage->ancestorStorage, This->dirEntry, ¤tEntry); currentEntry.size.u.HighPart = libNewSize.u.HighPart; currentEntry.size.u.LowPart = libNewSize.u.LowPart; - if (Success) + if (SUCCEEDED(hr)) { StorageImpl_WriteDirEntry(This->parentStorage->ancestorStorage, This->dirEntry, @@ -835,7 +835,7 @@ static HRESULT WINAPI StgStreamImpl_Stat( StgStreamImpl* const This=(StgStreamImpl*)iface; DirEntry currentEntry; - BOOL readSuccessful; + HRESULT hr; TRACE("%p %p %d\n", This, pstatstg, grfStatFlag); @@ -852,11 +852,11 @@ static HRESULT WINAPI StgStreamImpl_Stat( /* * Read the information from the directory entry. */ - readSuccessful = StorageImpl_ReadDirEntry(This->parentStorage->ancestorStorage, + hr = StorageImpl_ReadDirEntry(This->parentStorage->ancestorStorage, This->dirEntry, ¤tEntry); - if (readSuccessful) + if (SUCCEEDED(hr)) { StorageUtl_CopyDirEntryToSTATSTG(This->parentStorage, pstatstg, @@ -873,7 +873,7 @@ static HRESULT WINAPI StgStreamImpl_Stat( } WARN("failed to read entry\n"); - return E_FAIL; + return hr; } /*** diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c index 8173b84..68de806 100644 --- a/dlls/ole32/storage32.c +++ b/dlls/ole32/storage32.c @@ -673,7 +673,6 @@ static HRESULT WINAPI StorageBaseImpl_Stat( { StorageBaseImpl *This = (StorageBaseImpl *)iface; DirEntry currentEntry; - BOOL readSuccessful; HRESULT res = STG_E_UNKNOWN; TRACE("(%p, %p, %x)\n", @@ -691,12 +690,12 @@ static HRESULT WINAPI StorageBaseImpl_Stat( goto end; } - readSuccessful = StorageImpl_ReadDirEntry( + res = StorageImpl_ReadDirEntry( This->ancestorStorage, This->storageDirEntry, ¤tEntry); - if (readSuccessful) + if (SUCCEEDED(res)) { StorageUtl_CopyDirEntryToSTATSTG( This, @@ -706,13 +705,8 @@ static HRESULT WINAPI StorageBaseImpl_Stat( pstatstg->grfMode = This->openFlags; pstatstg->grfStateBits = This->stateBits; - - res = S_OK; - goto end; } - res = E_FAIL; - end: if (res == S_OK) { @@ -962,19 +956,18 @@ static HRESULT WINAPI StorageBaseImpl_SetClass( REFCLSID clsid) /* [in] */ { StorageBaseImpl *This = (StorageBaseImpl *)iface; - HRESULT hRes = E_FAIL; + HRESULT hRes; DirEntry currentEntry; - BOOL success; TRACE("(%p, %p)\n", iface, clsid); if (!This->ancestorStorage) return STG_E_REVERTED; - success = StorageImpl_ReadDirEntry(This->ancestorStorage, - This->storageDirEntry, - ¤tEntry); - if (success) + hRes = StorageImpl_ReadDirEntry(This->ancestorStorage, + This->storageDirEntry, + ¤tEntry); + if (SUCCEEDED(hRes)) { currentEntry.clsid = *clsid; @@ -2065,13 +2058,15 @@ static HRESULT removeFromTree( DirRef deletedIndex) { HRESULT hr = S_OK; - BOOL res = TRUE; DirEntry entryToDelete; DirEntry parentEntry; DirRef parentEntryRef; ULONG typeOfRelation; - res = StorageImpl_ReadDirEntry(This, deletedIndex, &entryToDelete); + hr = StorageImpl_ReadDirEntry(This, deletedIndex, &entryToDelete); + + if (hr != S_OK) + return hr; /* * Find the element that links to the one we want to delete. @@ -2110,13 +2105,13 @@ static HRESULT removeFromTree( do { - res = StorageImpl_ReadDirEntry( + hr = StorageImpl_ReadDirEntry( This, newRightChildParent, &newRightChildParentEntry); - if (!res) + if (FAILED(hr)) { - return E_FAIL; + return hr; } if (newRightChildParentEntry.rightChild != DIRENTRY_NULL) @@ -2230,7 +2225,6 @@ static HRESULT StorageImpl_Construct( StorageImpl* This; HRESULT hr = S_OK; DirEntry currentEntry; - BOOL readSuccessful; DirRef currentEntryRef; if ( FAILED( validateSTGM(openFlags) )) @@ -2405,12 +2399,12 @@ static HRESULT StorageImpl_Construct( do { - readSuccessful = StorageImpl_ReadDirEntry( + hr = StorageImpl_ReadDirEntry( This, currentEntryRef, ¤tEntry); - if (readSuccessful) + if (SUCCEEDED(hr)) { if ( (currentEntry.sizeOfNameString != 0 ) && (currentEntry.stgType == STGTY_ROOT) ) @@ -2421,9 +2415,9 @@ static HRESULT StorageImpl_Construct( currentEntryRef++; - } while (readSuccessful && (This->base.storageDirEntry == DIRENTRY_NULL) ); + } while (SUCCEEDED(hr) && (This->base.storageDirEntry == DIRENTRY_NULL) ); - if (!readSuccessful) + if (FAILED(hr)) { hr = STG_E_READFAULT; goto end; @@ -3247,7 +3241,7 @@ void UpdateRawDirEntry(BYTE *buffer, const DirEntry *newData) * * This method will read the specified directory entry. */ -BOOL StorageImpl_ReadDirEntry( +HRESULT StorageImpl_ReadDirEntry( StorageImpl* This, DirRef index, DirEntry* buffer) @@ -3326,7 +3320,7 @@ BOOL StorageImpl_ReadDirEntry( buffer->size.u.HighPart = 0; } - return SUCCEEDED(readRes) ? TRUE : FALSE; + return readRes; } /********************************************************************* @@ -3858,7 +3852,7 @@ static HRESULT WINAPI IEnumSTATSTGImpl_Reset( IEnumSTATSTGImpl* const This=(IEnumSTATSTGImpl*)iface; DirEntry storageEntry; - BOOL readSuccessful; + HRESULT hr; /* * Re-initialize the search stack to an empty stack @@ -3868,12 +3862,12 @@ static HRESULT WINAPI IEnumSTATSTGImpl_Reset( /* * Read the storage entry from the top-level storage. */ - readSuccessful = StorageImpl_ReadDirEntry( + hr = StorageImpl_ReadDirEntry( This->parentStorage, This->storageDirEntry, &storageEntry); - if (readSuccessful) + if (SUCCEEDED(hr)) { assert(storageEntry.sizeOfNameString!=0); @@ -3883,7 +3877,7 @@ static HRESULT WINAPI IEnumSTATSTGImpl_Reset( IEnumSTATSTGImpl_PushSearchNode(This, storageEntry.dirRootEntry); } - return S_OK; + return hr; } static HRESULT WINAPI IEnumSTATSTGImpl_Clone( @@ -3934,7 +3928,7 @@ static void IEnumSTATSTGImpl_PushSearchNode( DirRef nodeToPush) { DirEntry storageEntry; - BOOL readSuccessful; + HRESULT hr; /* * First, make sure we're not trying to push an unexisting node. @@ -3962,12 +3956,12 @@ static void IEnumSTATSTGImpl_PushSearchNode( /* * Read the storage entry from the top-level storage. */ - readSuccessful = StorageImpl_ReadDirEntry( + hr = StorageImpl_ReadDirEntry( This->parentStorage, nodeToPush, &storageEntry); - if (readSuccessful) + if (SUCCEEDED(hr)) { assert(storageEntry.sizeOfNameString!=0); @@ -4327,19 +4321,19 @@ void BlockChainStream_Destroy(BlockChainStream* This) static ULONG BlockChainStream_GetHeadOfChain(BlockChainStream* This) { DirEntry chainEntry; - BOOL readSuccessful; + HRESULT hr; if (This->headOfStreamPlaceHolder != 0) return *(This->headOfStreamPlaceHolder); if (This->ownerDirEntry != DIRENTRY_NULL) { - readSuccessful = StorageImpl_ReadDirEntry( + hr = StorageImpl_ReadDirEntry( This->parentStorage, This->ownerDirEntry, &chainEntry); - if (readSuccessful) + if (SUCCEEDED(hr)) { return chainEntry.startingBlock; } @@ -4855,19 +4849,19 @@ static ULONG SmallBlockChainStream_GetHeadOfChain( SmallBlockChainStream* This) { DirEntry chainEntry; - BOOL readSuccessful; + HRESULT hr; if (This->headOfStreamPlaceHolder != NULL) return *(This->headOfStreamPlaceHolder); if (This->ownerDirEntry) { - readSuccessful = StorageImpl_ReadDirEntry( + hr = StorageImpl_ReadDirEntry( This->parentStorage, This->ownerDirEntry, &chainEntry); - if (readSuccessful) + if (SUCCEEDED(hr)) { return chainEntry.startingBlock; } diff --git a/dlls/ole32/storage32.h b/dlls/ole32/storage32.h index 45fffac..5d6f651 100644 --- a/dlls/ole32/storage32.h +++ b/dlls/ole32/storage32.h @@ -331,7 +331,7 @@ HRESULT StorageImpl_WriteRawDirEntry( ULONG index, const BYTE *buffer); -BOOL StorageImpl_ReadDirEntry( +HRESULT StorageImpl_ReadDirEntry( StorageImpl* This, DirRef index, DirEntry* buffer); -- 1.6.3.3