From: Hermès BÉLUSCA-MAÏTO Subject: [PATCH v2 resend] shlwapi: Fix the return value of SHAddDataBlock Message-Id: <001401d27113$8c505d40$a4f117c0$@sfr.fr> Date: Tue, 17 Jan 2017 23:46:31 +0100 Patch resend (sorry for the noise, my emailer has problems with newlines format). Herms.

Patch resend (sorry for the noise, my emailer has problems with newlines format).

Herms.

From 575db74272d5a58ca7809182254c93cf7a3824b3 Mon Sep 17 00:00:00 2001 From: Hermes Belusca-Maito Date: Tue, 17 Jan 2017 23:25:29 +0100 Subject: [PATCH v2 resend] shlwapi: Fix the return value of SHAddDataBlock Patch resent because of "formatting" issue. This patch fixes the return type and value of SHAddDataBlock. The corresponding test (shlwapi's clist) is adjusted to reflect those changes. Tested on Windows 2003 and 7. In addition I set, in SHRemoveDataBlock, the lpList pointer to NULL, to respect the fact it's a pointer, not just a number. Signed-off-by: Hermes Belusca-Maito --- dlls/shlwapi/clist.c | 14 +++++++------- dlls/shlwapi/tests/clist.c | 21 +++++++++------------ 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/dlls/shlwapi/clist.c b/dlls/shlwapi/clist.c index 52bee37..77917b3 100644 --- a/dlls/shlwapi/clist.c +++ b/dlls/shlwapi/clist.c @@ -65,19 +65,19 @@ static inline LPDATABLOCK_HEADER NextItem(LPDBLIST lpList) * the call returns S_OK but does not actually add the element. * See SHWriteDataBlockList. */ -HRESULT WINAPI SHAddDataBlock(LPDBLIST* lppList, const DATABLOCK_HEADER *lpNewItem) +BOOL WINAPI SHAddDataBlock(LPDBLIST* lppList, const DATABLOCK_HEADER *lpNewItem) { LPDATABLOCK_HEADER lpInsertAt = NULL; ULONG ulSize; TRACE("(%p,%p)\n", lppList, lpNewItem); - if(!lppList || !lpNewItem ) - return E_INVALIDARG; + if(!lppList || !lpNewItem) + return FALSE; if (lpNewItem->cbSize < sizeof(DATABLOCK_HEADER) || lpNewItem->dwSignature == CLIST_ID_CONTAINER) - return S_OK; + return FALSE; ulSize = lpNewItem->cbSize; @@ -134,9 +134,9 @@ HRESULT WINAPI SHAddDataBlock(LPDBLIST* lppList, const DATABLOCK_HEADER *lpNewIt lpInsertAt = NextItem(lpInsertAt); lpInsertAt->cbSize = 0; - return lpNewItem->cbSize; + return TRUE; } - return S_OK; + return FALSE; } /************************************************************************* @@ -354,7 +354,7 @@ VOID WINAPI SHFreeDataBlockList(LPDBLIST lpList) */ BOOL WINAPI SHRemoveDataBlock(LPDBLIST* lppList, DWORD dwSignature) { - LPDATABLOCK_HEADER lpList = 0; + LPDATABLOCK_HEADER lpList = NULL; LPDATABLOCK_HEADER lpItem = NULL; LPDATABLOCK_HEADER lpNext; ULONG ulNewSize; diff --git a/dlls/shlwapi/tests/clist.c b/dlls/shlwapi/tests/clist.c index b930470..309b333 100644 --- a/dlls/shlwapi/tests/clist.c +++ b/dlls/shlwapi/tests/clist.c @@ -218,7 +218,7 @@ static IStreamVtbl iclvt = static HMODULE SHLWAPI_hshlwapi = 0; static VOID (WINAPI *pSHLWAPI_19)(LPSHLWAPI_CLIST); -static HRESULT (WINAPI *pSHLWAPI_20)(LPSHLWAPI_CLIST*,LPCSHLWAPI_CLIST); +static BOOL (WINAPI *pSHLWAPI_20)(LPSHLWAPI_CLIST*,LPCSHLWAPI_CLIST); static BOOL (WINAPI *pSHLWAPI_21)(LPSHLWAPI_CLIST*,ULONG); static LPSHLWAPI_CLIST (WINAPI *pSHLWAPI_22)(LPSHLWAPI_CLIST,ULONG); static HRESULT (WINAPI *pSHLWAPI_17)(IStream*, SHLWAPI_CLIST*); @@ -292,6 +292,7 @@ static void test_CList(void) struct dummystream streamobj; LPSHLWAPI_CLIST list = NULL; LPCSHLWAPI_CLIST item = SHLWAPI_CLIST_items; + BOOL bRet; HRESULT hRet; LPSHLWAPI_CLIST inserted; BYTE buff[64]; @@ -312,10 +313,10 @@ static void test_CList(void) buff[sizeof(SHLWAPI_CLIST)+i] = i*2; /* Add it */ - hRet = pSHLWAPI_20(&list, inserted); - ok(hRet > S_OK, "failed list add\n"); + bRet = pSHLWAPI_20(&list, inserted); + ok(bRet == TRUE, "failed list add\n"); - if (hRet > S_OK) + if (bRet == TRUE) { ok(list && list->ulSize, "item not added\n"); @@ -390,11 +391,8 @@ static void test_CList(void) inserted = (LPSHLWAPI_CLIST)buff; inserted->ulSize = sizeof(SHLWAPI_CLIST) -1; inserted->ulId = 33; - - /* The call succeeds but the item is not inserted, except on some early - * versions which return failure. Wine behaves like later versions. - */ - pSHLWAPI_20(&list, inserted); + bRet = pSHLWAPI_20(&list, inserted); + ok(bRet == FALSE, "Expected failure\n"); inserted = pSHLWAPI_22(list, 33); ok(inserted == NULL, "inserted bad element size\n"); @@ -402,9 +400,8 @@ static void test_CList(void) inserted = (LPSHLWAPI_CLIST)buff; inserted->ulSize = 44; inserted->ulId = ~0U; - - /* See comment above, some early versions fail this call */ - pSHLWAPI_20(&list, inserted); + bRet = pSHLWAPI_20(&list, inserted); + ok(bRet == FALSE, "Expected failure\n"); item = SHLWAPI_CLIST_items; -- 2.8.1.windows.1 =