diff --git a/accessible/src/msaa/TextLeafAccessibleWrap.cpp b/accessible/src/msaa/TextLeafAccessibleWrap.cpp index 2909a97673f5..fc9a63a19633 100644 --- a/accessible/src/msaa/TextLeafAccessibleWrap.cpp +++ b/accessible/src/msaa/TextLeafAccessibleWrap.cpp @@ -137,9 +137,9 @@ __try { 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())) { } @@ -191,7 +191,7 @@ TextLeafAccessibleWrap::GetPointFromOffset(nsIFrame* aContainingFrame, /* * 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, @@ -207,7 +207,7 @@ TextLeafAccessibleWrap::GetCharacterExtents(int32_t aStartOffset, 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); @@ -234,7 +234,7 @@ TextLeafAccessibleWrap::GetCharacterExtents(int32_t aStartOffset, *aWidth = sum.width; *aHeight = sum.height; - return NS_OK; + return S_OK; } STDMETHODIMP diff --git a/accessible/src/msaa/TextLeafAccessibleWrap.h b/accessible/src/msaa/TextLeafAccessibleWrap.h index 09f5aad79699..8d85400aa382 100644 --- a/accessible/src/msaa/TextLeafAccessibleWrap.h +++ b/accessible/src/msaa/TextLeafAccessibleWrap.h @@ -55,9 +55,9 @@ public: /* [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, diff --git a/accessible/src/msaa/nsAccessNodeWrap.cpp b/accessible/src/msaa/nsAccessNodeWrap.cpp index 0769aeeb2687..420724af683e 100644 --- a/accessible/src/msaa/nsAccessNodeWrap.cpp +++ b/accessible/src/msaa/nsAccessNodeWrap.cpp @@ -56,7 +56,8 @@ NS_IMPL_ISUPPORTS_INHERITED1(nsAccessNodeWrap, nsAccessNode, nsIWinAccessNode); NS_IMETHODIMP nsAccessNodeWrap::QueryNativeInterface(REFIID aIID, void** aInstancePtr) { - return QueryInterface(aIID, aInstancePtr); + // XXX Wrong for E_NOINTERFACE + return static_cast(QueryInterface(aIID, aInstancePtr)); } //----------------------------------------------------- diff --git a/browser/components/shell/src/nsWindowsShellService.cpp b/browser/components/shell/src/nsWindowsShellService.cpp index e71677fd5bfe..5ee8306090fc 100644 --- a/browser/components/shell/src/nsWindowsShellService.cpp +++ b/browser/components/shell/src/nsWindowsShellService.cpp @@ -613,7 +613,7 @@ nsWindowsShellService::SetDefaultBrowser(bool aClaimAllTypes, bool aForAllUsers) 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; } diff --git a/embedding/components/printingui/src/mac/nsPrintProgress.cpp b/embedding/components/printingui/src/mac/nsPrintProgress.cpp index 053850a4fb12..71795f43e5ae 100644 --- a/embedding/components/printingui/src/mac/nsPrintProgress.cpp +++ b/embedding/components/printingui/src/mac/nsPrintProgress.cpp @@ -27,7 +27,7 @@ nsPrintProgress::nsPrintProgress() m_closeProgress = false; m_processCanceled = false; m_pendingStateFlags = -1; - m_pendingStateValue = 0; + m_pendingStateValue = NS_OK; } nsPrintProgress::~nsPrintProgress() @@ -88,7 +88,9 @@ NS_IMETHODIMP nsPrintProgress::OpenProgressDialog(nsIDOMWindow *parent, 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(forceClose)); } /* nsIPrompt GetPrompter (); */ @@ -113,7 +115,7 @@ NS_IMETHODIMP nsPrintProgress::GetProcessCanceledByUser(bool *aProcessCanceledBy 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; } @@ -132,10 +134,11 @@ NS_IMETHODIMP nsPrintProgress::RegisterListener(nsIWebProgressListener * listene { 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); } diff --git a/embedding/components/printingui/src/mac/nsPrintProgress.h b/embedding/components/printingui/src/mac/nsPrintProgress.h index fd219b8b6111..527643b3d91b 100644 --- a/embedding/components/printingui/src/mac/nsPrintProgress.h +++ b/embedding/components/printingui/src/mac/nsPrintProgress.h @@ -33,7 +33,7 @@ private: bool m_processCanceled; nsString m_pendingStatus; int32_t m_pendingStateFlags; - int32_t m_pendingStateValue; + nsresult m_pendingStateValue; nsCOMPtr m_dialog; nsCOMPtr m_listenerList; nsCOMPtr m_observer; diff --git a/embedding/components/printingui/src/win/nsPrintProgress.cpp b/embedding/components/printingui/src/win/nsPrintProgress.cpp index 53b0f6d891fe..ff5537aeadd0 100644 --- a/embedding/components/printingui/src/win/nsPrintProgress.cpp +++ b/embedding/components/printingui/src/win/nsPrintProgress.cpp @@ -57,7 +57,7 @@ nsPrintProgress::nsPrintProgress() m_closeProgress = false; m_processCanceled = false; m_pendingStateFlags = -1; - m_pendingStateValue = 0; + m_pendingStateValue = NS_OK; } nsPrintProgress::~nsPrintProgress() @@ -116,7 +116,9 @@ NS_IMETHODIMP nsPrintProgress::OpenProgressDialog(nsIDOMWindow *parent, 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(forceClose)); } /* nsIPrompt GetPrompter (); */ @@ -141,7 +143,7 @@ NS_IMETHODIMP nsPrintProgress::GetProcessCanceledByUser(bool *aProcessCanceledBy 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; } @@ -160,10 +162,11 @@ NS_IMETHODIMP nsPrintProgress::RegisterListener(nsIWebProgressListener * listene { 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); } diff --git a/embedding/components/printingui/src/win/nsPrintProgress.h b/embedding/components/printingui/src/win/nsPrintProgress.h index b126fd3775f8..aef54e68c967 100644 --- a/embedding/components/printingui/src/win/nsPrintProgress.h +++ b/embedding/components/printingui/src/win/nsPrintProgress.h @@ -34,7 +34,7 @@ private: bool m_processCanceled; nsString m_pendingStatus; int32_t m_pendingStateFlags; - int32_t m_pendingStateValue; + nsresult m_pendingStateValue; nsCOMPtr m_dialog; nsCOMPtr m_listenerList; nsCOMPtr m_observer; diff --git a/gfx/thebes/gfxDWriteFontList.cpp b/gfx/thebes/gfxDWriteFontList.cpp index b4de81394243..c7ebddd3cc84 100644 --- a/gfx/thebes/gfxDWriteFontList.cpp +++ b/gfx/thebes/gfxDWriteFontList.cpp @@ -1214,7 +1214,7 @@ gfxDWriteFontList::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, SizeOfExcludingThis(aMallocSizeOf, aSizes); } -static nsresult GetFamilyName(IDWriteFont *aFont, nsString& aFamilyName) +static HRESULT GetFamilyName(IDWriteFont *aFont, nsString& aFamilyName) { HRESULT hr; nsRefPtr family; @@ -1256,7 +1256,7 @@ static nsresult GetFamilyName(IDWriteFont *aFont, nsString& aFamilyName) } if (!name.SetLength(length + 1)) { - return NS_ERROR_FAILURE; + return E_FAIL; } hr = familyNames->GetString(index, name.Elements(), length + 1); if (FAILED(hr)) { @@ -1264,7 +1264,7 @@ static nsresult GetFamilyName(IDWriteFont *aFont, nsString& aFamilyName) } aFamilyName.Assign(name.Elements()); - return NS_OK; + return S_OK; } // bug 705594 - the method below doesn't actually do any "drawing", it's only diff --git a/js/xpconnect/src/XPCConvert.cpp b/js/xpconnect/src/XPCConvert.cpp index 9062939420eb..6d63b9d44857 100644 --- a/js/xpconnect/src/XPCConvert.cpp +++ b/js/xpconnect/src/XPCConvert.cpp @@ -1282,7 +1282,10 @@ XPCConvert::JSValToXPCException(XPCCallContext& ccx, 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; } diff --git a/js/xpconnect/src/XPCWrappedJSClass.cpp b/js/xpconnect/src/XPCWrappedJSClass.cpp index 883819d2db0c..1d3efc523d2e 100644 --- a/js/xpconnect/src/XPCWrappedJSClass.cpp +++ b/js/xpconnect/src/XPCWrappedJSClass.cpp @@ -294,7 +294,10 @@ nsXPCWrappedJSClass::CallQueryInterfaceOnJSObject(XPCCallContext& ccx, } 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)); diff --git a/netwerk/protocol/device/AndroidCaptureProvider.cpp b/netwerk/protocol/device/AndroidCaptureProvider.cpp index 133b12f4b14d..fd0daa6f659b 100644 --- a/netwerk/protocol/device/AndroidCaptureProvider.cpp +++ b/netwerk/protocol/device/AndroidCaptureProvider.cpp @@ -245,7 +245,7 @@ NS_IMETHODIMP AndroidCameraInputStream::AsyncWait(nsIInputStreamCallback *aCallb } -NS_IMETHODIMP AndroidCameraInputStream::CloseWithStatus(uint32_t status) +NS_IMETHODIMP AndroidCameraInputStream::CloseWithStatus(nsresult status) { AndroidCameraInputStream::doClose(); return NS_OK; diff --git a/netwerk/protocol/device/GonkCaptureProvider.cpp b/netwerk/protocol/device/GonkCaptureProvider.cpp index f30a450c9b0e..94b6a45faab0 100644 --- a/netwerk/protocol/device/GonkCaptureProvider.cpp +++ b/netwerk/protocol/device/GonkCaptureProvider.cpp @@ -537,7 +537,7 @@ NS_IMETHODIMP GonkCameraInputStream::AsyncWait(nsIInputStreamCallback *aCallback } -NS_IMETHODIMP GonkCameraInputStream::CloseWithStatus(uint32_t status) +NS_IMETHODIMP GonkCameraInputStream::CloseWithStatus(nsresult status) { GonkCameraInputStream::doClose(); return NS_OK; diff --git a/toolkit/xre/nsNativeAppSupportCocoa.mm b/toolkit/xre/nsNativeAppSupportCocoa.mm index 7585db2fb03c..689702cae9ac 100644 --- a/toolkit/xre/nsNativeAppSupportCocoa.mm +++ b/toolkit/xre/nsNativeAppSupportCocoa.mm @@ -95,7 +95,7 @@ NS_IMETHODIMP nsNativeAppSupportCocoa::Start(bool *_retval) #endif if ((err != noErr) || response < minimumOS) { NSLog(@"Minimum OS version requirement not met!"); - return false; + return NS_OK; } *_retval = true; diff --git a/toolkit/xre/nsUpdateDriver.cpp b/toolkit/xre/nsUpdateDriver.cpp index f8a41b415c5d..5acfc5626ab4 100644 --- a/toolkit/xre/nsUpdateDriver.cpp +++ b/toolkit/xre/nsUpdateDriver.cpp @@ -329,9 +329,12 @@ CopyUpdaterIntoUpdateDir(nsIFile *greDir, nsIFile *appDir, nsIFile *updateDir, 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)); diff --git a/widget/windows/nsDataObj.cpp b/widget/windows/nsDataObj.cpp index 40441ada206b..c1b80479eb48 100644 --- a/widget/windows/nsDataObj.cpp +++ b/widget/windows/nsDataObj.cpp @@ -1565,8 +1565,8 @@ HRESULT nsDataObj::DropTempFile(FORMATETC& aFE, STGMEDIUM& aSTG) 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; diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp index c27649e8bde7..b6b27083233a 100644 --- a/widget/windows/nsWindow.cpp +++ b/widget/windows/nsWindow.cpp @@ -2197,7 +2197,7 @@ nsWindow::SetNonClientMargins(nsIntMargin &margins) mCustomNonClient = true; if (!UpdateNonClientMargins()) { NS_WARNING("UpdateNonClientMargins failed!"); - return false; + return NS_OK; } return NS_OK; diff --git a/xpcom/base/nsStackWalk.cpp b/xpcom/base/nsStackWalk.cpp index 3aeda3b6acc6..e7f748492190 100644 --- a/xpcom/base/nsStackWalk.cpp +++ b/xpcom/base/nsStackWalk.cpp @@ -456,7 +456,7 @@ NS_StackWalk(NS_WalkStackCallback aCallback, uint32_t aSkipFrames, struct WalkStackData data; if (!EnsureImageHlpInitialized()) - return false; + return NS_OK; HANDLE targetThread = ::GetCurrentThread(); data.walkCallingThread = true; diff --git a/xpcom/base/nsUUIDGenerator.cpp b/xpcom/base/nsUUIDGenerator.cpp index 2e4b317ce4dd..5f07cb4f1e90 100644 --- a/xpcom/base/nsUUIDGenerator.cpp +++ b/xpcom/base/nsUUIDGenerator.cpp @@ -100,7 +100,7 @@ nsUUIDGenerator::GenerateUUIDInPlace(nsID* id) #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); diff --git a/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_arm.cpp b/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_arm.cpp index c82b9b8723fb..7e507d500049 100644 --- a/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_arm.cpp +++ b/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_arm.cpp @@ -108,7 +108,7 @@ invoke_copy_to_stack(uint32_t* stk, uint32_t *end, } } -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, diff --git a/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_x86_64_unix.cpp b/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_x86_64_unix.cpp index 77cfa6f547d1..6aff3b069b6d 100644 --- a/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_x86_64_unix.cpp +++ b/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_x86_64_unix.cpp @@ -156,10 +156,10 @@ NS_InvokeByIndex_P(nsISupports * that, uint32_t methodIndex, 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; diff --git a/xpcom/tests/windows/TestCOM.cpp b/xpcom/tests/windows/TestCOM.cpp index f707b586416d..4327f7a356d3 100644 --- a/xpcom/tests/windows/TestCOM.cpp +++ b/xpcom/tests/windows/TestCOM.cpp @@ -83,7 +83,7 @@ public: printf("nsTestComFactory: "); printf("%s", (aLock ? "Locking server" : "Unlocking server")); printf("\n"); - return S_OK; + return NS_OK; } }; @@ -127,11 +127,8 @@ int main(int argc, char *argv[]) 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;