Bug 675472 - Incorrect return of NS_ERROR_* codes in functions returning PRBool, r=standard8
authorMichael Wu <mwu@mozilla.com>
Tue, 09 Aug 2011 01:43:55 -0700
changeset 8267 53a2ab49111744ae0d4b9a1b9129ab642dcfa3ec
parent 8266 ef977dca2337aebabfd77af8d02a9d8a394d849b
child 8268 aa8e3dd28126cbf653c0a7ff26b43fbc5efcb732
push id6359
push usermwu@mozilla.com
push dateTue, 09 Aug 2011 08:46:03 +0000
treeherdercomm-central@53a2ab491117 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersstandard8
bugs675472
Bug 675472 - Incorrect return of NS_ERROR_* codes in functions returning PRBool, r=standard8
mail/components/migration/src/nsProfileMigrator.cpp
mailnews/addrbook/src/nsAbMDBDirectory.cpp
mailnews/addrbook/src/nsAddrDatabase.cpp
mailnews/addrbook/src/nsDirPrefs.cpp
mailnews/base/src/nsMsgContentPolicy.cpp
mailnews/imap/src/nsImapMailFolder.cpp
mailnews/imap/src/nsImapProtocol.cpp
mailnews/local/src/nsMovemailService.cpp
mailnews/news/src/nsNewsDownloader.cpp
--- a/mail/components/migration/src/nsProfileMigrator.cpp
+++ b/mail/components/migration/src/nsProfileMigrator.cpp
@@ -193,21 +193,21 @@ nsProfileMigrator::Import()
 
 PRBool
 nsProfileMigrator::ImportRegistryProfiles(const nsACString& aAppName)
 {
   nsresult rv;
 
   nsCOMPtr<nsIToolkitProfileService> profileSvc
     (do_GetService(NS_PROFILESERVICE_CONTRACTID));
-  NS_ENSURE_TRUE(profileSvc, NS_ERROR_FAILURE);
+  NS_ENSURE_TRUE(profileSvc, PR_FALSE);
 
   nsCOMPtr<nsIProperties> dirService
     (do_GetService("@mozilla.org/file/directory_service;1"));
-  NS_ENSURE_TRUE(dirService, NS_ERROR_FAILURE);
+  NS_ENSURE_TRUE(dirService, PR_FALSE);
 
   nsCOMPtr<nsILocalFile> regFile;
 #ifdef XP_WIN
   rv = dirService->Get(NS_WIN_APPDATA_DIR, NS_GET_IID(nsILocalFile),
                        getter_AddRefs(regFile));
   NS_ENSURE_SUCCESS(rv, PR_FALSE);
   regFile->AppendNative(aAppName);
   regFile->AppendNative(NS_LITERAL_CSTRING("registry.dat"));
--- a/mailnews/addrbook/src/nsAbMDBDirectory.cpp
+++ b/mailnews/addrbook/src/nsAbMDBDirectory.cpp
@@ -789,17 +789,17 @@ NS_IMETHODIMP nsAbMDBDirectory::EditMail
   return NS_OK;
 }
 
 static PRBool ContainsDirectory(nsIAbDirectory *parent, nsIAbDirectory *directory)
 {
   // If parent is a maillist, 'addressLists' contains AbCards.
   PRBool bIsMailList = PR_FALSE;
   nsresult rv = parent->GetIsMailList(&bIsMailList);
-  NS_ENSURE_SUCCESS(rv, rv);
+  NS_ENSURE_SUCCESS(rv, PR_FALSE);
 
   if (bIsMailList)
     return PR_FALSE;
 
   nsCOMPtr<nsIMutableArray> pAddressLists;
   parent->GetAddressLists(getter_AddRefs(pAddressLists));
   if (pAddressLists)
   {
--- a/mailnews/addrbook/src/nsAddrDatabase.cpp
+++ b/mailnews/addrbook/src/nsAddrDatabase.cpp
@@ -3263,17 +3263,17 @@ NS_IMETHODIMP nsAddrDatabase::GetCardCou
 
     return rv;
 }
 
 PRBool
 nsAddrDatabase::HasRowButDeletedForCharColumn(const PRUnichar *unicodeStr, mdb_column findColumn, PRBool aIsCard, nsIMdbRow **aFindRow)
 {
   if (!m_mdbStore || !aFindRow || !m_mdbEnv)
-    return NS_ERROR_NULL_POINTER;
+    return PR_FALSE;
 
   mdbYarn    sourceYarn;
 
   NS_ConvertUTF16toUTF8 UTF8String(unicodeStr);
   sourceYarn.mYarn_Buf = (void *) UTF8String.get();
   sourceYarn.mYarn_Fill = UTF8String.Length();
   sourceYarn.mYarn_Form = 0;
   sourceYarn.mYarn_Size = sourceYarn.mYarn_Fill;
--- a/mailnews/addrbook/src/nsDirPrefs.cpp
+++ b/mailnews/addrbook/src/nsDirPrefs.cpp
@@ -362,17 +362,17 @@ static void DIR_InitServer(DIR_Server *s
  *                    is already in the list, does nothing.
  *   DIR_POS_DELETE - Deletes the given server from the list.  Note that this
  *                    does not cause the server structure to be freed.
  *
  * Returns PR_TRUE if the server list was re-sorted.
  */
 static PRBool DIR_SetServerPosition(nsVoidArray *wholeList, DIR_Server *server, PRInt32 position)
  {
-   NS_ENSURE_ARG_POINTER(wholeList);
+   NS_ENSURE_TRUE(wholeList, PR_FALSE);
 
    PRInt32    i, count, num;
    PRBool     resort = PR_FALSE;
    DIR_Server *s=nsnull;
    
    switch (position) {
    case DIR_POS_APPEND:
    /* Do nothing if the request is to append a server that is already
--- a/mailnews/base/src/nsMsgContentPolicy.cpp
+++ b/mailnews/base/src/nsMsgContentPolicy.cpp
@@ -148,17 +148,17 @@ nsMsgContentPolicy::ShouldAcceptRemoteCo
   nsCOMPtr<nsIAbDirectory> directory;
   nsCOMPtr<nsIAbCard> cardForAddress;
   PRBool hasMore;
 
   while (NS_SUCCEEDED(enumerator->HasMoreElements(&hasMore)) && hasMore &&
          !cardForAddress)
   {
     rv = enumerator->GetNext(getter_AddRefs(supports));
-    NS_ENSURE_SUCCESS(rv, rv);
+    NS_ENSURE_SUCCESS(rv, PR_FALSE);
     directory = do_QueryInterface(supports);
     if (directory)
     {
       rv = directory->CardForEmailAddress(emailAddress, getter_AddRefs(cardForAddress));
       if (NS_FAILED(rv) && rv != NS_ERROR_NOT_IMPLEMENTED)
         return PR_FALSE;
     }
   }
--- a/mailnews/imap/src/nsImapMailFolder.cpp
+++ b/mailnews/imap/src/nsImapMailFolder.cpp
@@ -2566,17 +2566,17 @@ nsImapMailFolder::DeleteSubFolders(nsIAr
 /*static*/
 PRBool nsImapMailFolder::ShouldCheckAllFolders(nsIImapIncomingServer *imapServer)
 {
   // Check legacy global preference to see if we should check all folders for
   // new messages, or just the inbox and marked ones.
   PRBool checkAllFolders = PR_FALSE;
   nsresult rv;
   nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
+  NS_ENSURE_SUCCESS(rv, PR_FALSE);
   // This pref might not exist, which is OK.
   (void) prefBranch->GetBoolPref("mail.check_all_imap_folders_for_new", &checkAllFolders);
 
   if (checkAllFolders)
     return PR_TRUE;
 
   // If the legacy preference doesn't exist or has its default value (False),
   // the true preference is read.
--- a/mailnews/imap/src/nsImapProtocol.cpp
+++ b/mailnews/imap/src/nsImapProtocol.cpp
@@ -1656,17 +1656,18 @@ PRBool nsImapProtocol::ProcessCurrentURL
             && (GetServerStateParser().GetCapabilityFlag() & kHasStartTLSCapability))
           || m_socketType == nsMsgSocketType::alwaysSTARTTLS)
         {
           StartTLS();
           if (GetServerStateParser().LastCommandSuccessful())
           {
             nsCOMPtr<nsISupports> secInfo;
             nsCOMPtr<nsISocketTransport> strans = do_QueryInterface(m_transport, &rv);
-            if (NS_FAILED(rv)) return rv;
+            if (NS_FAILED(rv))
+              return PR_FALSE;
 
             rv = strans->GetSecurityInfo(getter_AddRefs(secInfo));
 
             if (NS_SUCCEEDED(rv) && secInfo)
             {
               nsCOMPtr<nsISSLSocketControl> sslControl = do_QueryInterface(secInfo, &rv);
 
               if (NS_SUCCEEDED(rv) && sslControl)
--- a/mailnews/local/src/nsMovemailService.cpp
+++ b/mailnews/local/src/nsMovemailService.cpp
@@ -157,17 +157,17 @@ nsMovemailService::Error(PRInt32 errorCo
   }
 }
 
 
 PRBool ObtainSpoolLock(const char *aSpoolName,
                        int aSeconds /* number of seconds to retry */,
                        PRBool *aUsingLockFile)
 {
-  NS_ENSURE_ARG_POINTER(aUsingLockFile);
+  NS_ENSURE_TRUE(aUsingLockFile, PR_FALSE);
 
   /*
    * Locking procedures:
    * If the directory is not writable, we want to use the appropriate system
    * utilites to lock the file.
    * If the directory is writable, we want to go through the create-and-link
    * locking procedures to make it atomic for certain networked file systems.
    * This involves creating a .mozlock file and attempting to hard-link it to
--- a/mailnews/news/src/nsNewsDownloader.cpp
+++ b/mailnews/news/src/nsNewsDownloader.cpp
@@ -163,17 +163,17 @@ PRBool DownloadNewsArticlesToOfflineStor
 
   PRBool hasMore = PR_FALSE;
 
   while (NS_SUCCEEDED(rv = m_headerEnumerator->HasMoreElements(&hasMore)) && hasMore)
   {
     nsCOMPtr <nsISupports> supports;
     rv = m_headerEnumerator->GetNext(getter_AddRefs(supports));
     m_newsHeader = do_QueryInterface(supports);
-    NS_ENSURE_SUCCESS(rv,rv);
+    NS_ENSURE_SUCCESS(rv, PR_FALSE);
     PRUint32 hdrFlags;
     m_newsHeader->GetFlags(&hdrFlags);
     if (hdrFlags & nsMsgMessageFlags::Marked)
     {
       m_newsHeader->GetMessageKey(&m_keyToDownload);
       break;
     }
     else
@@ -211,34 +211,34 @@ PRBool nsNewsDownloader::GetNextHdrToRet
       LL_SUB(diffSinceLastProgress, diffSinceLastProgress, minIntervalBetweenProgress); // r = a - b
       if (!LL_GE_ZERO(diffSinceLastProgress))
         return PR_TRUE;
     }
 
     m_lastProgressTime = nowMS;
     nsCOMPtr <nsIMsgNewsFolder> newsFolder = do_QueryInterface(m_folder);
     nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-    NS_ENSURE_SUCCESS(rv, rv);
+    NS_ENSURE_SUCCESS(rv, PR_FALSE);
     nsCOMPtr<nsIStringBundle> bundle;
     rv = bundleService->CreateBundle(NEWS_MSGS_URL, getter_AddRefs(bundle));
-    NS_ENSURE_SUCCESS(rv, rv);
+    NS_ENSURE_SUCCESS(rv, PR_FALSE);
 
     nsAutoString firstStr;
     firstStr.AppendInt(m_numwrote);
     nsAutoString totalStr;
     totalStr.AppendInt(m_keysToDownload.Length());
     nsString prettiestName;
     nsString statusString;
 
     m_folder->GetPrettiestName(prettiestName);
 
     const PRUnichar *formatStrings[3] = { firstStr.get(), totalStr.get(), prettiestName.get() };
     rv = bundle->FormatStringFromName(NS_LITERAL_STRING("downloadingArticlesForOffline").get(),
                                       formatStrings, 3, getter_Copies(statusString));
-    NS_ENSURE_SUCCESS(rv, rv);
+    NS_ENSURE_SUCCESS(rv, PR_FALSE);
     ShowProgress(statusString.get(), percent);
     return PR_TRUE;
   }
   NS_ASSERTION(PR_FALSE, "shouldn't get here if we're not downloading from keys.");
   return PR_FALSE;  // shouldn't get here if we're not downloading from keys.
 }
 
 nsresult nsNewsDownloader::ShowProgress(const PRUnichar *progressString, PRInt32 percent)