From 9f23801918dffba0ad329c98b28f4108a15c8578 Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Mon, 13 Aug 2012 16:32:28 +0300 Subject: [PATCH] Bug 782252 - Cast some nsresult to bool where the function really returns bool; r=ehsan --- netwerk/base/src/nsLoadGroup.cpp | 3 ++- xpcom/io/nsDirectoryService.cpp | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/netwerk/base/src/nsLoadGroup.cpp b/netwerk/base/src/nsLoadGroup.cpp index b23c4cf0307..9e018361315 100644 --- a/netwerk/base/src/nsLoadGroup.cpp +++ b/netwerk/base/src/nsLoadGroup.cpp @@ -723,7 +723,8 @@ AppendRequestsToISupportsArray(PLDHashTable *table, PLDHashEntryHdr *hdr, RequestMapEntry *e = static_cast(hdr); nsISupportsArray *array = static_cast(arg); - bool ok = array->AppendElement(e->mKey); + // nsISupportsArray::AppendElement returns a bool disguised as nsresult + bool ok = static_cast(array->AppendElement(e->mKey)); if (!ok) { return PL_DHASH_STOP; diff --git a/xpcom/io/nsDirectoryService.cpp b/xpcom/io/nsDirectoryService.cpp index ff904c732e4..a6944dc00a0 100644 --- a/xpcom/io/nsDirectoryService.cpp +++ b/xpcom/io/nsDirectoryService.cpp @@ -280,7 +280,9 @@ nsDirectoryService::RealInit() if (!defaultProvider) return NS_ERROR_OUT_OF_MEMORY; // AppendElement returns true for success. - rv = ((nsDirectoryService*) self)->mProviders->AppendElement(defaultProvider) ? NS_OK : NS_ERROR_FAILURE; + rv = static_cast(((nsDirectoryService*) self) + ->mProviders->AppendElement(defaultProvider)) + ? NS_OK : NS_ERROR_FAILURE; if (NS_FAILED(rv)) return rv; @@ -488,7 +490,8 @@ nsDirectoryService::RegisterProvider(nsIDirectoryServiceProvider *prov) if (NS_FAILED(rv)) return rv; // AppendElement returns true for success. - return mProviders->AppendElement(supports) ? NS_OK : NS_ERROR_FAILURE; + return static_cast(mProviders->AppendElement(supports)) + ? NS_OK : NS_ERROR_FAILURE; } void @@ -536,7 +539,8 @@ nsDirectoryService::UnregisterProvider(nsIDirectoryServiceProvider *prov) if (NS_FAILED(rv)) return rv; // RemoveElement returns true for success. - return mProviders->RemoveElement(supports) ? NS_OK : NS_ERROR_FAILURE; + return static_cast(mProviders->RemoveElement(supports)) + ? NS_OK : NS_ERROR_FAILURE; } // DO NOT ADD ANY LOCATIONS TO THIS FUNCTION UNTIL YOU TALK TO: dougt@netscape.com.