[PATCH] Remove unneeded assignments and variables, minor cleanups.

Nikolay Sivov nsivov at codeweavers.com
Tue May 25 18:02:28 CDT 2010


---
 dlls/ole32/antimoniker.c      |   27 +++++++++------------------
 dlls/ole32/bindctx.c          |   11 ++---------
 dlls/ole32/classmoniker.c     |    4 +---
 dlls/ole32/compositemoniker.c |    6 +++---
 dlls/ole32/datacache.c        |   31 ++++++++++++++-----------------
 dlls/ole32/defaulthandler.c   |    7 ++-----
 dlls/ole32/enumx.c            |    2 +-
 dlls/ole32/filemoniker.c      |   15 +++++----------
 dlls/ole32/git.c              |    8 ++++----
 9 files changed, 41 insertions(+), 70 deletions(-)

diff --git a/dlls/ole32/antimoniker.c b/dlls/ole32/antimoniker.c
index 69e0a90..db76b50 100644
--- a/dlls/ole32/antimoniker.c
+++ b/dlls/ole32/antimoniker.c
@@ -67,7 +67,7 @@ AntiMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject)
     TRACE("(%p,%p,%p)\n",This,riid,ppvObject);
 
     /* Perform a sanity check on the parameters.*/
-    if ( (This==0) || (ppvObject==0) )
+    if ( !ppvObject )
 	return E_INVALIDARG;
 
     /* Initialize the return parameter */
@@ -174,13 +174,13 @@ AntiMonikerImpl_IsDirty(IMoniker* iface)
 static HRESULT WINAPI
 AntiMonikerImpl_Load(IMoniker* iface,IStream* pStm)
 {
-    DWORD constant=1,dwbuffer;
+    DWORD dwbuffer;
     HRESULT res;
 
     /* data read by this function is only a DWORD constant (must be 1) ! */
     res=IStream_Read(pStm,&dwbuffer,sizeof(DWORD),NULL);
 
-    if (SUCCEEDED(res)&& dwbuffer!=constant)
+    if (SUCCEEDED(res)&& dwbuffer!=1)
         return E_FAIL;
 
     return res;
@@ -192,13 +192,9 @@ AntiMonikerImpl_Load(IMoniker* iface,IStream* pStm)
 static HRESULT WINAPI
 AntiMonikerImpl_Save(IMoniker* iface,IStream* pStm,BOOL fClearDirty)
 {
-    DWORD constant=1;
-    HRESULT res;
-
+    static const DWORD constant = 1;
     /* data written by this function is only a DWORD constant set to 1 ! */
-    res=IStream_Write(pStm,&constant,sizeof(constant),NULL);
-
-    return res;
+    return IStream_Write(pStm,&constant,sizeof(constant),NULL);
 }
 
 /******************************************************************************
@@ -538,8 +534,6 @@ static HRESULT WINAPI
 AntiMonikerROTDataImpl_GetComparisonData(IROTData* iface, BYTE* pbData,
                                           ULONG cbMax, ULONG* pcbData)
 {
-    DWORD constant = 1;
-
     TRACE("(%p, %u, %p)\n", pbData, cbMax, pcbData);
 
     *pcbData = sizeof(CLSID) + sizeof(DWORD);
@@ -547,7 +541,7 @@ AntiMonikerROTDataImpl_GetComparisonData(IROTData* iface, BYTE* pbData,
         return E_OUTOFMEMORY;
 
     memcpy(pbData, &CLSID_AntiMoniker, sizeof(CLSID));
-    memcpy(pbData+sizeof(CLSID), &constant, sizeof(DWORD));
+    *(DWORD*)(pbData+sizeof(CLSID)) = 1;
 
     return S_OK;
 }
@@ -615,8 +609,7 @@ static HRESULT AntiMonikerImpl_Construct(AntiMonikerImpl* This)
 HRESULT WINAPI CreateAntiMoniker(LPMONIKER * ppmk)
 {
     AntiMonikerImpl* newAntiMoniker = 0;
-    HRESULT        hr = S_OK;
-    IID riid=IID_IMoniker;
+    HRESULT hr;
 
     TRACE("(%p)\n",ppmk);
 
@@ -632,9 +625,7 @@ HRESULT WINAPI CreateAntiMoniker(LPMONIKER * ppmk)
         return hr;
     }
 
-    hr = AntiMonikerImpl_QueryInterface((IMoniker*)newAntiMoniker,&riid,(void**)ppmk);
-
-    return hr;
+    return AntiMonikerImpl_QueryInterface((IMoniker*)newAntiMoniker,&IID_IMoniker,(void**)ppmk);
 }
 
 static HRESULT WINAPI AntiMonikerCF_QueryInterface(LPCLASSFACTORY iface,
@@ -677,7 +668,7 @@ static HRESULT WINAPI AntiMonikerCF_CreateInstance(LPCLASSFACTORY iface,
     if (FAILED(hr))
         return hr;
 
-  	hr = IMoniker_QueryInterface(pMoniker, riid, ppv);
+    hr = IMoniker_QueryInterface(pMoniker, riid, ppv);
 
     if (FAILED(hr))
         IMoniker_Release(pMoniker);
diff --git a/dlls/ole32/bindctx.c b/dlls/ole32/bindctx.c
index f7561bd..76a8cc0 100644
--- a/dlls/ole32/bindctx.c
+++ b/dlls/ole32/bindctx.c
@@ -285,8 +285,6 @@ BindCtxImpl_GetBindOptions(IBindCtx* iface,BIND_OPTS *pbindopts)
 static HRESULT WINAPI
 BindCtxImpl_GetRunningObjectTable(IBindCtx* iface,IRunningObjectTable** pprot)
 {
-    HRESULT res;
-
     BindCtxImpl *This = (BindCtxImpl *)iface;
 
     TRACE("(%p,%p)\n",This,pprot);
@@ -294,9 +292,7 @@ BindCtxImpl_GetRunningObjectTable(IBindCtx* iface,IRunningObjectTable** pprot)
     if (pprot==NULL)
         return E_POINTER;
 
-    res=GetRunningObjectTable(0, pprot);
-
-    return res;
+    return GetRunningObjectTable(0, pprot);
 }
 
 /******************************************************************************
@@ -557,7 +553,6 @@ HRESULT WINAPI CreateBindCtx(DWORD reserved, LPBC * ppbc)
 {
     BindCtxImpl* newBindCtx = 0;
     HRESULT hr;
-    IID riid=IID_IBindCtx;
 
     TRACE("(%d,%p)\n",reserved,ppbc);
 
@@ -582,9 +577,7 @@ HRESULT WINAPI CreateBindCtx(DWORD reserved, LPBC * ppbc)
         return hr;
     }
 
-    hr = BindCtxImpl_QueryInterface((IBindCtx*)newBindCtx,&riid,(void**)ppbc);
-
-    return hr;
+    return BindCtxImpl_QueryInterface((IBindCtx*)newBindCtx,&IID_IBindCtx,(void**)ppbc);
 }
 
 /******************************************************************************
diff --git a/dlls/ole32/classmoniker.c b/dlls/ole32/classmoniker.c
index f67ae00..8b927f8 100644
--- a/dlls/ole32/classmoniker.c
+++ b/dlls/ole32/classmoniker.c
@@ -210,9 +210,7 @@ static HRESULT WINAPI ClassMoniker_Save(IMoniker* iface,
     hr = IStream_Write(pStm, &This->clsid, sizeof(This->clsid), NULL);
     if (FAILED(hr)) return hr;
 
-    hr = IStream_Write(pStm, &zero, sizeof(zero), NULL);
-
-    return hr;
+    return IStream_Write(pStm, &zero, sizeof(zero), NULL);
 }
 
 /******************************************************************************
diff --git a/dlls/ole32/compositemoniker.c b/dlls/ole32/compositemoniker.c
index 275d875..3e8b495 100644
--- a/dlls/ole32/compositemoniker.c
+++ b/dlls/ole32/compositemoniker.c
@@ -101,7 +101,7 @@ CompositeMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject
     TRACE("(%p,%p,%p)\n",This,riid,ppvObject);
 
     /* Perform a sanity check on the parameters.*/
-    if ( (This==0) || (ppvObject==0) )
+    if ( !ppvObject )
 	return E_INVALIDARG;
 
     /* Initialize the return parameter */
@@ -1184,7 +1184,7 @@ CompositeMonikerImpl_IsSystemMoniker(IMoniker* iface,DWORD* pwdMksys)
     if (!pwdMksys)
         return E_POINTER;
 
-    (*pwdMksys)=MKSYS_GENERICCOMPOSITE;
+    *pwdMksys = MKSYS_GENERICCOMPOSITE;
 
     return S_OK;
 }
@@ -1504,7 +1504,7 @@ EnumMonikerImpl_QueryInterface(IEnumMoniker* iface,REFIID riid,void** ppvObject)
     TRACE("(%p,%p,%p)\n",This,riid,ppvObject);
 
     /* Perform a sanity check on the parameters.*/
-    if ( (This==0) || (ppvObject==0) )
+    if ( !ppvObject )
 	return E_INVALIDARG;
 
     /* Initialize the return parameter */
diff --git a/dlls/ole32/datacache.c b/dlls/ole32/datacache.c
index ead53fe..0f739de 100644
--- a/dlls/ole32/datacache.c
+++ b/dlls/ole32/datacache.c
@@ -655,17 +655,15 @@ static HRESULT DataCacheEntry_LoadData(DataCacheEntry *This)
 static HRESULT DataCacheEntry_CreateStream(DataCacheEntry *This,
                                            IStorage *storage, IStream **stream)
 {
-    HRESULT hr;
     WCHAR wszName[] = {2,'O','l','e','P','r','e','s',
         '0' + (This->stream_number / 100) % 10,
         '0' + (This->stream_number / 10) % 10,
         '0' + This->stream_number % 10, 0};
 
     /* FIXME: cache the created stream in This? */
-    hr = IStorage_CreateStream(storage, wszName,
-                               STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE,
-                               0, 0, stream);
-    return hr;
+    return IStorage_CreateStream(storage, wszName,
+                                 STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE,
+                                 0, 0, stream);
 }
 
 static HRESULT DataCacheEntry_Save(DataCacheEntry *This, IStorage *storage,
@@ -881,7 +879,7 @@ static HRESULT WINAPI DataCache_NDIUnknown_QueryInterface(
   /*
    * Perform a sanity check on the parameters.
    */
-  if ( (this==0) || (ppvObject==0) )
+  if ( !ppvObject )
     return E_INVALIDARG;
 
   /*
@@ -892,30 +890,30 @@ static HRESULT WINAPI DataCache_NDIUnknown_QueryInterface(
   /*
    * Compare the riid with the interface IDs implemented by this object.
    */
-  if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0)
+  if (IsEqualIID(riid, &IID_IUnknown))
   {
     *ppvObject = iface;
   }
-  else if (memcmp(&IID_IDataObject, riid, sizeof(IID_IDataObject)) == 0)
+  else if (IsEqualIID(&IID_IDataObject, riid))
   {
     *ppvObject = &this->lpVtbl;
   }
-  else if ( (memcmp(&IID_IPersistStorage, riid, sizeof(IID_IPersistStorage)) == 0)  ||
-	    (memcmp(&IID_IPersist, riid, sizeof(IID_IPersist)) == 0) )
+  else if (IsEqualIID(&IID_IPersistStorage, riid) ||
+	   IsEqualIID(&IID_IPersist, riid))
   {
     *ppvObject = &this->lpvtblIPersistStorage;
   }
-  else if ( (memcmp(&IID_IViewObject, riid, sizeof(IID_IViewObject)) == 0) ||
-	    (memcmp(&IID_IViewObject2, riid, sizeof(IID_IViewObject2)) == 0) )
+  else if (IsEqualIID(&IID_IViewObject, riid) ||
+	   IsEqualIID(&IID_IViewObject2, riid))
   {
     *ppvObject = &this->lpvtblIViewObject;
   }
-  else if ( (memcmp(&IID_IOleCache, riid, sizeof(IID_IOleCache)) == 0) ||
-	    (memcmp(&IID_IOleCache2, riid, sizeof(IID_IOleCache2)) == 0) )
+  else if (IsEqualIID(&IID_IOleCache, riid) ||
+	   IsEqualIID(&IID_IOleCache2, riid))
   {
     *ppvObject = &this->lpvtblIOleCache2;
   }
-  else if (memcmp(&IID_IOleCacheControl, riid, sizeof(IID_IOleCacheControl)) == 0)
+  else if (IsEqualIID(&IID_IOleCacheControl, riid))
   {
     *ppvObject = &this->lpvtblIOleCacheControl;
   }
@@ -2286,8 +2284,7 @@ HRESULT WINAPI CreateDataCache(
    * This is necessary because it's the only time the non-delegating
    * IUnknown pointer can be returned to the outside.
    */
-  if ( (pUnkOuter!=NULL) &&
-       (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) != 0) )
+  if ( (pUnkOuter!=NULL) && !IsEqualIID(&IID_IUnknown, riid) )
     return CLASS_E_NOAGGREGATION;
 
   /*
diff --git a/dlls/ole32/defaulthandler.c b/dlls/ole32/defaulthandler.c
index d0a871f..c234054 100644
--- a/dlls/ole32/defaulthandler.c
+++ b/dlls/ole32/defaulthandler.c
@@ -1146,14 +1146,11 @@ static HRESULT WINAPI DefaultHandler_EnumFormatEtc(
 	    DWORD            dwDirection,
 	    IEnumFORMATETC** ppenumFormatEtc)
 {
-  HRESULT hres;
   DefaultHandler *This = impl_from_IDataObject(iface);
 
   TRACE("(%p, %x, %p)\n", iface, dwDirection, ppenumFormatEtc);
 
-  hres = OleRegEnumFormatEtc(&This->clsid, dwDirection, ppenumFormatEtc);
-
-  return hres;
+  return OleRegEnumFormatEtc(&This->clsid, dwDirection, ppenumFormatEtc);
 }
 
 /************************************************************************
@@ -2093,7 +2090,7 @@ HRESULT WINAPI OleCreateEmbeddingHelper(
   LPVOID*   ppvObj)
 {
   DefaultHandler* newHandler = NULL;
-  HRESULT         hr         = S_OK;
+  HRESULT         hr;
 
   TRACE("(%s, %p, %08x, %p, %s, %p)\n", debugstr_guid(clsid), pUnkOuter, flags, pCF, debugstr_guid(riid), ppvObj);
 
diff --git a/dlls/ole32/enumx.c b/dlls/ole32/enumx.c
index 2665301..4279ca8 100644
--- a/dlls/ole32/enumx.c
+++ b/dlls/ole32/enumx.c
@@ -51,7 +51,7 @@ HRESULT WINAPI enumx_QueryInterface(
     REFIID riid,
     void** ppvObject)
 {
-    if ( (This==0) || (ppvObject==0) )
+    if ( ppvObject==0 )
         return E_INVALIDARG;
 
     *ppvObject = 0;
diff --git a/dlls/ole32/filemoniker.c b/dlls/ole32/filemoniker.c
index 72f5913..39e7525 100644
--- a/dlls/ole32/filemoniker.c
+++ b/dlls/ole32/filemoniker.c
@@ -77,7 +77,7 @@ FileMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject)
     TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppvObject);
 
     /* Perform a sanity check on the parameters.*/
-    if ( (This==0) || (ppvObject==0) )
+    if ( !ppvObject )
 	return E_INVALIDARG;
 
     /* Initialize the return parameter */
@@ -421,10 +421,7 @@ FileMonikerImpl_Save(IMoniker* iface, IStream* pStm, BOOL fClearDirty)
     }
 
     if (!bWriteWide)
-    {
-        res=IStream_Write(pStm,&ZERO,sizeof(DWORD),NULL);
-        return res;
-    }
+        return IStream_Write(pStm,&ZERO,sizeof(DWORD),NULL);
 
     /* write bytes needed for the filepathW (without 0) + 6 */
     bytesW = len*sizeof(WCHAR) + 6;
@@ -441,9 +438,7 @@ FileMonikerImpl_Save(IMoniker* iface, IStream* pStm, BOOL fClearDirty)
     if (FAILED(res)) return res;
 
     /* write W string (no 0) */
-    res=IStream_Write(pStm,filePathW,bytesW,NULL);
-
-    return res;
+    return IStream_Write(pStm,filePathW,bytesW,NULL);
 }
 
 /******************************************************************************
@@ -679,7 +674,7 @@ FileMonikerImpl_ComposeWith(IMoniker* iface, IMoniker* pmkRight,
     static const WCHAR twoPoint[]={'.','.',0};
     static const WCHAR bkSlash[]={'\\',0};
     IBindCtx *bind=0;
-    int i=0,j=0,lastIdx1=0,lastIdx2=0;
+    int i,j,lastIdx1=0,lastIdx2=0;
     DWORD mkSys;
 
     TRACE("(%p,%p,%d,%p)\n",iface,pmkRight,fOnlyIfNotGeneric,ppmkComposite);
@@ -1362,7 +1357,7 @@ static const IROTDataVtbl VT_ROTDataImpl =
  */
 static HRESULT FileMonikerImpl_Construct(FileMonikerImpl* This, LPCOLESTR lpszPathName)
 {
-    int nb=0,i;
+    int nb,i;
     int sizeStr=lstrlenW(lpszPathName);
     LPOLESTR *tabStr=0;
     static const WCHAR twoPoint[]={'.','.',0};
diff --git a/dlls/ole32/git.c b/dlls/ole32/git.c
index e961f90..dc02a6a 100644
--- a/dlls/ole32/git.c
+++ b/dlls/ole32/git.c
@@ -187,9 +187,9 @@ StdGlobalInterfaceTable_RegisterInterfaceInGlobal(
   TRACE("About to marshal the interface\n");
 
   hres = CreateStreamOnHGlobal(0, TRUE, &stream);
-  if (hres) return hres;
+  if (hres != S_OK) return hres;
   hres = CoMarshalInterface(stream, riid, pUnk, MSHCTX_INPROC, NULL, MSHLFLAGS_TABLESTRONG);
-  if (hres)
+  if (hres != S_OK)
   {
     IStream_Release(stream);
     return hres;
@@ -281,7 +281,7 @@ StdGlobalInterfaceTable_GetInterfaceFromGlobal(
 
   LeaveCriticalSection(&git_section);
 
-  if (hres) {
+  if (hres != S_OK) {
     WARN("Failed to clone stream with error 0x%08x\n", hres);
     return hres;
   }
@@ -290,7 +290,7 @@ StdGlobalInterfaceTable_GetInterfaceFromGlobal(
   hres = CoUnmarshalInterface(stream, riid, ppv);
   IStream_Release(stream);
 
-  if (hres) {
+  if (hres != S_OK) {
     WARN("Failed to unmarshal stream\n");
     return hres;
   }
-- 
1.5.6.5


--------------070407000206030001070406--



More information about the wine-patches mailing list