Michael Stefaniuc : shlwapi/tests: Avoid casts from COM object to interface.

Alexandre Julliard julliard at winehq.org
Thu Aug 26 15:22:30 CDT 2021


Module: wine
Branch: master
Commit: 678ae0f925d4618b908817c36e6db92913b2b4d5
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=678ae0f925d4618b908817c36e6db92913b2b4d5

Author: Michael Stefaniuc <mstefani at winehq.org>
Date:   Thu Aug 26 09:45:22 2021 +0200

shlwapi/tests: Avoid casts from COM object to interface.

Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/shlwapi/tests/ordinal.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/dlls/shlwapi/tests/ordinal.c b/dlls/shlwapi/tests/ordinal.c
index 919cac8563f..bf43d35b1c2 100644
--- a/dlls/shlwapi/tests/ordinal.c
+++ b/dlls/shlwapi/tests/ordinal.c
@@ -1423,7 +1423,7 @@ static HRESULT WINAPI Contain_FindConnectionPoint(
     else
     {
         *ppCP = iface->pt[0];
-        IUnknown_AddRef((IUnknown*)*ppCP);
+        IConnectionPoint_AddRef(*ppCP);
     }
 
     return S_OK;
@@ -1459,7 +1459,8 @@ static void test_IConnectionPoint(void)
     dispatch->IDispatch_iface.lpVtbl = &disp_vtbl;
     dispatch->refCount = 1;
 
-    rc = pConnectToConnectionPoint((IUnknown*)dispatch, &IID_NULL, TRUE, (IUnknown*)container, &cookie, &point);
+    rc = pConnectToConnectionPoint((IUnknown*)&dispatch->IDispatch_iface, &IID_NULL, TRUE,
+                                   (IUnknown*)&container->IConnectionPointContainer_iface, &cookie, &point);
     ok(rc == S_OK, "pConnectToConnectionPoint failed with %x\n",rc);
     ok(point != NULL, "returned ConnectionPoint is NULL\n");
     ok(cookie != 0xffffffff, "invalid cookie returned\n");
@@ -1475,15 +1476,16 @@ static void test_IConnectionPoint(void)
     rc = pIConnectionPoint_SimpleInvoke(point,0xa1,&params);
     ok(rc == S_OK, "pConnectToConnectionPoint failed with %x\n",rc);
 
-    rc = pConnectToConnectionPoint(NULL, &IID_NULL, FALSE, (IUnknown*)container, &cookie, NULL);
+    rc = pConnectToConnectionPoint(NULL, &IID_NULL, FALSE,
+                                   (IUnknown*)&container->IConnectionPointContainer_iface, &cookie, NULL);
     ok(rc == S_OK, "pConnectToConnectionPoint failed with %x\n",rc);
 
 /* MSDN says this should be required but it crashes on XP
     IUnknown_Release(point);
 */
-    ref = IUnknown_Release((IUnknown*)container);
+    ref = IConnectionPointContainer_Release(&container->IConnectionPointContainer_iface);
     ok(ref == 0, "leftover IConnectionPointContainer reference %i\n",ref);
-    ref = IUnknown_Release((IUnknown*)dispatch);
+    ref = IDispatch_Release(&dispatch->IDispatch_iface);
     ok(ref == 0, "leftover IDispatch reference %i\n",ref);
 }
 
@@ -1593,7 +1595,7 @@ static void test_SHPropertyBag_ReadLONG(void)
     rc = pSHPropertyBag_ReadLONG(&pb->IPropertyBag_iface, szName1, &out);
     ok(rc == DISP_E_BADVARTYPE || broken(rc == S_OK) || broken(rc == S_FALSE), "incorrect return %x\n",rc);
     ok(out == 0xfeedface  || broken(out == 0xfeedfa00), "value should not have changed %x\n",out);
-    IUnknown_Release((IUnknown*)pb);
+    IPropertyBag_Release(&pb->IPropertyBag_iface);
 }
 
 static void test_SHSetWindowBits(void)




More information about the wine-cvs mailing list