Bug 782252 - Cast some nsresult to bool where the function really returns bool; r=ehsan

This commit is contained in:
Aryeh Gregor 2012-08-13 16:32:28 +03:00
parent 0a8f6b4783
commit 105b55a935
2 changed files with 9 additions and 4 deletions

View File

@ -723,7 +723,8 @@ AppendRequestsToISupportsArray(PLDHashTable *table, PLDHashEntryHdr *hdr,
RequestMapEntry *e = static_cast<RequestMapEntry *>(hdr);
nsISupportsArray *array = static_cast<nsISupportsArray *>(arg);
bool ok = array->AppendElement(e->mKey);
// nsISupportsArray::AppendElement returns a bool disguised as nsresult
bool ok = static_cast<bool>(array->AppendElement(e->mKey));
if (!ok) {
return PL_DHASH_STOP;

View File

@ -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<bool>(((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<bool>(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<bool>(mProviders->RemoveElement(supports))
? NS_OK : NS_ERROR_FAILURE;
}
// DO NOT ADD ANY LOCATIONS TO THIS FUNCTION UNTIL YOU TALK TO: dougt@netscape.com.