PATCH: aliasing problems in ole32

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

This fixing some of the pointer aliasing problems in
dlls/ole32.

(The compiler can assume that (void**)&ptr and ptr are
 different entities, have nothing to do with each other 
 and move code around where it might break.)

Ciao, Marcus

Changelog:
	Fixed some warnings from newer gccs in regards to
	pointer aliasing problems by using unions instead of
	using (void**)&ptr constructs.

Index: dlls/ole32/compobj.c
===================================================================
RCS file: /home/wine/wine/dlls/ole32/compobj.c,v
retrieving revision 1.73
diff -u -r1.73 compobj.c
--- dlls/ole32/compobj.c	11 Mar 2003 01:45:39 -0000	1.73
+++ dlls/ole32/compobj.c	26 Apr 2003 09:05:37 -0000
@@ -865,16 +865,19 @@
     STATSTG		ststg;
     unsigned char	*buffer;
     int 		buflen;
-    IClassFactory	*classfac;
     LARGE_INTEGER	seekto;
     ULARGE_INTEGER	newpos;
     ULONG		res;
+    union {
+	LPVOID vptr;
+	IClassFactory *pcfac;
+    } xcf;
 
     TRACE("Starting threader for %s.\n",debugstr_guid(&newClass->classIdentifier));
     strcpy(pipefn,PIPEPREF);
     WINE_StringFromCLSID(&newClass->classIdentifier,pipefn+strlen(PIPEPREF));
 
-    hres = IUnknown_QueryInterface(newClass->classObject,&IID_IClassFactory,(LPVOID*)&classfac);
+    hres = IUnknown_QueryInterface(newClass->classObject,&IID_IClassFactory,&xcf.vptr);
     if (hres) return hres;
 
     hres = CreateStreamOnHGlobal(0,TRUE,&pStm);
@@ -882,7 +885,7 @@
 	FIXME("Failed to create stream on hglobal.\n");
 	return hres;
     }
-    hres = CoMarshalInterface(pStm,&IID_IClassFactory,(LPVOID)classfac,0,NULL,0);
+    hres = CoMarshalInterface(pStm,&IID_IClassFactory,xcf.vptr,0,NULL,0);
     if (hres) {
 	FIXME("CoMarshalInterface failed, %lx!\n",hres);
 	return hres;
@@ -1306,8 +1309,11 @@
 	REFIID iid,
 	LPVOID *ppv)
 {
-	HRESULT hres;
-	LPCLASSFACTORY lpclf = 0;
+  HRESULT hres;
+  union {
+    LPVOID vptr;
+    LPCLASSFACTORY lpclf;
+  } xcf;
 
   /*
    * Sanity check
@@ -1341,7 +1347,7 @@
 			  dwClsContext,
 			  NULL,
 			  &IID_IClassFactory,
-			  (LPVOID)&lpclf);
+			  &xcf.vptr);
 
   if (FAILED(hres)) {
     FIXME("no classfactory created for CLSID %s, hres is 0x%08lx\n",
@@ -1352,8 +1358,8 @@
   /*
    * Create the object and don't forget to release the factory
    */
-	hres = IClassFactory_CreateInstance(lpclf, pUnkOuter, iid, ppv);
-	IClassFactory_Release(lpclf);
+	hres = IClassFactory_CreateInstance(xcf.lpclf, pUnkOuter, iid, ppv);
+	IClassFactory_Release(xcf.lpclf);
 	if(FAILED(hres))
 	  FIXME("no instance created for interface %s of class %s, hres is 0x%08lx\n",
 		debugstr_guid(iid), debugstr_guid(rclsid),hres);
@@ -1372,10 +1378,13 @@
   ULONG         cmq,
   MULTI_QI*     pResults)
 {
-  IUnknown* pUnk = NULL;
   HRESULT   hr;
   ULONG     index;
   int       successCount = 0;
+  union {
+    LPVOID vptr;
+    LPUNKNOWN punk;
+  } xunk;
 
   /*
    * Sanity check
@@ -1402,8 +1411,7 @@
 			pUnkOuter,
 			dwClsContext,
 			&IID_IUnknown,
-			(VOID**)&pUnk);
-
+			&xunk.vptr);
   if (hr)
     return hr;
 
@@ -1412,10 +1420,15 @@
    */
   for (index = 0; index < cmq; index++)
   {
-    pResults[index].hr = IUnknown_QueryInterface(pUnk,
+    union {
+	  LPVOID vptr;
+	  LPUNKNOWN punk;
+    } xunk2;
+    pResults[index].hr = IUnknown_QueryInterface(xunk.punk,
 						 pResults[index].pIID,
-						 (VOID**)&(pResults[index].pItf));
-
+						 &xunk2.vptr
+    );
+    pResults[index].pItf = xunk2.punk;
     if (pResults[index].hr == S_OK)
       successCount++;
   }
@@ -1423,7 +1436,7 @@
   /*
    * Release our temporary unknown pointer.
    */
-  IUnknown_Release(pUnk);
+  IUnknown_Release(xunk.punk);
 
   if (successCount == 0)
     return E_NOINTERFACE;
Index: dlls/ole32/compobj_private.h
===================================================================
RCS file: /home/wine/wine/dlls/ole32/compobj_private.h,v
retrieving revision 1.6
diff -u -r1.6 compobj_private.h
--- dlls/ole32/compobj_private.h	11 Mar 2003 01:45:39 -0000	1.6
+++ dlls/ole32/compobj_private.h	26 Apr 2003 09:05:38 -0000
@@ -37,10 +37,16 @@
 get_facbuf_for_iid(REFIID riid,IPSFactoryBuffer **facbuf) {
     HRESULT       hres;
     CLSID         pxclsid;
+    union { 
+	LPVOID vptr;
+	IPSFactoryBuffer *psfac;
+    } x;
 
     if ((hres = CoGetPSClsid(riid,&pxclsid)))
 	return hres;
-    return CoGetClassObject(&pxclsid,CLSCTX_INPROC_SERVER,NULL,&IID_IPSFactoryBuffer,(LPVOID*)facbuf);
+    hres = CoGetClassObject(&pxclsid,CLSCTX_INPROC_SERVER,NULL,&IID_IPSFactoryBuffer,&x.vptr);
+    *facbuf = x.psfac;
+    return hres;
 }
 
 #define PIPEPREF "\\\\.\\pipe\\"
Index: dlls/ole32/compositemoniker.c
===================================================================
RCS file: /home/wine/wine/dlls/ole32/compositemoniker.c,v
retrieving revision 1.20
diff -u -r1.20 compositemoniker.c
--- dlls/ole32/compositemoniker.c	10 Apr 2003 18:17:35 -0000	1.20
+++ dlls/ole32/compositemoniker.c	26 Apr 2003 09:05:38 -0000
@@ -1626,7 +1626,7 @@
                                                  IEnumMoniker ** ppmk)
 {
     EnumMonikerImpl* newEnumMoniker;
-    int i;
+    unsigned int i;
 
 
     newEnumMoniker = HeapAlloc(GetProcessHeap(), 0, sizeof(EnumMonikerImpl));
Index: dlls/ole32/datacache.c
===================================================================
RCS file: /home/wine/wine/dlls/ole32/datacache.c,v
retrieving revision 1.17
diff -u -r1.17 datacache.c
--- dlls/ole32/datacache.c	7 Jan 2003 20:36:28 -0000	1.17
+++ dlls/ole32/datacache.c	26 Apr 2003 09:05:39 -0000
@@ -1070,7 +1070,6 @@
 {
   HRESULT hr = 0;
   HRESULT hrRet = E_UNEXPECTED;
-  IPersistStorage *pPersistStorage = 0;
   IStorage *pStorage = 0;
   IStream *pStream = 0;
   OLECHAR name[]={ 2, 'O', 'l', 'e', 'P', 'r', 'e', 's', '0', '0', '0', 0};
@@ -1079,12 +1078,16 @@
   PresentationDataHeader pdh;
   METAFILEPICT *mfPict;
   HMETAFILE hMetaFile = 0;
+  union {
+    LPVOID vptr;
+    IPersistStorage *ppers;
+  } xps;
 
   if (pformatetcIn->cfFormat == CF_METAFILEPICT)
   {
     /* Get the Persist Storage */
 
-    hr = IDataObject_QueryInterface(iface, &IID_IPersistStorage, (void**)&pPersistStorage);
+    hr = IDataObject_QueryInterface(iface, &IID_IPersistStorage, &xps.vptr);
 
     if (hr != S_OK)
       goto cleanup;
@@ -1098,7 +1101,7 @@
 
     /* Save it to storage */
 
-    hr = OleSave(pPersistStorage, pStorage, FALSE);
+    hr = OleSave(xps.ppers, pStorage, FALSE);
 
     if (hr != S_OK)
       goto cleanup;
@@ -1151,8 +1154,8 @@
     if (pStorage)
       IStorage_Release(pStorage);
 
-    if (pPersistStorage)
-      IPersistStorage_Release(pPersistStorage);
+    if (xps.ppers)
+      IPersistStorage_Release(xps.ppers);
 
     return hrRet;
   }
@@ -1208,20 +1211,19 @@
 	    STGMEDIUM*       pmedium,
 	    BOOL             fRelease)
 {
-  IOleCache2* oleCache = NULL;
   HRESULT     hres;
+  union {
+    LPVOID vptr;
+    IOleCache2 *poc;
+  } xoc;
 
   TRACE("(%p, %p, %p, %d)\n", iface, pformatetc, pmedium, fRelease);
 
-  hres = IDataObject_QueryInterface(iface, &IID_IOleCache2, (void**)&oleCache);
-
+  hres = IDataObject_QueryInterface(iface, &IID_IOleCache2, &xoc.vptr);
   if (FAILED(hres))
     return E_UNEXPECTED;
-
-  hres = IOleCache2_SetData(oleCache, pformatetc, pmedium, fRelease);
-
-  IOleCache2_Release(oleCache);
-
+  hres = IOleCache2_SetData(xoc.poc, pformatetc, pmedium, fRelease);
+  IOleCache2_Release(xoc.poc);
   return hres;
 }
 
Index: dlls/ole32/defaulthandler.c
===================================================================
RCS file: /home/wine/wine/dlls/ole32/defaulthandler.c,v
retrieving revision 1.10
diff -u -r1.10 defaulthandler.c
--- dlls/ole32/defaulthandler.c	31 May 2002 23:25:50 -0000	1.10
+++ dlls/ole32/defaulthandler.c	26 Apr 2003 09:05:39 -0000
@@ -1094,14 +1094,17 @@
 	    SIZEL*             psizel)
 {
   DVTARGETDEVICE* targetDevice;
-  IViewObject2*   cacheView = NULL;
   HRESULT         hres;
+  union {
+    IViewObject2* pcv;
+    LPVOID vptr;
+  } xvo;
 
   _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
 
   TRACE("(%p, %lx, %p)\n", iface, dwDrawAspect, psizel);
 
-  hres = IUnknown_QueryInterface(this->dataCache, &IID_IViewObject2, (void**)&cacheView);
+  hres = IUnknown_QueryInterface(this->dataCache, &IID_IViewObject2, &xvo.vptr);
 
   if (FAILED(hres))
     return E_UNEXPECTED;
@@ -1115,18 +1118,12 @@
    * extra work until later.
    */
   targetDevice = NULL;
-
-  hres = IViewObject2_GetExtent(cacheView,
+  hres = IViewObject2_GetExtent(xvo.pcv,
 				dwDrawAspect,
 				-1,
 				targetDevice,
 				psizel);
-
-  /*
-   * Cleanup
-   */
-  IViewObject2_Release(cacheView);
-
+  IViewObject2_Release(xvo.pcv);
   return hres;
 }
 
@@ -1326,26 +1323,21 @@
 	    LPFORMATETC      pformatetcIn,
 	    STGMEDIUM*       pmedium)
 {
-  IDataObject* cacheDataObject = NULL;
   HRESULT      hres;
-
+  union {
+    LPVOID vptr;
+    IDataObject *pdo;
+  } xdo;
   _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
 
   TRACE("(%p, %p, %p)\n", iface, pformatetcIn, pmedium);
-
-  hres = IUnknown_QueryInterface(this->dataCache,
-				 &IID_IDataObject,
-				 (void**)&cacheDataObject);
-
+  hres = IUnknown_QueryInterface(this->dataCache, &IID_IDataObject, &xdo.vptr);
   if (FAILED(hres))
     return E_UNEXPECTED;
-
-  hres = IDataObject_GetData(cacheDataObject,
+  hres = IDataObject_GetData(xdo.pdo,
 			     pformatetcIn,
 			     pmedium);
-
-  IDataObject_Release(cacheDataObject);
-
+  IDataObject_Release(xdo.pdo);
   return hres;
 }
 
@@ -1370,25 +1362,19 @@
 	    IDataObject*     iface,
 	    LPFORMATETC      pformatetc)
 {
-  IDataObject* cacheDataObject = NULL;
   HRESULT      hres;
-
+  union {
+    LPVOID vptr;
+    IDataObject* pdo;
+  } xdo;
   _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
 
   TRACE("(%p, %p)\n", iface, pformatetc);
-
-  hres = IUnknown_QueryInterface(this->dataCache,
-				 &IID_IDataObject,
-				 (void**)&cacheDataObject);
-
+  hres = IUnknown_QueryInterface(this->dataCache, &IID_IDataObject, &xdo.vptr);
   if (FAILED(hres))
     return E_UNEXPECTED;
-
-  hres = IDataObject_QueryGetData(cacheDataObject,
-				  pformatetc);
-
-  IDataObject_Release(cacheDataObject);
-
+  hres = IDataObject_QueryGetData(xdo.pdo, pformatetc);
+  IDataObject_Release(xdo.pdo);
   return hres;
 }
 
@@ -1423,27 +1409,24 @@
 	    STGMEDIUM*       pmedium,
 	    BOOL             fRelease)
 {
-  IDataObject* cacheDataObject = NULL;
   HRESULT      hres;
-
+  union {
+    LPVOID vptr;
+    IDataObject *pod;
+  } xdo;
   _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
 
   TRACE("(%p, %p, %p, %d)\n", iface, pformatetc, pmedium, fRelease);
-
   hres = IUnknown_QueryInterface(this->dataCache,
 				 &IID_IDataObject,
-				 (void**)&cacheDataObject);
-
+				 &xdo.vptr);
   if (FAILED(hres))
     return E_UNEXPECTED;
-
-  hres = IDataObject_SetData(cacheDataObject,
+  hres = IDataObject_SetData(xdo.pod,
 			     pformatetc,
 			     pmedium,
 			     fRelease);
-
-  IDataObject_Release(cacheDataObject);
-
+  IDataObject_Release(xdo.pod);
   return hres;
 }
 
Index: dlls/ole32/filemoniker.c
===================================================================
RCS file: /home/wine/wine/dlls/ole32/filemoniker.c,v
retrieving revision 1.23
diff -u -r1.23 filemoniker.c
--- dlls/ole32/filemoniker.c	7 Jan 2003 20:36:27 -0000	1.23
+++ dlls/ole32/filemoniker.c	26 Apr 2003 09:05:40 -0000
@@ -561,11 +561,19 @@
     CLSID     clsID;
     IUnknown* pObj=0;
     IRunningObjectTable *prot=0;
-    IPersistFile  *ppf=0;
-    IClassFactory *pcf=0;
-    IClassActivator *pca=0;
-
     ICOM_THIS(FileMonikerImpl,iface);
+    union {
+	LPVOID vptr;
+	IPersistFile *ppf;
+    } xpf;
+    union {
+	LPVOID vptr;
+	IClassFactory *pcf;
+    } xcf;
+    union {
+	LPVOID vptr;
+	IClassActivator *pca;
+    } xca;
 
     *ppvResult=0;
 
@@ -583,44 +591,37 @@
                 /* first activation of this class */
                 res=GetClassFile(This->filePathName,&clsID);
                 if (SUCCEEDED(res)){
-
-                    res=CoCreateInstance(&clsID,NULL,CLSCTX_ALL,&IID_IPersistFile,(void**)&ppf);
+                    res=CoCreateInstance(&clsID,NULL,CLSCTX_ALL,&IID_IPersistFile,&xpf.vptr);
                     if (SUCCEEDED(res)){
 
-                        res=IPersistFile_Load(ppf,This->filePathName,STGM_READ);
+                        res=IPersistFile_Load(xpf.ppf,This->filePathName,STGM_READ);
                         if (SUCCEEDED(res)){
-
-                            pObj=(IUnknown*)ppf;
+                            pObj=(IUnknown*)xpf.ppf;
                             IUnknown_AddRef(pObj);
                         }
                     }
                 }
             }
         }
-    }
-    else{
-        res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&IID_IClassFactory,(void**)&pcf);
-
+    } else{
+        res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&IID_IClassFactory,&xcf.vptr);
         if (res==E_NOINTERFACE){
-
-            res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&IID_IClassActivator,(void**)&pca);
-
+            res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&IID_IClassActivator,&xca.vptr);
             if (res==E_NOINTERFACE)
                 return MK_E_INTERMEDIATEINTERFACENOTSUPPORTED;
         }
-        if (pcf!=NULL){
-
-            IClassFactory_CreateInstance(pcf,NULL,&IID_IPersistFile,(void**)ppf);
+        if (xcf.pcf!=NULL){
 
-            res=IPersistFile_Load(ppf,This->filePathName,STGM_READ);
+            IClassFactory_CreateInstance(xcf.pcf,NULL,&IID_IPersistFile,&xpf.ppf);
+            res=IPersistFile_Load(xpf.ppf,This->filePathName,STGM_READ);
 
             if (SUCCEEDED(res)){
 
-                pObj=(IUnknown*)ppf;
+                pObj=(IUnknown*)xpf.ppf;
                 IUnknown_AddRef(pObj);
             }
         }
-        if (pca!=NULL){
+        if (xca.pca!=NULL){
 
             FIXME("()\n");
 
@@ -628,7 +629,7 @@
 
             if (SUCCEEDED(res)){
 
-                res=IClassActivator_GetClassObject(pca,&clsID,CLSCTX_ALL,0,&IID_IPersistFile,(void**)&ppf);
+                res=IClassActivator_GetClassObject(xca.pca,&clsID,CLSCTX_ALL,0,&IID_IPersistFile,&xpf.vptr);
 
                 if (SUCCEEDED(res)){
 
@@ -651,14 +652,14 @@
     if (prot!=NULL)
         IRunningObjectTable_Release(prot);
 
-    if (ppf!=NULL)
-        IPersistFile_Release(ppf);
+    if (xpf.ppf!=NULL)
+        IPersistFile_Release(xpf.ppf);
 
-    if (pca!=NULL)
-        IClassActivator_Release(pca);
+    if (xca.pca!=NULL)
+        IClassActivator_Release(xca.pca);
 
-    if (pcf!=NULL)
-        IClassFactory_Release(pcf);
+    if (xcf.pcf!=NULL)
+        IClassFactory_Release(xcf.pcf);
 
     return res;
 }
Index: dlls/ole32/itemmoniker.c
===================================================================
RCS file: /home/wine/wine/dlls/ole32/itemmoniker.c,v
retrieving revision 1.17
diff -u -r1.17 itemmoniker.c
--- dlls/ole32/itemmoniker.c	7 Jan 2003 20:36:27 -0000	1.17
+++ dlls/ole32/itemmoniker.c	26 Apr 2003 09:05:41 -0000
@@ -436,30 +436,23 @@
                                             VOID** ppvResult)
 {
     ICOM_THIS(ItemMonikerImpl,iface);
-
     HRESULT   res;
-    IID    refid=IID_IOleItemContainer;
-    IOleItemContainer *poic=0;
+    union {
+      LPVOID vptr;
+      IOleItemContainer *poic;
+    } xoic;
 
     TRACE("(%p,%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,riid,ppvResult);
 
-    if(ppvResult ==NULL)
-        return E_POINTER;
-
-    if(pmkToLeft==NULL)
-        return E_INVALIDARG;
+    if(ppvResult == NULL) return E_POINTER;
+    if(pmkToLeft == NULL) return E_INVALIDARG;
 
     *ppvResult=0;
-
-    res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&refid,(void**)&poic);
-
+    res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&IID_IOleItemContainer,&xoic.vptr);
     if (SUCCEEDED(res)){
-
-        res=IOleItemContainer_GetObject(poic,This->itemName,BINDSPEED_MODERATE,pbc,riid,ppvResult);
-
-        IOleItemContainer_Release(poic);
+        res=IOleItemContainer_GetObject(xoic.poic,This->itemName,BINDSPEED_MODERATE,pbc,riid,ppvResult);
+        IOleItemContainer_Release(xoic.poic);
     }
-
     return res;
 }
 
@@ -475,24 +468,22 @@
     ICOM_THIS(ItemMonikerImpl,iface);
 
     HRESULT   res;
-    IOleItemContainer *poic=0;
+    union {
+      LPVOID vptr;
+      IOleItemContainer *poic;
+    } xoic;
 
     TRACE("(%p,%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,riid,ppvResult);
 
     *ppvResult=0;
-
     if(pmkToLeft==NULL)
         return E_INVALIDARG;
-
-    res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&IID_IOleItemContainer,(void**)&poic);
-
+    res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&IID_IOleItemContainer,&xoic.vptr);
     if (SUCCEEDED(res)){
+        res=IOleItemContainer_GetObjectStorage(xoic.poic,This->itemName,pbc,riid,ppvResult);
 
-        res=IOleItemContainer_GetObjectStorage(poic,This->itemName,pbc,riid,ppvResult);
-
-        IOleItemContainer_Release(poic);
+        IOleItemContainer_Release(xoic.poic);
     }
-
     return res;
 }
 
@@ -683,7 +674,6 @@
 {
     IRunningObjectTable* rot;
     HRESULT res;
-    IOleItemContainer *poic=0;
     ICOM_THIS(ItemMonikerImpl,iface);
 
     TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,pmkNewlyRunning);
@@ -705,23 +695,21 @@
             res = IRunningObjectTable_IsRunning(rot,iface);
 
             IRunningObjectTable_Release(rot);
-        }
-    else{
+    } else{
+        union {
+	    IOleItemContainer *poic;
+	    LPVOID vptr;
+        } xoic;
 
         /* If pmkToLeft is non-NULL, the method calls IMoniker::BindToObject on the pmkToLeft parameter,         */
         /* requesting an IOleItemContainer interface pointer. The method then calls IOleItemContainer::IsRunning,*/
         /* passing the string contained within this moniker. */
-
-        res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&IID_IOleItemContainer,(void**)&poic);
-
+        res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&IID_IOleItemContainer,&xoic.vptr);
         if (SUCCEEDED(res)){
-
-            res=IOleItemContainer_IsRunning(poic,This->itemName);
-
-            IOleItemContainer_Release(poic);
+            res=IOleItemContainer_IsRunning(xoic.poic,This->itemName);
+            IOleItemContainer_Release(xoic.poic);
         }
     }
-
     return res;
 }
 
@@ -858,34 +846,32 @@
                                                 ULONG* pchEaten,
                                                 IMoniker** ppmkOut)
 {
-    IOleItemContainer* poic=0;
-    IParseDisplayName* ppdn=0;
     LPOLESTR displayName;
     HRESULT res;
     ICOM_THIS(ItemMonikerImpl,iface);
+    union {
+	LPVOID vptr;
+	IOleItemContainer* poic;
+    } xoic;
+    union {
+	LPVOID vptr;
+	IParseDisplayName* ppdn;
+    } xpdn;
 
     /* If pmkToLeft is NULL, this method returns MK_E_SYNTAX */
     if (pmkToLeft==NULL)
-
         return MK_E_SYNTAX;
 
-    else{
-        /* Otherwise, the method calls IMoniker::BindToObject on the pmkToLeft parameter, requesting an */
-        /* IParseDisplayName interface pointer to the object identified by the moniker, and passes the display */
-        /* name to IParseDisplayName::ParseDisplayName */
-        res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&IID_IOleItemContainer,(void**)&poic);
-
-        if (SUCCEEDED(res)){
-
-            res=IOleItemContainer_GetObject(poic,This->itemName,BINDSPEED_MODERATE,pbc,&IID_IParseDisplayName,(void**)&ppdn);
-
-            res=IMoniker_GetDisplayName(iface,pbc,NULL,&displayName);
-
-            res=IParseDisplayName_ParseDisplayName(ppdn,pbc,displayName,pchEaten,ppmkOut);
-
-            IOleItemContainer_Release(poic);
-            IParseDisplayName_Release(ppdn);
-        }
+    /* Otherwise, the method calls IMoniker::BindToObject on the pmkToLeft parameter, requesting an */
+    /* IParseDisplayName interface pointer to the object identified by the moniker, and passes the display */
+    /* name to IParseDisplayName::ParseDisplayName */
+    res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&IID_IOleItemContainer,&xoic.vptr);
+    if (SUCCEEDED(res)){
+	res=IOleItemContainer_GetObject(xoic.poic,This->itemName,BINDSPEED_MODERATE,pbc,&IID_IParseDisplayName,&xpdn.vptr);
+	res=IMoniker_GetDisplayName(iface,pbc,NULL,&displayName);
+	res=IParseDisplayName_ParseDisplayName(xpdn.ppdn,pbc,displayName,pchEaten,ppmkOut);
+	IOleItemContainer_Release(xoic.poic);
+	IParseDisplayName_Release(xpdn.ppdn);
     }
     return res;
 }
Index: dlls/ole32/marshal.c
===================================================================
RCS file: /home/wine/wine/dlls/ole32/marshal.c,v
retrieving revision 1.8
diff -u -r1.8 marshal.c
--- dlls/ole32/marshal.c	11 Mar 2003 01:45:38 -0000	1.8
+++ dlls/ole32/marshal.c	26 Apr 2003 09:05:41 -0000
@@ -246,17 +246,20 @@
 ) {
   wine_marshal_id	mid;
   wine_marshal_data 	md;
-  IUnknown		*pUnk;
   ULONG			res;
   HRESULT		hres;
   IRpcStubBuffer	*stub;
   IPSFactoryBuffer	*psfacbuf;
+  union {
+    LPVOID vptr;
+    LPUNKNOWN punk;
+  } xunk;
 
   TRACE("(...,%s,...)\n",debugstr_guid(riid));
-  IUnknown_QueryInterface((LPUNKNOWN)pv,&IID_IUnknown,(LPVOID*)&pUnk);
+  IUnknown_QueryInterface((LPUNKNOWN)pv,&IID_IUnknown,&xunk.vptr);
   mid.processid = GetCurrentProcessId();
-  mid.objectid = (DWORD)pUnk; /* FIXME */
-  IUnknown_Release(pUnk);
+  mid.objectid = (DWORD)xunk.punk; /* FIXME */
+  IUnknown_Release(xunk.punk);
   memcpy(&mid.iid,riid,sizeof(mid.iid));
   md.dwDestContext	= dwDestContext;
   md.mshlflags		= mshlflags;
@@ -265,8 +268,8 @@
   hres = IStream_Write(pStm,&md,sizeof(md),&res);
   if (hres) return hres;
 
-  if (SUCCEEDED(MARSHAL_Find_Stub(&mid,&pUnk))) {
-      IUnknown_Release(pUnk);
+  if (SUCCEEDED(MARSHAL_Find_Stub(&mid,&xunk.punk))) {
+      IUnknown_Release(xunk.punk);
       return S_OK;
   }
   hres = get_facbuf_for_iid(riid,&psfacbuf);
@@ -277,9 +280,9 @@
     FIXME("Failed to create a stub for %s\n",debugstr_guid(riid));
     return hres;
   }
-  IUnknown_QueryInterface((LPUNKNOWN)pv,riid,(LPVOID*)&pUnk);
-  MARSHAL_Register_Stub(&mid,pUnk,stub);
-  IUnknown_Release(pUnk);
+  IUnknown_QueryInterface((LPUNKNOWN)pv,riid,&xunk.vptr);
+  MARSHAL_Register_Stub(&mid,xunk.punk,stub);
+  IUnknown_Release(xunk.punk);
   return S_OK;
 }
 
@@ -437,16 +440,19 @@
   wine_marshal_id	mid;
   wine_marshal_data 	md;
   ULONG			res;
-  IUnknown		*pUnknown;
+  union {
+    LPVOID vptr;
+    LPUNKNOWN punk;
+  } xunk;
 
   TRACE("(%p, %s, %p, %lx, %p, %lx)\n",
     pStm,debugstr_guid(riid),pUnk,dwDestContext,pvDestContext,mshlflags
   );
   STUBMGR_Start(); /* Just to be sure we have one running. */
   mid.processid = GetCurrentProcessId();
-  IUnknown_QueryInterface(pUnk,&IID_IUnknown,(LPVOID*)&pUnknown);
-  mid.objectid = (DWORD)pUnknown;
-  IUnknown_Release(pUnknown);
+  IUnknown_QueryInterface(pUnk,&IID_IUnknown,&xunk.vptr);
+  mid.objectid = (DWORD)xunk.punk;
+  IUnknown_Release(xunk.punk);
   memcpy(&mid.iid,riid,sizeof(mid.iid));
   md.dwDestContext	= dwDestContext;
   md.mshlflags		= mshlflags;
@@ -499,8 +505,11 @@
   wine_marshal_data	md;
   ULONG			res;
   LPMARSHAL		pMarshal;
-  LPUNKNOWN		pUnk;
   CLSID			xclsid;
+  union {
+    LPVOID vptr;
+    LPUNKNOWN punk;
+  } xunk;
 
   TRACE("(%p,%s,%p)\n",pStm,debugstr_guid(riid),ppv);
 
@@ -519,12 +528,12 @@
       FIXME("Stream read 3 failed, %lx, (%ld of %d)\n",hres,res,sizeof(xclsid));
       return hres;
   }
-  hres=CoCreateInstance(&xclsid,NULL,CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER | CLSCTX_LOCAL_SERVER,&IID_IMarshal,(void**)&pUnk);
+  hres=CoCreateInstance(&xclsid,NULL,CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER | CLSCTX_LOCAL_SERVER,&IID_IMarshal,&xunk.vptr);
   if (hres) {
       FIXME("Failed to create instance of unmarshaller %s.\n",debugstr_guid(&xclsid));
       return hres;
   }
-  hres = _GetMarshaller(riid,pUnk,md.dwDestContext,NULL,md.mshlflags,&pMarshal);
+  hres = _GetMarshaller(riid,xunk.punk,md.dwDestContext,NULL,md.mshlflags,&pMarshal);
   if (hres) {
       FIXME("Failed to get unmarshaller, %lx?\n",hres);
       return hres;
Index: dlls/ole32/moniker.c
===================================================================
RCS file: /home/wine/wine/dlls/ole32/moniker.c,v
retrieving revision 1.22
diff -u -r1.22 moniker.c
--- dlls/ole32/moniker.c	10 Apr 2003 18:17:35 -0000	1.22
+++ dlls/ole32/moniker.c	26 Apr 2003 09:05:42 -0000
@@ -498,15 +498,18 @@
  */
 HRESULT WINAPI OleRun(LPUNKNOWN pUnknown)
 {
-  IRunnableObject	*runable;
   ICOM_THIS(IRunnableObject,pUnknown);
   LRESULT		ret;
+  union {
+    LPVOID vptr;
+    IRunnableObject *runable;
+  } xro;
 
-  ret = IRunnableObject_QueryInterface(This,&IID_IRunnableObject,(LPVOID*)&runable);
+  ret = IRunnableObject_QueryInterface(This,&IID_IRunnableObject,&xro.vptr);
   if (ret)
 	return 0; /* Appears to return no error. */
-  ret  = IRunnableObject_Run(runable,NULL);
-  IRunnableObject_Release(runable);
+  ret  = IRunnableObject_Run(xro.runable,NULL);
+  IRunnableObject_Release(xro.runable);
   return ret;
 }
 
Index: dlls/ole32/ole2.c
===================================================================
RCS file: /home/wine/wine/dlls/ole32/ole2.c,v
retrieving revision 1.42
diff -u -r1.42 ole2.c
--- dlls/ole32/ole2.c	28 Jan 2003 01:06:20 -0000	1.42
+++ dlls/ole32/ole2.c	26 Apr 2003 09:05:43 -0000
@@ -718,24 +718,22 @@
   LPUNKNOWN pUnknown,
   BOOL      fContained)
 {
-  IRunnableObject* runnable = NULL;
   HRESULT          hres;
+  union {
+    LPVOID vptr;
+    IRunnableObject* runnable;
+  } xro;
 
   TRACE("(%p,%x), stub!\n", pUnknown, fContained);
-
   hres = IUnknown_QueryInterface(pUnknown,
 				 &IID_IRunnableObject,
-				 (void**)&runnable);
-
+				 &xro.vptr);
   if (SUCCEEDED(hres))
   {
-    hres = IRunnableObject_SetContainedObject(runnable, fContained);
-
-    IRunnableObject_Release(runnable);
-
+    hres = IRunnableObject_SetContainedObject(xro.runnable, fContained);
+    IRunnableObject_Release(xro.runnable);
     return hres;
   }
-
   return S_OK;
 }
 
@@ -748,10 +746,16 @@
   LPOLECLIENTSITE pClientSite,
   LPVOID*         ppvObj)
 {
-  IPersistStorage* persistStorage = NULL;
-  IOleObject*      oleObject      = NULL;
   STATSTG          storageInfo;
   HRESULT          hres;
+  union {
+    LPVOID vptr;
+    IPersistStorage* persistStorage;
+  } xps;
+  union {
+    LPVOID vptr;
+    IOleObject* oleObject;
+  } xoo;
 
   TRACE("(%p,%p,%p,%p)\n", pStg, riid, pClientSite, ppvObj);
 
@@ -771,7 +775,7 @@
 			  NULL,
 			  CLSCTX_INPROC_HANDLER,
 			  &IID_IOleObject,
-			  (void**)&oleObject);
+			  &xoo.vptr);
 
   /*
    * If that fails, as it will most times, load the default
@@ -782,7 +786,7 @@
     hres = OleCreateDefaultHandler(&storageInfo.clsid,
 				   NULL,
 				   &IID_IOleObject,
-				   (void**)&oleObject);
+				   &xoo.vptr);
   }
 
   /*
@@ -794,33 +798,23 @@
   /*
    * Inform the new object of it's client site.
    */
-  hres = IOleObject_SetClientSite(oleObject, pClientSite);
+  hres = IOleObject_SetClientSite(xoo.oleObject, pClientSite);
 
   /*
    * Initialize the object with it's IPersistStorage interface.
    */
-  hres = IOleObject_QueryInterface(oleObject,
+  hres = IOleObject_QueryInterface(xoo.oleObject,
 				   &IID_IPersistStorage,
-				   (void**)&persistStorage);
+				   &xps.vptr);
 
   if (SUCCEEDED(hres))
   {
-    IPersistStorage_Load(persistStorage, pStg);
-
-    IPersistStorage_Release(persistStorage);
-    persistStorage = NULL;
+    IPersistStorage_Load(xps.persistStorage, pStg);
+    IPersistStorage_Release(xps.persistStorage);
+    xps.persistStorage = NULL;
   }
-
-  /*
-   * Return the requested interface to the caller.
-   */
-  hres = IOleObject_QueryInterface(oleObject, riid, ppvObj);
-
-  /*
-   * Cleanup interfaces used internally
-   */
-  IOleObject_Release(oleObject);
-
+  hres = IOleObject_QueryInterface(xoo.oleObject, riid, ppvObj);
+  IOleObject_Release(xoo.oleObject);
   return hres;
 }
 
@@ -868,27 +862,26 @@
  */
 HRESULT WINAPI OleLockRunning(LPUNKNOWN pUnknown, BOOL fLock, BOOL fLastUnlockCloses)
 {
-  IRunnableObject* runnable = NULL;
   HRESULT          hres;
+  union {
+    LPVOID vptr;
+    IRunnableObject* runnable;
+  } xro;
 
   TRACE("(%p,%x,%x)\n", pUnknown, fLock, fLastUnlockCloses);
 
   hres = IUnknown_QueryInterface(pUnknown,
 				 &IID_IRunnableObject,
-				 (void**)&runnable);
+				 &xro.vptr);
 
   if (SUCCEEDED(hres))
   {
-    hres = IRunnableObject_LockRunning(runnable, fLock, fLastUnlockCloses);
-
-    IRunnableObject_Release(runnable);
-
+    hres = IRunnableObject_LockRunning(xro.runnable, fLock, fLastUnlockCloses);
+    IRunnableObject_Release(xro.runnable);
     return hres;
   }
-  else
-    return E_INVALIDARG;
+  return E_INVALIDARG;
 }
-
 
 /**************************************************************************
  * Internal methods to manage the shared OLE menu in response to the
Index: dlls/ole32/ole2impl.c
===================================================================
RCS file: /home/wine/wine/dlls/ole32/ole2impl.c,v
retrieving revision 1.7
diff -u -r1.7 ole2impl.c
--- dlls/ole32/ole2impl.c	7 Jan 2003 20:36:27 -0000	1.7
+++ dlls/ole32/ole2impl.c	26 Apr 2003 09:05:43 -0000
@@ -128,9 +128,15 @@
         {
           ILockBytes *ptrILockBytes = 0;
           IStorage *pStorage = 0;
-          IOleObject *pOleObject = 0;
-          IPersistStorage *pPersistStorage = 0;
           CLSID clsID;
+	  union {
+	    LPVOID vptr;
+	    IPersistStorage *pPersistStorage;
+	  } xps;
+	  union {
+	    LPVOID vptr;
+	    IOleObject *pOleObject;
+	  } xoe;
 
           /* Create ILock bytes */
 
@@ -149,30 +155,30 @@
           /* Create default handler for Persist storage */
 
           if (hr1 == S_OK)
-            hr1 = OleCreateDefaultHandler(&clsID, NULL, &IID_IPersistStorage, (LPVOID*)&pPersistStorage);
+            hr1 = OleCreateDefaultHandler(&clsID, NULL, &IID_IPersistStorage, &xps.vptr);
 
           /* Load the storage to Persist storage */
 
           if (hr1 == S_OK)
-            hr1 = IPersistStorage_Load(pPersistStorage, pStorage);
+            hr1 = IPersistStorage_Load(xps.pPersistStorage, pStorage);
 
           /* Query for IOleObject */
 
           if (hr1 == S_OK)
-            hr1 = IPersistStorage_QueryInterface(pPersistStorage, &IID_IOleObject, (LPVOID*)&pOleObject);
+            hr1 = IPersistStorage_QueryInterface(xps.pPersistStorage, &IID_IOleObject, &xoe.vptr);
 
           /* Set client site with the IOleObject */
 
           if (hr1 == S_OK)
-            hr1 = IOleObject_SetClientSite(pOleObject, pClientSite);
+            hr1 = IOleObject_SetClientSite(xoe.pOleObject, pClientSite);
 
-          IPersistStorage_Release(pPersistStorage);
+          IPersistStorage_Release(xps.pPersistStorage);
           /* Query for the requested interface */
 
           if (hr1 == S_OK)
-            hr1 = IPersistStorage_QueryInterface(pPersistStorage, riid, ppvObj);
+            hr1 = IPersistStorage_QueryInterface(xps.pPersistStorage, riid, ppvObj);
 
-          IPersistStorage_Release(pPersistStorage);
+          IPersistStorage_Release(xps.pPersistStorage);
 
           IStorage_Release(pStorage);
 
Index: dlls/ole32/ole2stubs.c
===================================================================
RCS file: /home/wine/wine/dlls/ole32/ole2stubs.c,v
retrieving revision 1.29
diff -u -r1.29 ole2stubs.c
--- dlls/ole32/ole2stubs.c	13 Jan 2003 20:37:39 -0000	1.29
+++ dlls/ole32/ole2stubs.c	26 Apr 2003 09:05:43 -0000
@@ -96,36 +96,44 @@
 	LPVOID* ppvObj)
 {
   HRESULT hres, hres1;
-  IUnknown * pUnk = NULL;
+  union {
+    IUnknown * pUnk;
+    LPVOID vptr;
+  } xunk;
 
   FIXME("\n\t%s\n\t%s stub!\n", debugstr_guid(rclsid), debugstr_guid(riid));
 
-  if (SUCCEEDED((hres = CoCreateInstance(rclsid, 0, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER|CLSCTX_LOCAL_SERVER , riid, (LPVOID*)&pUnk))))
+  if (SUCCEEDED((hres = CoCreateInstance(rclsid, 0, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER|CLSCTX_LOCAL_SERVER , riid, &xunk.vptr))))
   {
     if (pClientSite)
     {
-      IOleObject * pOE;
-      IPersistStorage * pPS;
-      if (SUCCEEDED((hres = IUnknown_QueryInterface( pUnk, &IID_IOleObject, (LPVOID*)&pOE))))
+      union {
+        LPVOID vptr;
+        IOleObject * pOE;
+      } xoo;
+      union {
+        LPVOID vptr;
+        IPersistStorage * pPS;
+      } xps;
+
+      if (SUCCEEDED((hres = IUnknown_QueryInterface( xunk.pUnk, &IID_IOleObject, &xoo.vptr))))
       {
         TRACE("trying to set clientsite %p\n", pClientSite);
-        hres1 = IOleObject_SetClientSite(pOE, pClientSite);
+        hres1 = IOleObject_SetClientSite(xoo.pOE, pClientSite);
         TRACE("-- result 0x%08lx\n", hres1);
-	IOleObject_Release(pOE);
+	IOleObject_Release(xoo.pOE);
       }
-      if (SUCCEEDED((hres = IUnknown_QueryInterface( pUnk, &IID_IPersistStorage, (LPVOID*)&pPS))))
+      if (SUCCEEDED((hres = IUnknown_QueryInterface( xunk.pUnk, &IID_IPersistStorage, &xps.vptr))))
       {
         TRACE("trying to set stg %p\n", pStg);
-	hres1 = IPersistStorage_InitNew(pPS, pStg);
+	hres1 = IPersistStorage_InitNew(xps.pPS, pStg);
         TRACE("-- result 0x%08lx\n", hres1);
-	IPersistStorage_Release(pPS);
+	IPersistStorage_Release(xps.pPS);
       }
     }
   }
-
-  *ppvObj = pUnk;
-
-  TRACE("-- %p \n", pUnk);
+  *ppvObj = xunk.vptr;
+  TRACE("-- %p \n", xunk.pUnk);
   return hres;
 }
 
Index: dlls/ole32/oleproxy.c
===================================================================
RCS file: /home/wine/wine/dlls/ole32/oleproxy.c,v
retrieving revision 1.6
diff -u -r1.6 oleproxy.c
--- dlls/ole32/oleproxy.c	7 Jan 2003 20:36:27 -0000	1.6
+++ dlls/ole32/oleproxy.c	26 Apr 2003 09:05:44 -0000
@@ -138,13 +138,19 @@
 
     if (msg->iMethod == 3) { /* CreateInstance */
 	IID iid;
-	IClassFactory	*classfac;
-	IUnknown	*ppv;
 	IStream		*pStm;
 	STATSTG		ststg;
 	ULARGE_INTEGER	newpos;
 	LARGE_INTEGER	seekto;
 	ULONG		res;
+	union {
+	    LPVOID vptr;
+	    IClassFactory   *classfac;
+	} xcf;
+	union {
+	    LPVOID vptr;
+	    IUnknown        *ppv;
+	} xunk;
 
 	if (msg->cbBuffer < sizeof(IID)) {
 	    FIXME("Not enough bytes in buffer (%ld instead of %d)?\n",msg->cbBuffer,sizeof(IID));
@@ -152,13 +158,13 @@
 	}
 	memcpy(&iid,msg->Buffer,sizeof(iid));
 	TRACE("->CreateInstance(%s)\n",debugstr_guid(&iid));
-	hres = IUnknown_QueryInterface(This->pUnkServer,&IID_IClassFactory,(LPVOID*)&classfac);
+	hres = IUnknown_QueryInterface(This->pUnkServer,&IID_IClassFactory,&xcf.vptr);
 	if (hres) {
 	    FIXME("Ole server does not provide a IClassFactory?\n");
 	    return hres;
 	}
-	hres = IClassFactory_CreateInstance(classfac,NULL,&iid,(LPVOID*)&ppv);
-	IClassFactory_Release(classfac);
+	hres = IClassFactory_CreateInstance(xcf.classfac,NULL,&iid,&xunk.vptr);
+	IClassFactory_Release(xcf.classfac);
 	if (hres) {
 	    msg->cbBuffer = 0;
 	    FIXME("Failed to create an instance of %s\n",debugstr_guid(&iid));
@@ -169,7 +175,7 @@
 	    FIXME("Failed to create stream on hglobal\n");
 	    return hres;
 	}
-	hres = CoMarshalInterface(pStm,&iid,ppv,0,NULL,0);
+	hres = CoMarshalInterface(pStm,&iid,xunk.ppv,0,NULL,0);
 	if (hres) {
 	    FIXME("CoMarshalInterface failed, %lx!\n",hres);
 	    msg->cbBuffer = 0;
Index: dlls/ole32/storage32.c
===================================================================
RCS file: /home/wine/wine/dlls/ole32/storage32.c,v
retrieving revision 1.37
diff -u -r1.37 storage32.c
--- dlls/ole32/storage32.c	10 Apr 2003 18:17:35 -0000	1.37
+++ dlls/ole32/storage32.c	26 Apr 2003 09:05:48 -0000
@@ -5877,7 +5877,10 @@
 {
     CLSID	clsid;
     HRESULT	res;
-    LPPERSISTSTREAM	xstm;
+    union {
+	LPVOID vptr;
+	LPPERSISTSTREAM pstm;
+    } xstm;
 
     TRACE("(%p,%s,%p)\n",pStm,debugstr_guid(iidInterface),ppvObj);
 
@@ -5887,13 +5890,13 @@
     res=CoCreateInstance(&clsid,NULL,CLSCTX_INPROC_SERVER,iidInterface,ppvObj);
     if (!SUCCEEDED(res))
 	return res;
-    res=IUnknown_QueryInterface((IUnknown*)*ppvObj,&IID_IPersistStream,(LPVOID*)&xstm);
+    res=IUnknown_QueryInterface((IUnknown*)*ppvObj,&IID_IPersistStream,&xstm.vptr);
     if (!SUCCEEDED(res)) {
 	IUnknown_Release((IUnknown*)*ppvObj);
 	return res;
     }
-    res=IPersistStream_Load(xstm,pStm);
-    IPersistStream_Release(xstm);
+    res=IPersistStream_Load(xstm.pstm,pStm);
+    IPersistStream_Release(xstm.pstm);
     /* FIXME: all refcounts ok at this point? I think they should be:
      * 		pStm	: unchanged
      *		ppvObj	: 1


[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux