Bug 1202150 - Silence compiler warnings in nsMsgDBView and friends. r=rkent
authoralta88
Tue, 29 Sep 2015 09:37:46 -0600
changeset 18465 aac9d2367a718976c4789a93ddc4ccce5beb3f54
parent 18464 e2a40f305d0026812af60ad9d95eb88e355064c3
child 18466 4d82d455486356697812d9baa3042ee5ce1bde39
push id11304
push useraleth@instantbird.org
push dateTue, 29 Sep 2015 22:57:33 +0000
treeherdercomm-central@3ddf3a3eaf07 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrkent
bugs1202150
Bug 1202150 - Silence compiler warnings in nsMsgDBView and friends. r=rkent
mailnews/base/src/nsMsgDBView.cpp
mailnews/base/src/nsMsgXFViewThread.cpp
mailnews/base/src/nsMsgXFVirtualFolderDBView.cpp
mailnews/db/msgdb/src/nsMsgDatabase.cpp
--- a/mailnews/base/src/nsMsgDBView.cpp
+++ b/mailnews/base/src/nsMsgDBView.cpp
@@ -391,17 +391,17 @@ nsresult nsMsgDBView::FetchAuthor(nsIMsg
     if (!cachedDisplayName.IsEmpty())
     {
       CopyUTF8toUTF16(cachedDisplayName, aSenderString);
       return NS_OK;
     }
   }
 
   nsCString author;
-  nsresult rv = aHdr->GetAuthor(getter_Copies(author));
+  (void) aHdr->GetAuthor(getter_Copies(author));
 
   nsCString headerCharset;
   aHdr->GetEffectiveCharset(headerCharset);
 
   nsCString emailAddress;
   nsString name;
   ExtractFirstAddress(EncodedHeader(author, headerCharset.get()), name,
     emailAddress);
@@ -3822,53 +3822,53 @@ void nsMsgDBView::ReverseSort()
         // no need to swap elements in m_levels; since we only call
         // ReverseSort in non-threaded mode, m_levels are all the same.
     }
 }
 int
 nsMsgDBView::FnSortIdKey(const void *pItem1, const void *pItem2, void *privateData)
 {
     int32_t retVal = 0;
-    nsresult rv;
-    viewSortInfo* sortInfo = (viewSortInfo *) privateData;
 
     IdKey** p1 = (IdKey**)pItem1;
     IdKey** p2 = (IdKey**)pItem2;
+    viewSortInfo* sortInfo = (viewSortInfo *) privateData;
 
     nsIMsgDatabase *db = sortInfo->db;
 
-    rv = db->CompareCollationKeys((*p1)->dword, (*p1)->key, (*p2)->dword,
-                                  (*p2)->key, &retVal);
-    NS_ASSERTION(NS_SUCCEEDED(rv),"compare failed");
+    mozilla::DebugOnly<nsresult> rv = db->CompareCollationKeys((*p1)->dword, (*p1)->key,
+                                                               (*p2)->dword, (*p2)->key,
+                                                               &retVal);
+    NS_ASSERTION(NS_SUCCEEDED(rv), "compare failed");
 
     if (retVal)
       return sortInfo->ascendingSort ? retVal : -retVal;
     if (sortInfo->view->m_secondarySort == nsMsgViewSortType::byId)
       return (sortInfo->view->m_secondarySortOrder == nsMsgViewSortOrder::ascending &&
               (*p1)->id >= (*p2)->id) ? 1 : -1;
     else
       return sortInfo->view->SecondarySort((*p1)->id, (*p1)->folder, (*p2)->id, (*p2)->folder, sortInfo);
     // here we'd use the secondary sort
 }
 
 int
 nsMsgDBView::FnSortIdKeyPtr(const void *pItem1, const void *pItem2, void *privateData)
 {
   int32_t retVal = 0;
-  nsresult rv;
 
   IdKeyPtr** p1 = (IdKeyPtr**)pItem1;
   IdKeyPtr** p2 = (IdKeyPtr**)pItem2;
   viewSortInfo* sortInfo = (viewSortInfo *) privateData;
 
   nsIMsgDatabase *db = sortInfo->db;
 
-  rv = db->CompareCollationKeys((*p1)->dword, (*p1)->key, (*p2)->dword,
-                                (*p2)->key, &retVal);
-  NS_ASSERTION(NS_SUCCEEDED(rv),"compare failed");
+  mozilla::DebugOnly<nsresult> rv = db->CompareCollationKeys((*p1)->dword, (*p1)->key,
+                                                             (*p2)->dword, (*p2)->key,
+                                                             &retVal);
+  NS_ASSERTION(NS_SUCCEEDED(rv), "compare failed");
 
   if (retVal)
     return sortInfo->ascendingSort ? retVal : -retVal;
 
   if (sortInfo->view->m_secondarySort == nsMsgViewSortType::byId)
     return (sortInfo->view->m_secondarySortOrder == nsMsgViewSortOrder::ascending &&
             (*p1)->id >= (*p2)->id) ? 1 : -1;
   else
@@ -6496,20 +6496,16 @@ nsresult nsMsgDBView::MarkThreadOfMsgRea
         threadIndex = GetIndexOfFirstDisplayedKeyInThread(threadHdr);
     else
         threadIndex = msgIndex;
     return MarkThreadRead(threadHdr, threadIndex, idsMarkedRead, bRead);
 }
 
 nsresult nsMsgDBView::MarkThreadRead(nsIMsgThread *threadHdr, nsMsgViewIndex threadIndex, nsTArray<nsMsgKey> &idsMarkedRead, bool bRead)
 {
-    bool threadElided = true;
-    if (threadIndex != nsMsgViewIndex_None)
-        threadElided = (m_flags[threadIndex] & nsMsgMessageFlags::Elided);
-
     uint32_t numChildren;
     threadHdr->GetNumChildren(&numChildren);
     idsMarkedRead.SetCapacity(numChildren);
     for (int32_t childIndex = 0; childIndex < (int32_t) numChildren ; childIndex++)
     {
         nsCOMPtr <nsIMsgDBHdr> msgHdr;
         threadHdr->GetChildHdrAt(childIndex, getter_AddRefs(msgHdr));
         NS_ASSERTION(msgHdr, "msgHdr is null");
--- a/mailnews/base/src/nsMsgXFViewThread.cpp
+++ b/mailnews/base/src/nsMsgXFViewThread.cpp
@@ -124,17 +124,17 @@ nsresult nsMsgXFViewThread::AddHdr(nsIMs
   }
 
   // Find our parent, if any, in the thread. Starting at the newest
   // reference, and working our way back, see if we've mapped that reference
   // to this thread.
   uint16_t numReferences;
   newHdr->GetNumReferences(&numReferences);
   nsCOMPtr<nsIMsgDBHdr> parent;
-  int32_t parentIndex;
+  int32_t parentIndex = -1;
 
   for (int32_t i = numReferences - 1; i >= 0;  i--)
   {
     nsAutoCString reference;
     newHdr->GetStringReference(i, reference);
     if (reference.IsEmpty())
       break;
 
--- a/mailnews/base/src/nsMsgXFVirtualFolderDBView.cpp
+++ b/mailnews/base/src/nsMsgXFVirtualFolderDBView.cpp
@@ -425,29 +425,32 @@ nsMsgXFVirtualFolderDBView::OnNewSearch(
           continue;
         searchDB->GetCachedHits(searchUri.get(), getter_AddRefs(cachedHits));
         bool hasMore;
         if (cachedHits)
         {
           cachedHits->HasMoreElements(&hasMore);
           if (hasMore)
           {
-            nsMsgKey prevKey = nsMsgKey_None;
+            mozilla::DebugOnly<nsMsgKey> prevKey = nsMsgKey_None;
             while (hasMore)
             {
               nsCOMPtr <nsISupports> supports;
               nsresult rv = cachedHits->GetNext(getter_AddRefs(supports));
               NS_ASSERTION(NS_SUCCEEDED(rv), "nsMsgDBEnumerator broken");
               nsCOMPtr <nsIMsgDBHdr> pHeader = do_QueryInterface(supports);
               if (pHeader && NS_SUCCEEDED(rv))
               {
                 nsMsgKey msgKey;
                 pHeader->GetMessageKey(&msgKey);
-                NS_ASSERTION(prevKey == nsMsgKey_None || msgKey > prevKey, "cached Hits not sorted");
+                NS_ASSERTION(prevKey == nsMsgKey_None || msgKey > prevKey,
+                             "cached Hits not sorted");
+#ifdef DEBUG
                 prevKey = msgKey;
+#endif
                 AddHdrFromFolder(pHeader, searchFolder);
               }
               else
                 break;
               cachedHits->HasMoreElements(&hasMore);
             }
           }
         }
--- a/mailnews/db/msgdb/src/nsMsgDatabase.cpp
+++ b/mailnews/db/msgdb/src/nsMsgDatabase.cpp
@@ -1616,29 +1616,28 @@ nsresult nsMsgDatabase::InitNewDB()
     if (dbFolderInfo)
     {
       NS_ADDREF(dbFolderInfo);
       err = dbFolderInfo->AddToNewMDB();
       dbFolderInfo->SetVersion(GetCurVersion());
       dbFolderInfo->SetBooleanProperty(kFixedBadRefThreadingProp, true);
       nsIMdbStore *store = GetStore();
       // create the unique table for the dbFolderInfo.
-      nsresult mdberr;
       struct mdbOid allMsgHdrsTableOID;
       struct mdbOid allThreadsTableOID;
       if (!store)
         return NS_ERROR_NULL_POINTER;
 
       allMsgHdrsTableOID.mOid_Scope = m_hdrRowScopeToken;
       allMsgHdrsTableOID.mOid_Id = kAllMsgHdrsTableKey;
       allThreadsTableOID.mOid_Scope = m_threadRowScopeToken;
       allThreadsTableOID.mOid_Id = kAllThreadsTableKey;
 
       // TODO: check this error value?
-      mdberr  = store->NewTableWithOid(GetEnv(), &allMsgHdrsTableOID, m_hdrTableKindToken,
+      (void) store->NewTableWithOid(GetEnv(), &allMsgHdrsTableOID, m_hdrTableKindToken,
         false, nullptr, &m_mdbAllMsgHeadersTable);
 
       // error here is not fatal.
       (void) store->NewTableWithOid(GetEnv(), &allThreadsTableOID, m_allThreadsTableKindToken,
         false, nullptr, &m_mdbAllThreadsTable);
 
       m_dbFolderInfo = dbFolderInfo;
 
@@ -5697,17 +5696,17 @@ nsresult nsMsgDatabase::GetSearchResults
 
   return *table ? err : NS_ERROR_FAILURE;
 }
 
 NS_IMETHODIMP
 nsMsgDatabase::GetCachedHits(const char *aSearchFolderUri, nsISimpleEnumerator **aEnumerator)
 {
   nsCOMPtr <nsIMdbTable> table;
-  nsresult err = GetSearchResultsTable(aSearchFolderUri, false, getter_AddRefs(table));
+  (void) GetSearchResultsTable(aSearchFolderUri, false, getter_AddRefs(table));
   if (!table)
     return NS_ERROR_FAILURE; // expected result for no cached hits
   nsMsgDBEnumerator* e = new nsMsgDBEnumerator(this, table, nullptr, nullptr);
   if (e == nullptr)
       return NS_ERROR_OUT_OF_MEMORY;
   NS_ADDREF(*aEnumerator = e);
   return NS_OK;
 }