Bug 783523 - Fix platform-specific nsresult misuse; r=ehsan,tbsaunde,smaug
authorAryeh Gregor <ayg@aryeh.name>
Thu, 16 Aug 2012 14:58:11 +0300
changeset 111328 844b142d811163f0c545aadbb021f2d85e4839a4
parent 111327 128b4ccd8d217a566c9564cba4374c8a8eb7b73b
child 111329 689f8d57ff20830846d802dc150b17083333cd20
push id239
push userakeybl@mozilla.com
push dateThu, 03 Jan 2013 21:54:43 +0000
treeherdermozilla-release@3a7b66445659 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan, tbsaunde, smaug
bugs783523
milestone18.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 783523 - Fix platform-specific nsresult misuse; r=ehsan,tbsaunde,smaug
accessible/src/msaa/TextLeafAccessibleWrap.cpp
accessible/src/msaa/TextLeafAccessibleWrap.h
accessible/src/msaa/nsAccessNodeWrap.cpp
browser/components/shell/src/nsWindowsShellService.cpp
embedding/components/printingui/src/mac/nsPrintProgress.cpp
embedding/components/printingui/src/mac/nsPrintProgress.h
embedding/components/printingui/src/win/nsPrintProgress.cpp
embedding/components/printingui/src/win/nsPrintProgress.h
gfx/thebes/gfxDWriteFontList.cpp
js/xpconnect/src/XPCConvert.cpp
js/xpconnect/src/XPCWrappedJSClass.cpp
netwerk/protocol/device/AndroidCaptureProvider.cpp
netwerk/protocol/device/GonkCaptureProvider.cpp
toolkit/xre/nsNativeAppSupportCocoa.mm
toolkit/xre/nsUpdateDriver.cpp
widget/windows/nsDataObj.cpp
widget/windows/nsWindow.cpp
xpcom/base/nsStackWalk.cpp
xpcom/base/nsUUIDGenerator.cpp
xpcom/reflect/xptcall/src/md/unix/xptcinvoke_arm.cpp
xpcom/reflect/xptcall/src/md/unix/xptcinvoke_x86_64_unix.cpp
xpcom/tests/windows/TestCOM.cpp
--- a/accessible/src/msaa/TextLeafAccessibleWrap.cpp
+++ b/accessible/src/msaa/TextLeafAccessibleWrap.cpp
@@ -132,19 +132,19 @@ TextLeafAccessibleWrap::get_unclippedSub
     /* [out] */ int __RPC_FAR *aHeight)
 {
 __try {
   *aX = *aY = *aWidth = *aHeight = 0;
 
   if (IsDefunct())
     return E_FAIL;
 
-  if (NS_FAILED(GetCharacterExtents(aStartIndex, aEndIndex, 
-                                    aX, aY, aWidth, aHeight))) {
-    return NS_ERROR_FAILURE;
+  if (FAILED(GetCharacterExtents(aStartIndex, aEndIndex,
+                                 aX, aY, aWidth, aHeight))) {
+    return E_FAIL;
   }
 } __except(FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
 
   return S_OK;
 }
 
 STDMETHODIMP
 TextLeafAccessibleWrap::scrollToSubstring(
@@ -186,33 +186,33 @@ TextLeafAccessibleWrap::GetPointFromOffs
 
   textFrame->GetPointFromOffset(aOffset, &aOutPoint);
   return textFrame;
 }
 
 /*
  * Given an offset, the x, y, width, and height values are filled appropriately.
  */
-nsresult
+HRESULT
 TextLeafAccessibleWrap::GetCharacterExtents(int32_t aStartOffset,
                                             int32_t aEndOffset,
                                             int32_t* aX,
                                             int32_t* aY,
                                             int32_t* aWidth,
                                             int32_t* aHeight)
 {
   *aX = *aY = *aWidth = *aHeight = 0;
 
   if (IsDefunct())
     return CO_E_OBJNOTCONNECTED;
 
   nsPresContext* presContext = mDoc->PresContext();
 
   nsIFrame *frame = GetFrame();
-  NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE);
+  NS_ENSURE_TRUE(frame, E_FAIL);
 
   nsPoint startPoint, endPoint;
   nsIFrame *startFrame = GetPointFromOffset(frame, aStartOffset, true, startPoint);
   nsIFrame *endFrame = GetPointFromOffset(frame, aEndOffset, false, endPoint);
   if (!startFrame || !endFrame) {
     return E_FAIL;
   }
   
@@ -229,17 +229,17 @@ TextLeafAccessibleWrap::GetCharacterExte
     sum.UnionRect(sum, rect);
   }
 
   *aX      = sum.x;
   *aY      = sum.y;
   *aWidth  = sum.width;
   *aHeight = sum.height;
 
-  return NS_OK;
+  return S_OK;
 }
 
 STDMETHODIMP
 TextLeafAccessibleWrap::get_fontFamily(
     /* [retval][out] */ BSTR __RPC_FAR *aFontFamily)
 {
 __try {
   *aFontFamily = NULL;
--- a/accessible/src/msaa/TextLeafAccessibleWrap.h
+++ b/accessible/src/msaa/TextLeafAccessibleWrap.h
@@ -50,19 +50,19 @@ public:
     virtual HRESULT STDMETHODCALLTYPE scrollToSubstring( 
         /* [in] */ unsigned int startIndex,
         /* [in] */ unsigned int endIndex);
 
     virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_fontFamily( 
         /* [retval][out] */ BSTR __RPC_FAR *fontFamily);
     
   protected:
-    nsresult GetCharacterExtents(int32_t aStartOffset, int32_t aEndOffset,
-                                 int32_t* aX, int32_t* aY, 
-                                 int32_t* aWidth, int32_t* aHeight);
+    HRESULT GetCharacterExtents(int32_t aStartOffset, int32_t aEndOffset,
+                                int32_t* aX, int32_t* aY,
+                                int32_t* aWidth, int32_t* aHeight);
 
     // Return child frame containing offset on success
     nsIFrame* GetPointFromOffset(nsIFrame *aContainingFrame,
                                  int32_t aOffset, bool aPreferNext, nsPoint& aOutPoint);
 };
 
 } // namespace a11y
 } // namespace mozilla
--- a/accessible/src/msaa/nsAccessNodeWrap.cpp
+++ b/accessible/src/msaa/nsAccessNodeWrap.cpp
@@ -51,17 +51,18 @@ NS_IMPL_ISUPPORTS_INHERITED1(nsAccessNod
 
 //-----------------------------------------------------
 // nsIWinAccessNode methods
 //-----------------------------------------------------
 
 NS_IMETHODIMP
 nsAccessNodeWrap::QueryNativeInterface(REFIID aIID, void** aInstancePtr)
 {
-  return QueryInterface(aIID, aInstancePtr);
+  // XXX Wrong for E_NOINTERFACE
+  return static_cast<nsresult>(QueryInterface(aIID, aInstancePtr));
 }
 
 //-----------------------------------------------------
 // IUnknown interface methods - see iunknown.h for documentation
 //-----------------------------------------------------
 
 STDMETHODIMP nsAccessNodeWrap::QueryInterface(REFIID iid, void** ppv)
 {
--- a/browser/components/shell/src/nsWindowsShellService.cpp
+++ b/browser/components/shell/src/nsWindowsShellService.cpp
@@ -608,17 +608,17 @@ nsWindowsShellService::SetDefaultBrowser
     info.pcszClass = NULL;
     info.oaifInFlags = OAIF_FORCE_REGISTRATION | 
                        OAIF_URL_PROTOCOL |
                        OAIF_REGISTER_EXT;
     nsresult rv = DynSHOpenWithDialog(NULL, &info);
     NS_ENSURE_SUCCESS(rv, rv);
     bool isDefaultBrowser = false;
     rv = NS_SUCCEEDED(IsDefaultBrowser(&isDefaultBrowser)) &&
-         isDefaultBrowser ? S_OK : NS_ERROR_FAILURE;
+         isDefaultBrowser ? NS_OK : NS_ERROR_FAILURE;
   }
   return rv;
 }
 
 NS_IMETHODIMP
 nsWindowsShellService::GetShouldCheckDefaultBrowser(bool* aResult)
 {
   NS_ENSURE_ARG_POINTER(aResult);
--- a/embedding/components/printingui/src/mac/nsPrintProgress.cpp
+++ b/embedding/components/printingui/src/mac/nsPrintProgress.cpp
@@ -22,17 +22,17 @@ NS_INTERFACE_MAP_BEGIN(nsPrintProgress)
 NS_INTERFACE_MAP_END_THREADSAFE
 
 
 nsPrintProgress::nsPrintProgress()
 {
   m_closeProgress = false;
   m_processCanceled = false;
   m_pendingStateFlags = -1;
-  m_pendingStateValue = 0;
+  m_pendingStateValue = NS_OK;
 }
 
 nsPrintProgress::~nsPrintProgress()
 {
   (void)ReleaseListeners();
 }
 
 /* void openProgressDialog (in nsIDOMWindow parent, in string dialogURL, in nsISupports parameters); */
@@ -83,17 +83,19 @@ NS_IMETHODIMP nsPrintProgress::OpenProgr
 
   return rv;
 }
 
 /* void closeProgressDialog (in boolean forceClose); */
 NS_IMETHODIMP nsPrintProgress::CloseProgressDialog(bool forceClose)
 {
   m_closeProgress = true;
-  return OnStateChange(nullptr, nullptr, nsIWebProgressListener::STATE_STOP, forceClose);
+  // XXX Casting bool to nsresult
+  return OnStateChange(nullptr, nullptr, nsIWebProgressListener::STATE_STOP,
+                       static_cast<nsresult>(forceClose));
 }
 
 /* nsIPrompt GetPrompter (); */
 NS_IMETHODIMP nsPrintProgress::GetPrompter(nsIPrompt **_retval)
 {
   NS_ENSURE_ARG_POINTER(_retval);
   *_retval = nullptr;
 
@@ -108,17 +110,17 @@ NS_IMETHODIMP nsPrintProgress::GetProces
 {
   NS_ENSURE_ARG_POINTER(aProcessCanceledByUser);
   *aProcessCanceledByUser = m_processCanceled;
   return NS_OK;
 }
 NS_IMETHODIMP nsPrintProgress::SetProcessCanceledByUser(bool aProcessCanceledByUser)
 {
   m_processCanceled = aProcessCanceledByUser;
-  OnStateChange(nullptr, nullptr, nsIWebProgressListener::STATE_STOP, false);
+  OnStateChange(nullptr, nullptr, nsIWebProgressListener::STATE_STOP, NS_OK);
   return NS_OK;
 }
 
 /* void RegisterListener (in nsIWebProgressListener listener); */
 NS_IMETHODIMP nsPrintProgress::RegisterListener(nsIWebProgressListener * listener)
 {
   nsresult rv = NS_OK;
   
@@ -127,20 +129,21 @@ NS_IMETHODIMP nsPrintProgress::RegisterL
   
   if (!m_listenerList)
     rv = NS_NewISupportsArray(getter_AddRefs(m_listenerList));
   
   if (NS_SUCCEEDED(rv) && m_listenerList)
   {
     m_listenerList->AppendElement(listener);
     if (m_closeProgress || m_processCanceled)
-      listener->OnStateChange(nullptr, nullptr, nsIWebProgressListener::STATE_STOP, 0);
+      listener->OnStateChange(nullptr, nullptr,
+                              nsIWebProgressListener::STATE_STOP, NS_OK);
     else
     {
-      listener->OnStatusChange(nullptr, nullptr, 0, m_pendingStatus.get());
+      listener->OnStatusChange(nullptr, nullptr, NS_OK, m_pendingStatus.get());
       if (m_pendingStateFlags != -1)
         listener->OnStateChange(nullptr, nullptr, m_pendingStateFlags, m_pendingStateValue);
     }
   }
     
   return NS_OK;
 }
 
--- a/embedding/components/printingui/src/mac/nsPrintProgress.h
+++ b/embedding/components/printingui/src/mac/nsPrintProgress.h
@@ -28,15 +28,15 @@ public:
 
 private:
   nsresult ReleaseListeners();
 
   bool                              m_closeProgress;
   bool                              m_processCanceled;
   nsString                          m_pendingStatus;
   int32_t                           m_pendingStateFlags;
-  int32_t                           m_pendingStateValue;
+  nsresult                          m_pendingStateValue;
   nsCOMPtr<nsIDOMWindow>            m_dialog;
   nsCOMPtr<nsISupportsArray>        m_listenerList;
   nsCOMPtr<nsIObserver>             m_observer;
 };
 
 #endif
--- a/embedding/components/printingui/src/win/nsPrintProgress.cpp
+++ b/embedding/components/printingui/src/win/nsPrintProgress.cpp
@@ -52,17 +52,17 @@ NS_INTERFACE_MAP_BEGIN(nsPrintProgress)
 NS_INTERFACE_MAP_END_THREADSAFE
 
 
 nsPrintProgress::nsPrintProgress()
 {
   m_closeProgress = false;
   m_processCanceled = false;
   m_pendingStateFlags = -1;
-  m_pendingStateValue = 0;
+  m_pendingStateValue = NS_OK;
 }
 
 nsPrintProgress::~nsPrintProgress()
 {
   (void)ReleaseListeners();
 }
 
 /* void openProgressDialog (in nsIDOMWindow parent, in string dialogURL, in nsISupports parameters); */
@@ -111,17 +111,19 @@ NS_IMETHODIMP nsPrintProgress::OpenProgr
 
   return rv;
 }
 
 /* void closeProgressDialog (in boolean forceClose); */
 NS_IMETHODIMP nsPrintProgress::CloseProgressDialog(bool forceClose)
 {
   m_closeProgress = true;
-  return OnStateChange(nullptr, nullptr, nsIWebProgressListener::STATE_STOP, forceClose);
+  // XXX Casting from bool to nsresult
+  return OnStateChange(nullptr, nullptr, nsIWebProgressListener::STATE_STOP,
+                       static_cast<nsresult>(forceClose));
 }
 
 /* nsIPrompt GetPrompter (); */
 NS_IMETHODIMP nsPrintProgress::GetPrompter(nsIPrompt **_retval)
 {
   NS_ENSURE_ARG_POINTER(_retval);
   *_retval = nullptr;
 
@@ -136,17 +138,17 @@ NS_IMETHODIMP nsPrintProgress::GetProces
 {
   NS_ENSURE_ARG_POINTER(aProcessCanceledByUser);
   *aProcessCanceledByUser = m_processCanceled;
   return NS_OK;
 }
 NS_IMETHODIMP nsPrintProgress::SetProcessCanceledByUser(bool aProcessCanceledByUser)
 {
   m_processCanceled = aProcessCanceledByUser;
-  OnStateChange(nullptr, nullptr, nsIWebProgressListener::STATE_STOP, false);
+  OnStateChange(nullptr, nullptr, nsIWebProgressListener::STATE_STOP, NS_OK);
   return NS_OK;
 }
 
 /* void RegisterListener (in nsIWebProgressListener listener); */
 NS_IMETHODIMP nsPrintProgress::RegisterListener(nsIWebProgressListener * listener)
 {
   nsresult rv = NS_OK;
   
@@ -155,20 +157,21 @@ NS_IMETHODIMP nsPrintProgress::RegisterL
   
   if (!m_listenerList)
     rv = NS_NewISupportsArray(getter_AddRefs(m_listenerList));
   
   if (NS_SUCCEEDED(rv) && m_listenerList)
   {
     m_listenerList->AppendElement(listener);
     if (m_closeProgress || m_processCanceled)
-      listener->OnStateChange(nullptr, nullptr, nsIWebProgressListener::STATE_STOP, 0);
+      listener->OnStateChange(nullptr, nullptr,
+                              nsIWebProgressListener::STATE_STOP, NS_OK);
     else
     {
-      listener->OnStatusChange(nullptr, nullptr, 0, m_pendingStatus.get());
+      listener->OnStatusChange(nullptr, nullptr, NS_OK, m_pendingStatus.get());
       if (m_pendingStateFlags != -1)
         listener->OnStateChange(nullptr, nullptr, m_pendingStateFlags, m_pendingStateValue);
     }
   }
     
   return NS_OK;
 }
 
--- a/embedding/components/printingui/src/win/nsPrintProgress.h
+++ b/embedding/components/printingui/src/win/nsPrintProgress.h
@@ -29,15 +29,15 @@ public:
 
 private:
   nsresult ReleaseListeners();
 
   bool                              m_closeProgress;
   bool                              m_processCanceled;
   nsString                          m_pendingStatus;
   int32_t                           m_pendingStateFlags;
-  int32_t                           m_pendingStateValue;
+  nsresult                          m_pendingStateValue;
   nsCOMPtr<nsIDOMWindow>            m_dialog;
   nsCOMPtr<nsISupportsArray>        m_listenerList;
   nsCOMPtr<nsIObserver>             m_observer;
 };
 
 #endif
--- a/gfx/thebes/gfxDWriteFontList.cpp
+++ b/gfx/thebes/gfxDWriteFontList.cpp
@@ -1209,17 +1209,17 @@ gfxDWriteFontList::SizeOfExcludingThis(n
 void
 gfxDWriteFontList::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
                                        FontListSizes*    aSizes) const
 {
     aSizes->mFontListSize += aMallocSizeOf(this);
     SizeOfExcludingThis(aMallocSizeOf, aSizes);
 }
 
-static nsresult GetFamilyName(IDWriteFont *aFont, nsString& aFamilyName)
+static HRESULT GetFamilyName(IDWriteFont *aFont, nsString& aFamilyName)
 {
     HRESULT hr;
     nsRefPtr<IDWriteFontFamily> family;
 
     // clean out previous value
     aFamilyName.Truncate();
 
     hr = aFont->GetFontFamily(getter_AddRefs(family));
@@ -1251,25 +1251,25 @@ static nsresult GetFamilyName(IDWriteFon
     UINT32 length;
 
     hr = familyNames->GetStringLength(index, &length);
     if (FAILED(hr)) {
         return hr;
     }
 
     if (!name.SetLength(length + 1)) {
-        return NS_ERROR_FAILURE;
+        return E_FAIL;
     }
     hr = familyNames->GetString(index, name.Elements(), length + 1);
     if (FAILED(hr)) {
         return hr;
     }
 
     aFamilyName.Assign(name.Elements());
-    return NS_OK;
+    return S_OK;
 }
 
 // bug 705594 - the method below doesn't actually do any "drawing", it's only
 // used to invoke the DirectWrite layout engine to determine the fallback font
 // for a given character.
 
 IFACEMETHODIMP FontFallbackRenderer::DrawGlyphRun(
     void* clientDrawingContext,
--- a/js/xpconnect/src/XPCConvert.cpp
+++ b/js/xpconnect/src/XPCConvert.cpp
@@ -1277,17 +1277,20 @@ XPCConvert::JSValToXPCException(XPCCallC
                 isResult = true;
             else
                 number = (double) JSVAL_TO_INT(s);
         } else {
             number = JSVAL_TO_DOUBLE(s);
             if (number > 0.0 &&
                 number < (double)0xffffffff &&
                 0.0 == fmod(number,1)) {
-                rv = (nsresult) number;
+                // Visual Studio 9 doesn't allow casting directly from a
+                // double to an enumeration type, contrary to 5.2.9(10) of
+                // C++11, so add an intermediate cast.
+                rv = (nsresult)(uint32_t) number;
                 if (NS_FAILED(rv))
                     isResult = true;
             }
         }
 
         if (isResult)
             return ConstructException(rv, nullptr, ifaceName, methodName,
                                       nullptr, exceptn, cx, &s);
--- a/js/xpconnect/src/XPCWrappedJSClass.cpp
+++ b/js/xpconnect/src/XPCWrappedJSClass.cpp
@@ -289,17 +289,20 @@ nsXPCWrappedJSClass::CallQueryInterfaceO
                             NS_SUCCEEDED(exception->GetResult(&rv)) &&
                             rv == NS_NOINTERFACE) {
                             JS_ClearPendingException(cx);
                         }
                     }
                 } else if (JSVAL_IS_NUMBER(jsexception)) {
                     // JS often throws an nsresult.
                     if (JSVAL_IS_DOUBLE(jsexception))
-                        rv = (nsresult)(JSVAL_TO_DOUBLE(jsexception));
+                        // Visual Studio 9 doesn't allow casting directly from
+                        // a double to an enumeration type, contrary to
+                        // 5.2.9(10) of C++11, so add an intermediate cast.
+                        rv = (nsresult)(uint32_t)(JSVAL_TO_DOUBLE(jsexception));
                     else
                         rv = (nsresult)(JSVAL_TO_INT(jsexception));
 
                     if (rv == NS_NOINTERFACE)
                         JS_ClearPendingException(cx);
                 }
             }
 
--- a/netwerk/protocol/device/AndroidCaptureProvider.cpp
+++ b/netwerk/protocol/device/AndroidCaptureProvider.cpp
@@ -240,17 +240,17 @@ NS_IMETHODIMP AndroidCameraInputStream::
   mCallback = aCallback;
 
   // What we are being asked for may be present already
   NotifyListeners();
   return NS_OK;
 }
 
 
-NS_IMETHODIMP AndroidCameraInputStream::CloseWithStatus(uint32_t status)
+NS_IMETHODIMP AndroidCameraInputStream::CloseWithStatus(nsresult status)
 {
   AndroidCameraInputStream::doClose();
   return NS_OK;
 }
 
 /**
  * AndroidCaptureProvider implementation
  */
--- a/netwerk/protocol/device/GonkCaptureProvider.cpp
+++ b/netwerk/protocol/device/GonkCaptureProvider.cpp
@@ -532,17 +532,17 @@ NS_IMETHODIMP GonkCameraInputStream::Asy
   mCallback = aCallback;
 
   // What we are being asked for may be present already
   NotifyListeners();
   return NS_OK;
 }
 
 
-NS_IMETHODIMP GonkCameraInputStream::CloseWithStatus(uint32_t status)
+NS_IMETHODIMP GonkCameraInputStream::CloseWithStatus(nsresult status)
 {
   GonkCameraInputStream::doClose();
   return NS_OK;
 }
 
 /**
  * GonkCaptureProvider implementation
  */
--- a/toolkit/xre/nsNativeAppSupportCocoa.mm
+++ b/toolkit/xre/nsNativeAppSupportCocoa.mm
@@ -90,17 +90,17 @@ NS_IMETHODIMP nsNativeAppSupportCocoa::S
   // to the console before quitting.
 #ifdef __LP64__
   SInt32 minimumOS = 0x00001060;
 #else
   SInt32 minimumOS = 0x00001050;
 #endif
   if ((err != noErr) || response < minimumOS) {
     NSLog(@"Minimum OS version requirement not met!");
-    return false;
+    return NS_OK;
   }
 
   *_retval = true;
   return NS_OK;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
--- a/toolkit/xre/nsUpdateDriver.cpp
+++ b/toolkit/xre/nsUpdateDriver.cpp
@@ -324,19 +324,22 @@ CopyUpdaterIntoUpdateDir(nsIFile *greDir
     return false;
 #endif
   // Finally, return the location of the updater binary.
   nsresult rv = updateDir->Clone(getter_AddRefs(updater));
   if (NS_FAILED(rv))
     return false;
 #if defined(XP_MACOSX)
   rv  = updater->AppendNative(NS_LITERAL_CSTRING(kUpdaterApp));
-  rv |= updater->AppendNative(NS_LITERAL_CSTRING("Contents"));
-  rv |= updater->AppendNative(NS_LITERAL_CSTRING("MacOS"));
-  if (NS_FAILED(rv))
+  nsresult tmp = updater->AppendNative(NS_LITERAL_CSTRING("Contents"));
+  if (NS_FAILED(tmp)) {
+    rv = tmp;
+  }
+  tmp = updater->AppendNative(NS_LITERAL_CSTRING("MacOS"));
+  if (NS_FAILED(tmp) || NS_FAILED(rv))
     return false;
 #endif
   rv = updater->AppendNative(NS_LITERAL_CSTRING(kUpdaterBin));
   return NS_SUCCEEDED(rv); 
 }
 
 /**
  * Switch an existing application directory to an updated version which has been
--- a/widget/windows/nsDataObj.cpp
+++ b/widget/windows/nsDataObj.cpp
@@ -1560,18 +1560,18 @@ HRESULT nsDataObj::DropTempFile(FORMATET
     IStream *pStream = NULL;
     nsDataObj::CreateStream(&pStream);
     NS_ENSURE_TRUE(pStream, E_FAIL);
 
     char buffer[512];
     ULONG readCount = 0;
     uint32_t writeCount = 0;
     while (1) {
-      rv = pStream->Read(buffer, sizeof(buffer), &readCount);
-      if (NS_FAILED(rv))
+      HRESULT hres = pStream->Read(buffer, sizeof(buffer), &readCount);
+      if (FAILED(hres))
         return E_FAIL;
       if (readCount == 0)
         break;
       rv = outStream->Write(buffer, readCount, &writeCount);
       if (NS_FAILED(rv))
         return E_FAIL;
     }
     outStream->Close();
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -2192,17 +2192,17 @@ nsWindow::SetNonClientMargins(nsIntMargi
   if (margins.top < -1 || margins.bottom < -1 ||
       margins.left < -1 || margins.right < -1)
     return NS_ERROR_INVALID_ARG;
 
   mNonClientMargins = margins;
   mCustomNonClient = true;
   if (!UpdateNonClientMargins()) {
     NS_WARNING("UpdateNonClientMargins failed!");
-    return false;
+    return NS_OK;
   }
 
   return NS_OK;
 }
 
 void
 nsWindow::InvalidateNonClientRegion()
 {
--- a/xpcom/base/nsStackWalk.cpp
+++ b/xpcom/base/nsStackWalk.cpp
@@ -451,17 +451,17 @@ NS_StackWalk(NS_WalkStackCallback aCallb
 {
     MOZ_ASSERT(gCriticalAddress.mInit);
     static HANDLE myProcess = NULL;
     HANDLE myThread;
     DWORD walkerReturn;
     struct WalkStackData data;
 
     if (!EnsureImageHlpInitialized())
-        return false;
+        return NS_OK;
 
     HANDLE targetThread = ::GetCurrentThread();
     data.walkCallingThread = true;
     if (aThread) {
         HANDLE threadToWalk = reinterpret_cast<HANDLE> (aThread);
         // walkCallingThread indicates whether we are walking the caller's stack
         data.walkCallingThread = (threadToWalk == targetThread);
         targetThread = threadToWalk;
--- a/xpcom/base/nsUUIDGenerator.cpp
+++ b/xpcom/base/nsUUIDGenerator.cpp
@@ -95,17 +95,17 @@ NS_IMETHODIMP
 nsUUIDGenerator::GenerateUUIDInPlace(nsID* id)
 {
     // The various code in this method is probably not threadsafe, so lock
     // across the whole method.
     MutexAutoLock lock(mLock);
 
 #if defined(XP_WIN)
     HRESULT hr = CoCreateGuid((GUID*)id);
-    if (NS_FAILED(hr))
+    if (FAILED(hr))
         return NS_ERROR_FAILURE;
 #elif defined(XP_MACOSX)
     CFUUIDRef uuid = CFUUIDCreate(kCFAllocatorDefault);
     if (!uuid)
         return NS_ERROR_FAILURE;
 
     CFUUIDBytes bytes = CFUUIDGetUUIDBytes(uuid);
     memcpy(id, &bytes, sizeof(nsID));
--- a/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_arm.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_arm.cpp
@@ -103,17 +103,17 @@ invoke_copy_to_stack(uint32_t* stk, uint
         default:
             // all the others are plain pointer types
             *((void**)d) = s->val.p;
             break;
         }
     }
 }
 
-typedef uint32_t (*vtable_func)(nsISupports *, uint32_t, uint32_t, uint32_t);
+typedef nsresult (*vtable_func)(nsISupports *, uint32_t, uint32_t, uint32_t);
 
 EXPORT_XPCOM_API(nsresult)
 NS_InvokeByIndex(nsISupports* that, uint32_t methodIndex,
                    uint32_t paramCount, nsXPTCVariant* params)
 {
 
 /* This is to call a given method of class that.
  * The parameters are in params, the number is in paramCount.
--- a/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_x86_64_unix.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_x86_64_unix.cpp
@@ -151,16 +151,16 @@ NS_InvokeByIndex_P(nsISupports * that, u
     a1 = gpregs[1];
     a0 = (uint64_t) that;
 
     // Get pointer to method
     uint64_t methodAddress = *((uint64_t *)that);
     methodAddress += 8 * methodIndex;
     methodAddress = *((uint64_t *)methodAddress);
     
-    typedef uint32_t (*Method)(uint64_t, uint64_t, uint64_t, uint64_t,
+    typedef nsresult (*Method)(uint64_t, uint64_t, uint64_t, uint64_t,
                                uint64_t, uint64_t, double, double, double,
                                double, double, double, double, double);
-    uint32_t result = ((Method)methodAddress)(a0, a1, a2, a3, a4, a5,
+    nsresult result = ((Method)methodAddress)(a0, a1, a2, a3, a4, a5,
                                               d0, d1, d2, d3, d4, d5,
                                               d6, d7);
     return result;
 }
--- a/xpcom/tests/windows/TestCOM.cpp
+++ b/xpcom/tests/windows/TestCOM.cpp
@@ -78,17 +78,17 @@ public:
   NS_IMETHOD CreateInstance(nsISupports *aOuter,
                             const nsIID &aIID,
                             void **aResult);
 
   NS_IMETHOD LockFactory(bool aLock) {
     printf("nsTestComFactory: ");
     printf("%s", (aLock ? "Locking server" : "Unlocking server"));
     printf("\n");
-    return S_OK;
+    return NS_OK;
   }
 };
 
 NS_IMPL_ISUPPORTS1(nsTestComFactory, nsIFactory)
 
 nsresult nsTestComFactory::CreateInstance(nsISupports *aOuter,
 					  const nsIID &aIID,
 					  void **aResult)
@@ -122,21 +122,18 @@ int main(int argc, char *argv[])
 {
   nsTestComFactory *inst = new nsTestComFactory();
   IClassFactory *iFactory;
   inst->QueryInterface(NS_GET_IID(nsIFactory), (void **) &iFactory);
 
   IUnknown *iUnknown;  
   nsITestCom *iTestCom;
 
-  nsresult res;
   iFactory->LockServer(TRUE);
-  res = iFactory->CreateInstance(NULL,
-				 IID_IUnknown, 
-				 (void **) &iUnknown);
+  iFactory->CreateInstance(NULL, IID_IUnknown, (void **) &iUnknown);
   iFactory->LockServer(FALSE);
 
   GUID testGUID = NS_ITEST_COM_IID;
   HRESULT hres;
   hres= iUnknown->QueryInterface(testGUID, 
 				 (void **) &iTestCom);
 
   iTestCom->Test();