Bug 777770 - Replace nsVoidArray with nsTArray, part 2. r=rkent a=me CLOSED TREE
authorStefan Sitter <ssitter@gmail.com>
Wed, 13 May 2015 21:07:16 +0200
changeset 26126 7af2eea538ce6d0f465328b95bc0fb652d397999
parent 26125 44917543a77bebdc40d8f84c3825c1a2abf013ce
child 26127 9a0e327af6dec7c0f9c61b60c1232ff0ce3e6d71
push id1850
push userclokep@gmail.com
push dateWed, 08 Mar 2017 19:29:12 +0000
treeherdercomm-esr52@028df196b2d9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrkent, me
bugs777770
Bug 777770 - Replace nsVoidArray with nsTArray, part 2. r=rkent a=me CLOSED TREE
mailnews/addrbook/src/nsAbView.cpp
mailnews/addrbook/src/nsDirPrefs.cpp
mailnews/addrbook/src/nsDirPrefs.h
mailnews/base/src/nsMsgDBView.cpp
mailnews/base/src/nsMsgDBView.h
mailnews/imap/src/nsIMAPBodyShell.cpp
mailnews/imap/src/nsIMAPNamespace.cpp
mailnews/imap/src/nsImapIncomingServer.cpp
mailnews/imap/src/nsImapProtocol.cpp
mailnews/import/eudora/src/nsEudoraAddress.cpp
mailnews/import/eudora/src/nsEudoraCompose.cpp
mailnews/import/eudora/src/nsEudoraMailbox.cpp
mailnews/import/outlook/src/MapiApi.cpp
mailnews/import/outlook/src/MapiApi.h
mailnews/import/src/nsImportFieldMap.cpp
mailnews/local/public/nsIPop3Protocol.idl
mailnews/local/src/nsParseMailbox.cpp
mailnews/mime/emitters/nsMimeBaseEmitter.cpp
mailnews/mime/emitters/nsMimeHtmlEmitter.cpp
--- a/mailnews/addrbook/src/nsAbView.cpp
+++ b/mailnews/addrbook/src/nsAbView.cpp
@@ -93,17 +93,17 @@ NS_IMETHODIMP nsAbView::ClearView()
 
   return NS_OK;
 }
 
 nsresult nsAbView::RemoveCardAt(int32_t row)
 {
   nsresult rv;
 
-  AbCard *abcard = (AbCard*) (mCards.ElementAt(row));
+  AbCard *abcard = mCards.ElementAt(row);
   NS_IF_RELEASE(abcard->card);
   mCards.RemoveElementAt(row);
   PR_FREEIF(abcard->primaryCollationKey);
   PR_FREEIF(abcard->secondaryCollationKey);
   PR_FREEIF(abcard);
 
   
   // This needs to happen after we remove the card, as RowCountChanged() will call GetRowCount()
@@ -349,17 +349,17 @@ NS_IMETHODIMP nsAbView::GetRowProperties
 {
     return NS_OK;
 }
 
 NS_IMETHODIMP nsAbView::GetCellProperties(int32_t row, nsITreeColumn* col, nsAString& properties)
 {
   NS_ENSURE_TRUE(row >= 0, NS_ERROR_UNEXPECTED);
 
-  if (mCards.Length() <= row)
+  if (mCards.Length() <= (size_t)row)
     return NS_OK;
 
   const char16_t* colID;
   col->GetIdConst(&colID);
   // "G" == "GeneratedName"
   if (colID[0] != char16_t('G'))
     return NS_OK;
 
@@ -520,17 +520,17 @@ nsresult nsAbView::RefreshTree()
     SelectionChanged();
   }
 
   return rv;
 }
 
 NS_IMETHODIMP nsAbView::GetCellText(int32_t row, nsITreeColumn* col, nsAString& _retval)
 {
-  NS_ENSURE_TRUE(row >= 0 && row < mCards.Length(), NS_ERROR_UNEXPECTED);
+  NS_ENSURE_TRUE(row >= 0 && (size_t)row < mCards.Length(), NS_ERROR_UNEXPECTED);
 
   nsIAbCard *card = mCards.ElementAt(row)->card;
   const char16_t* colID;
   col->GetIdConst(&colID);
   return GetCardValue(card, colID, _retval);
 }
 
 NS_IMETHODIMP nsAbView::SetTree(nsITreeBoxObject *tree)
@@ -607,22 +607,21 @@ NS_IMETHODIMP nsAbView::PerformActionOnR
 NS_IMETHODIMP nsAbView::PerformActionOnCell(const char16_t *action, int32_t row, nsITreeColumn* col)
 {
     return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP nsAbView::GetCardFromRow(int32_t row, nsIAbCard **aCard)
 {
   *aCard = nullptr;  
-  if (mCards.Length() <= row) {
+  NS_ENSURE_TRUE(row >= 0, NS_ERROR_UNEXPECTED);
+  if (mCards.Length() <= (size_t)row) {
     return NS_OK;
   }
 
-  NS_ENSURE_TRUE(row >= 0, NS_ERROR_UNEXPECTED);
-
   AbCard *a = mCards.ElementAt(row);
   if (!a)
       return NS_OK;
 
   NS_IF_ADDREF(*aCard = a->card);
   return NS_OK;
 }
 
@@ -632,23 +631,18 @@ NS_IMETHODIMP nsAbView::GetCardFromRow(i
 typedef struct SortClosure
 {
   const char16_t *colID;
   int32_t factor;
   nsAbView *abView;
 } SortClosure;
 
 static int
-inplaceSortCallback(const void *data1, const void *data2, void *privateData)
+inplaceSortCallback(const AbCard *card1, const AbCard *card2, SortClosure *closure)
 {
-  AbCard *card1 = (AbCard *)data1;
-  AbCard *card2 = (AbCard *)data2;
-  
-  SortClosure *closure = (SortClosure *) privateData;
-  
   int32_t sortValue;
   
   // If we are sorting the "PrimaryEmail", swap the collation keys, as the secondary is always the
   // PrimaryEmail. Use the last primary key as the secondary key.
   //
   // "Pr" to distinguish "PrimaryEmail" from "PagerNumber"
   if (closure->colID[0] == char16_t('P') && closure->colID[1] == char16_t('r')) {
     sortValue = closure->abView->CompareCollationKeys(card1->secondaryCollationKey,card1->secondaryCollationKeyLen,card2->secondaryCollationKey,card2->secondaryCollationKeyLen);
@@ -674,29 +668,30 @@ static void SetSortClosure(const char16_
     closure->factor = DESCENDING_SORT_FACTOR;
   else 
     closure->factor = ASCENDING_SORT_FACTOR;
 
   closure->abView = abView;
   return;
 }
 
-class CardComparator {
-  private:
-    SortClosure *m_closure;
+class CardComparator
+{
+public:
+  void SetClosure(SortClosure *closure) { m_closure = closure; };
 
-  public:
-    void SetClosure(SortClosure *closure) { m_closure = closure; };
-    /** @return True if the elements are equals; false otherise. */
-    bool Equals(const AbCard* a, const AbCard* b) const {
-      return inplaceSortCallback(a, b, m_closure) == 0;
-    }
-    bool LessThan(const AbCard* a, const AbCard* b) const{
-      return inplaceSortCallback(a, b, m_closure) < 0;
-    }
+  bool Equals(const AbCard *a, const AbCard *b) const {
+    return inplaceSortCallback(a, b, m_closure) == 0;
+  }
+  bool LessThan(const AbCard *a, const AbCard *b) const{
+    return inplaceSortCallback(a, b, m_closure) < 0;
+  }
+
+private:
+  SortClosure *m_closure;
 };
 
 NS_IMETHODIMP nsAbView::SortBy(const char16_t *colID, const char16_t *sortDir, bool aResort = false)
 {
   nsresult rv;
 
   int32_t count = mCards.Length();
 
@@ -947,26 +942,23 @@ nsresult nsAbView::AddCard(AbCard *abcar
   return rv;
 }
 
 int32_t nsAbView::FindIndexForInsert(AbCard *abcard)
 {
   int32_t count = mCards.Length();
   int32_t i;
 
-  void *item = (void *)abcard;
-  
   SortClosure closure;
   SetSortClosure(mSortColumn.get(), mSortDirection.get(), this, &closure);
   
   // XXX todo
   // Make this a binary search
   for (i=0; i < count; i++) {
-    void *current = (void *)mCards.ElementAt(i);
-    int32_t value = inplaceSortCallback(item, current, (void *)(&closure));
+    int32_t value = inplaceSortCallback(abcard, mCards.ElementAt(i), &closure);
     // XXX Fix me, this is not right for both ascending and descending
     if (value <= 0) 
       break;
   }
   return i;
 }
 
 NS_IMETHODIMP nsAbView::OnItemRemoved(nsISupports *parentDir, nsISupports *item)
@@ -1041,17 +1033,17 @@ int32_t nsAbView::FindIndexForCard(nsIAb
 {
   int32_t count = mCards.Length();
   int32_t i;
  
   // You can't implement the binary search here, as all you have is the nsIAbCard
   // you might be here because one of the card properties has changed, and that property
   // could be the collation key.
   for (i=0; i < count; i++) {
-    AbCard *abcard = (AbCard*) (mCards.ElementAt(i));
+    AbCard *abcard = mCards.ElementAt(i);
     bool equals;
     nsresult rv = card->Equals(abcard->card, &equals);
     if (NS_SUCCEEDED(rv) && equals) {
       return i;
     }
   }
   return CARD_NOT_FOUND;
 }
@@ -1063,17 +1055,17 @@ NS_IMETHODIMP nsAbView::OnItemPropertyCh
   nsCOMPtr <nsIAbCard> card = do_QueryInterface(item);
   if (!card)
     return NS_OK;
 
   int32_t index = FindIndexForCard(card);
   if (index == -1)
     return NS_OK;
 
-  AbCard *oldCard = (AbCard*) (mCards.ElementAt(index));
+  AbCard *oldCard = mCards.ElementAt(index);
 
   // Malloc these from an arena
   AbCard *newCard = (AbCard *) PR_Calloc(1, sizeof(struct AbCard));
   if (!newCard)
     return NS_ERROR_OUT_OF_MEMORY;
 
   newCard->card = card;
   NS_IF_ADDREF(newCard->card);
--- a/mailnews/addrbook/src/nsDirPrefs.cpp
+++ b/mailnews/addrbook/src/nsDirPrefs.cpp
@@ -194,17 +194,17 @@ DIR_Server* DIR_GetServerFromList(const 
     DIR_GetDirServers();
 
   if (dir_ServerList)
   {
     int32_t count = dir_ServerList->Length();
     int32_t i;
     for (i = 0; i < count; ++i)
     {
-      DIR_Server *server = (DIR_Server *)dir_ServerList->ElementAt(i);
+      DIR_Server *server = dir_ServerList->ElementAt(i);
 
       if (server && strcmp(server->prefName, prefName) == 0)
       {
         result = server;
         break;
       }
     }
   }
@@ -244,17 +244,17 @@ nsresult DIR_ShutDown()  /* FEs should c
 nsresult DIR_ContainsServer(DIR_Server* pServer, bool *hasDir)
 {
   if (dir_ServerList)
   {
     int32_t count = dir_ServerList->Length();
     int32_t i;
     for (i = 0; i < count; i++)
     {
-      DIR_Server* server = (DIR_Server *)(dir_ServerList->ElementAt(i));
+      DIR_Server* server = dir_ServerList->ElementAt(i);
       if (server == pServer)
       {
         *hasDir = true;
         return NS_OK;
       }
     }
   }
   *hasDir = false;
@@ -349,27 +349,27 @@ static bool DIR_SetServerPosition(nsTArr
    switch (position) {
    case DIR_POS_APPEND:
    /* Do nothing if the request is to append a server that is already
      * in the list.
      */
      count = wholeList->Length();
      for (i= 0; i < count; i++)
      {
-       if  ((s = (DIR_Server *)wholeList->ElementAt(i)) != nullptr)
+       if  ((s = wholeList->ElementAt(i)) != nullptr)
          if (s == server)
            return false;
      }
      /* In general, if there are any servers already in the list, set the
      * position to the position of the last server plus one.  If there
      * are none, set it to position 1.
      */
      if (count > 0)
      {
-       s = (DIR_Server *)wholeList->ElementAt(count - 1);
+       s = wholeList->ElementAt(count - 1);
        server->position = s->position + 1;
      }
      else
        server->position = 1;
      
      wholeList->AppendElement(server);
      break;
      
@@ -413,17 +413,17 @@ static bool DIR_SetServerPosition(nsTArr
      break;
      
    default:
    /* See if the server is already in the list.
      */
      count = wholeList->Length();
      for (i= 0; i < count; i++)
      {
-       if  ((s = (DIR_Server *)wholeList->ElementAt(i)) != nullptr)
+       if  ((s = wholeList->ElementAt(i)) != nullptr)
          if (s == server)
            break;
      }
      
      /* If the server is not in the list, add it to the beginning and re-sort.
      */
      if (s == nullptr)
      {
@@ -463,17 +463,17 @@ static bool DIR_SetServerPosition(nsTArr
 static DIR_Server *dir_MatchServerPrefToServer(nsTArray<DIR_Server*> *wholeList, const char *pref)
 {
   DIR_Server *server;
 
   int32_t count = wholeList->Length();
   int32_t i;
   for (i = 0; i < count; i++)
   {
-    if ((server = (DIR_Server *)wholeList->ElementAt(i)) != nullptr)
+    if ((server = wholeList->ElementAt(i)) != nullptr)
     {
       if (server->prefName && PL_strstr(pref, server->prefName) == pref)
       {
         char c = pref[PL_strlen(server->prefName)];
         if (c == 0 || c == '.')
           return server;
       }
     }
@@ -676,17 +676,17 @@ static void DIR_DeleteServerList(nsTArra
   {
     DIR_Server *server = nullptr;
   
     /* TBD: Send notifications? */
     int32_t count = wholeList->Length();
     int32_t i;
     for (i = count - 1; i >=0; i--)
     {
-      server = (DIR_Server *)wholeList->ElementAt(i);
+      server = wholeList->ElementAt(i);
       if (server != nullptr)
         DIR_DeleteServer(server);
     }
     delete wholeList;
   }
 }
 
 /*****************************************************************************
@@ -1186,19 +1186,19 @@ void DIR_SortServersByPosition(nsTArray<
   int i, j;
   DIR_Server *server;
   
   int count = serverList->Length();
   for (i = 0; i < count - 1; i++)
   {
     for (j = i + 1; j < count; j++)
     {
-      if (((DIR_Server *) serverList->ElementAt(j))->position < ((DIR_Server *) serverList->ElementAt(i))->position)
+      if (serverList->ElementAt(j)->position < serverList->ElementAt(i)->position)
       {
-        server        = (DIR_Server *) serverList->ElementAt(i);
+        server = serverList->ElementAt(i);
         serverList->ReplaceElementAt(i, serverList->ElementAt(j));
         serverList->ReplaceElementAt(j, server);
       }
     }
   }
 }
 
 static nsresult DIR_GetServerPreferences(nsTArray<DIR_Server*>** list)
@@ -1438,15 +1438,15 @@ static void DIR_SaveServerPreferences(ns
     }
 
     int32_t  i;
     int32_t  count = wholeList->Length();
     DIR_Server *server;
 
     for (i = 0; i < count; i++)
     {
-      server = (DIR_Server *) wholeList->ElementAt(i);
+      server = wholeList->ElementAt(i);
       if (server)
         DIR_SavePrefsForOneServer(server);
     }
     pPref->SetIntPref(PREF_LDAP_GLOBAL_TREE_NAME".user_id", dir_UserId);
   }
 }
--- a/mailnews/addrbook/src/nsDirPrefs.h
+++ b/mailnews/addrbook/src/nsDirPrefs.h
@@ -1,23 +1,23 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef _NSDIRPREFS_H_
 #define _NSDIRPREFS_H_
 
+#include "nsTArray.h"
+
 //
 // XXX nsDirPrefs is being greatly reduced if not removed altogether. Directory
 // Prefs etc. should be handled via their appropriate nsAb*Directory classes.
 //
 
-template <class> class nsTArray;
-
 #define kPreviousListVersion   2
 #define kCurrentListVersion    3
 #define PREF_LDAP_GLOBAL_TREE_NAME "ldap_2"
 #define PREF_LDAP_VERSION_NAME     "ldap_2.version"
 #define PREF_LDAP_SERVER_TREE_NAME "ldap_2.servers"
 
 #define kMainLdapAddressBook "ldap.mab"   /* v3 main ldap address book file */
 
--- a/mailnews/base/src/nsMsgDBView.cpp
+++ b/mailnews/base/src/nsMsgDBView.cpp
@@ -5579,17 +5579,17 @@ NS_IMETHODIMP nsMsgDBView::InsertTreeRow
   if (GetSize() < aIndex)
     return NS_ERROR_UNEXPECTED;
 
   nsCOMArray<nsIMsgFolder> *folders = GetFolders();
   if (folders)
   {
     // In a search/xfvf view only, a folder is required.
     NS_ENSURE_ARG_POINTER(aFolder);
-    for (int32_t i = 0; i < aNumRows; i++)
+    for (size_t i = 0; i < aNumRows; i++)
       // Insert into m_folders.
       if (!folders->InsertObjectAt(aFolder, aIndex + i))
         return NS_ERROR_UNEXPECTED;
   }
 
   if (m_keys.InsertElementsAt(aIndex, aNumRows, aKey) &&
       m_flags.InsertElementsAt(aIndex, aNumRows, aFlags) &&
       m_levels.InsertElementsAt(aIndex, aNumRows, aLevel))
--- a/mailnews/base/src/nsMsgDBView.h
+++ b/mailnews/base/src/nsMsgDBView.h
@@ -7,17 +7,16 @@
 #define _nsMsgDBView_H_
 
 #include "nsIMsgDBView.h"
 #include "nsIMsgWindow.h"
 #include "nsIMessenger.h"
 #include "nsIMsgDatabase.h"
 #include "nsIMsgHdr.h"
 #include "MailNewsTypes.h"
-#include "nsTArray.h"
 #include "nsIDBChangeListener.h"
 #include "nsITreeView.h"
 #include "nsITreeBoxObject.h"
 #include "nsITreeSelection.h"
 #include "nsIMsgFolder.h"
 #include "nsIMsgThread.h"
 #include "nsIDateTimeFormat.h"
 #include "nsIDOMElement.h"
--- a/mailnews/imap/src/nsIMAPBodyShell.cpp
+++ b/mailnews/imap/src/nsIMAPBodyShell.cpp
@@ -1008,17 +1008,17 @@ int32_t nsIMAPBodypartMultipart::Generat
     bool needMIMEHeader = !parentIsMessageType;  // !PL_strcasecmp(m_bodySubType, "signed") ? true : !parentIsMessageType;
     if (needMIMEHeader && !aShell->GetPseudoInterrupted())  // not a message body's type
     {
       len += GenerateMIMEHeader(aShell, stream, prefetch);
     }
     
     if (ShouldFetchInline(aShell))
     {
-      for (int i = 0; i < m_partList->Length(); i++)
+      for (size_t i = 0; i < m_partList->Length(); i++)
       {
         if (!aShell->GetPseudoInterrupted())
           len += GenerateBoundary(aShell, stream, prefetch, false);
         if (!aShell->GetPseudoInterrupted())
           len += m_partList->ElementAt(i)->Generate(aShell, stream, prefetch);
       }
       if (!aShell->GetPseudoInterrupted())
         len += GenerateBoundary(aShell, stream, prefetch, true);
@@ -1081,17 +1081,17 @@ bool nsIMAPBodypartMultipart::ShouldFetc
     return true;
   }
 }
 
 bool nsIMAPBodypartMultipart::PreflightCheckAllInline(nsIMAPBodyShell *aShell)
 {
   bool rv = ShouldFetchInline(aShell);
   
-  int i = 0;
+  size_t i = 0;
   while (rv && (i < m_partList->Length()))
   {
     rv = m_partList->ElementAt(i)->PreflightCheckAllInline(aShell);
     i++;
   }
   
   return rv;
 }
--- a/mailnews/imap/src/nsIMAPNamespace.cpp
+++ b/mailnews/imap/src/nsIMAPNamespace.cpp
@@ -111,17 +111,17 @@ nsresult nsIMAPNamespaceList::OutputToSt
 }
 
 
 int nsIMAPNamespaceList::GetNumberOfNamespaces(EIMAPNamespaceType type)
 {
 	int nodeIndex = 0, count = 0;
 	for (nodeIndex = m_NamespaceList.Length() - 1; nodeIndex >= 0; nodeIndex--)
 	{
-		nsIMAPNamespace *nspace = (nsIMAPNamespace *) m_NamespaceList.ElementAt(nodeIndex);
+		nsIMAPNamespace *nspace = m_NamespaceList.ElementAt(nodeIndex);
 		if (nspace->GetType() == type)
 		{
 			count++;
 		}
 	}
 	return count;
 }
 
@@ -131,17 +131,17 @@ int nsIMAPNamespaceList::AddNewNamespace
 	// are any namespaces previously set by the preferences, or the default namespace.  If so, remove these.
 
 	if (!ns->GetIsNamespaceFromPrefs())
 	{
 		int nodeIndex;
         // iterate backwards because we delete elements
 		for (nodeIndex = m_NamespaceList.Length() - 1; nodeIndex >= 0; nodeIndex--)
 		{
-			nsIMAPNamespace *nspace = (nsIMAPNamespace *) m_NamespaceList.ElementAt(nodeIndex);
+			nsIMAPNamespace *nspace = m_NamespaceList.ElementAt(nodeIndex);
 			// if we find existing namespace(s) that matches the 
 			// new one, we'll just remove the old ones and let the
 			// new one get added when we've finished checking for
 			// matching namespaces or namespaces that came from prefs.
 			if (nspace &&
                             (nspace->GetIsNamespaceFromPrefs() ||
                             (!PL_strcmp(ns->GetPrefix(), nspace->GetPrefix()) &&
 			     ns->GetType() == nspace->GetType() &&
@@ -164,17 +164,17 @@ int nsIMAPNamespaceList::AddNewNamespace
 // chrisf - later, fix this to know the real concept of "default" namespace of a given type
 nsIMAPNamespace *nsIMAPNamespaceList::GetDefaultNamespaceOfType(EIMAPNamespaceType type)
 {
 	nsIMAPNamespace *rv = 0, *firstOfType = 0;
 
 	int nodeIndex, count = m_NamespaceList.Length();
 	for (nodeIndex= 0; nodeIndex < count && !rv; nodeIndex++)
 	{
-		nsIMAPNamespace *ns = (nsIMAPNamespace *) m_NamespaceList.ElementAt(nodeIndex);
+		nsIMAPNamespace *ns = m_NamespaceList.ElementAt(nodeIndex);
 		if (ns->GetType() == type)
 		{
 			if (!firstOfType)
 				firstOfType = ns;
 			if (!(*(ns->GetPrefix())))
 			{
 				// This namespace's prefix is ""
 				// Therefore it is the default
@@ -195,17 +195,17 @@ nsIMAPNamespaceList::~nsIMAPNamespaceLis
 // ClearNamespaces removes and deletes the namespaces specified, and if there are no namespaces left,
 void nsIMAPNamespaceList::ClearNamespaces(bool deleteFromPrefsNamespaces, bool deleteServerAdvertisedNamespaces, bool reallyDelete)
 {
 	int nodeIndex;
 	
     // iterate backwards because we delete elements
 	for (nodeIndex = m_NamespaceList.Length() - 1; nodeIndex >= 0; nodeIndex--)
 	{
-		nsIMAPNamespace *ns = (nsIMAPNamespace *) m_NamespaceList.ElementAt(nodeIndex);
+		nsIMAPNamespace *ns = m_NamespaceList.ElementAt(nodeIndex);
 		if (ns->GetIsNamespaceFromPrefs())
 		{
 			if (deleteFromPrefsNamespaces)
 			{
 				m_NamespaceList.RemoveElementAt(nodeIndex);
 				if (reallyDelete)
 					delete ns;
 			}
@@ -220,25 +220,25 @@ void nsIMAPNamespaceList::ClearNamespace
 }
 
 nsIMAPNamespace *nsIMAPNamespaceList::GetNamespaceNumber(int nodeIndex)
 {
   NS_ASSERTION(nodeIndex >= 0 && nodeIndex < GetNumberOfNamespaces(), "invalid IMAP namespace node index");
   if (nodeIndex < 0) nodeIndex = 0;
 
   // XXX really could be just ElementAt; that's why we have the assertion
-  return 	(nsIMAPNamespace *) m_NamespaceList.SafeElementAt(nodeIndex);
+  return m_NamespaceList.SafeElementAt(nodeIndex);
 }
 
 nsIMAPNamespace *nsIMAPNamespaceList::GetNamespaceNumber(int nodeIndex, EIMAPNamespaceType type)
 {
   int nodeCount, count = 0;
-  for (nodeCount=m_NamespaceList.Length() - 1; nodeCount >= 0; nodeCount--)
+  for (nodeCount = m_NamespaceList.Length() - 1; nodeCount >= 0; nodeCount--)
   {
-    nsIMAPNamespace *nspace = (nsIMAPNamespace *) m_NamespaceList.ElementAt(nodeCount);
+    nsIMAPNamespace *nspace = m_NamespaceList.ElementAt(nodeCount);
     if (nspace->GetType() == type)
     {
       count++;
       if (count == nodeIndex)
         return nspace;
     }
   }
   return nullptr;
@@ -260,17 +260,17 @@ nsIMAPNamespace *nsIMAPNamespaceList::Ge
   nsIMAPNamespace *rv = nullptr;
   int nodeIndex = 0;
   
   if (!PL_strcasecmp(boxname, "INBOX"))
     return GetDefaultNamespaceOfType(kPersonalNamespace);
   
   for (nodeIndex = m_NamespaceList.Length() - 1; nodeIndex >= 0; nodeIndex--)
   {
-    nsIMAPNamespace *nspace = (nsIMAPNamespace *) m_NamespaceList.ElementAt(nodeIndex);
+    nsIMAPNamespace *nspace = m_NamespaceList.ElementAt(nodeIndex);
     currentMatchedLength = nspace->MailboxMatchesNamespace(boxname);
     if (currentMatchedLength > lengthMatched)
     {
       rv = nspace;
       lengthMatched = currentMatchedLength;
     }
   }
   
--- a/mailnews/imap/src/nsImapIncomingServer.cpp
+++ b/mailnews/imap/src/nsImapIncomingServer.cpp
@@ -538,17 +538,17 @@ nsImapIncomingServer::LoadNextQueuedUrl(
     if (aImapUrl)
     {
       nsImapProtocol::LogImapUrl("considering playing queued url", aImapUrl);
       rv = DoomUrlIfChannelHasError(aImapUrl, &removeUrlFromQueue);
       NS_ENSURE_SUCCESS(rv, rv);
       // if we didn't doom the url, lets run it.
       if (!removeUrlFromQueue)
       {
-        nsISupports *aConsumer = (nsISupports*)m_urlConsumers.ElementAt(0);
+        nsISupports *aConsumer = m_urlConsumers.ElementAt(0);
         NS_IF_ADDREF(aConsumer);
 
         nsImapProtocol::LogImapUrl("creating protocol instance to play queued url", aImapUrl);
         rv = GetImapConnection(aImapUrl, getter_AddRefs(protocolInstance));
         if (NS_SUCCEEDED(rv) && protocolInstance)
         {
           nsCOMPtr<nsIURI> url = do_QueryInterface(aImapUrl, &rv);
           if (NS_SUCCEEDED(rv) && url)
--- a/mailnews/imap/src/nsImapProtocol.cpp
+++ b/mailnews/imap/src/nsImapProtocol.cpp
@@ -6769,25 +6769,25 @@ bool nsImapProtocol::RenameHierarchyByHa
     }
     m_hierarchyNameState = kNoOperationInProgress;
 
     if (GetServerStateParser().LastCommandSuccessful())
       renameSucceeded = // rename this, and move subscriptions
                 RenameMailboxRespectingSubscriptions(oldParentMailboxName,
                                                      newParentMailboxName, true);
 
-    int32_t numberToDelete = m_deletableChildren->Length();
-        int32_t childIndex;
+    size_t numberToDelete = m_deletableChildren->Length();
+    size_t childIndex;
 
     for (childIndex = 0;
              (childIndex < numberToDelete) && renameSucceeded; childIndex++)
     {
       // the imap parser has already converted to a non UTF7 string in the canonical
       // format so convert it back
-        char *currentName = (char *) m_deletableChildren->ElementAt(childIndex);
+        char *currentName = m_deletableChildren->ElementAt(childIndex);
         if (currentName)
         {
           char *serverName = nullptr;
           m_runningUrl->AllocateServerPath(currentName,
                                          onlineDirSeparator,
                                          &serverName);
           PR_FREEIF(currentName);
           currentName = serverName;
@@ -6833,48 +6833,48 @@ bool nsImapProtocol::DeleteSubFolders(co
       List(pattern.get(), false);
     }
     m_hierarchyNameState = kNoOperationInProgress;
 
     // this should be a short list so perform a sequential search for the
     // longest name mailbox.  Deleting the longest first will hopefully
         // prevent the server from having problems about deleting parents
         // ** jt - why? I don't understand this.
-    int32_t numberToDelete = m_deletableChildren->Length();
-    int32_t outerIndex, innerIndex;
+    size_t numberToDelete = m_deletableChildren->Length();
+    size_t outerIndex, innerIndex;
 
     // intelligently decide if myself(either plain format or following the dir-separator)
     // is in the sub-folder list
     bool folderInSubfolderList = false; // For Performance
     char *selectedMailboxDir = nullptr;
     {
         int32_t length = strlen(selectedMailbox);
         selectedMailboxDir = (char *)PR_MALLOC(length+2);
         if( selectedMailboxDir )    // only do the intelligent test if there is enough memory
         {
             strcpy(selectedMailboxDir, selectedMailbox);
             selectedMailboxDir[length] = onlineDirSeparator;
             selectedMailboxDir[length+1] = '\0';
-            int32_t i;
+            size_t i;
             for( i=0; i<numberToDelete && !folderInSubfolderList; i++ )
             {
                 char *currentName = m_deletableChildren->ElementAt(i);
                 if( !strcmp(currentName, selectedMailbox) || !strcmp(currentName, selectedMailboxDir) )
                     folderInSubfolderList = true;
             }
         }
     }
 
     deleteSucceeded = GetServerStateParser().LastCommandSuccessful();
     for (outerIndex = 0;
          (outerIndex < numberToDelete) && deleteSucceeded;
          outerIndex++)
     {
         char* longestName = nullptr;
-        int32_t longestIndex = 0; // fix bogus warning by initializing
+        size_t longestIndex = 0; // fix bogus warning by initializing
         for (innerIndex = 0;
              innerIndex < m_deletableChildren->Length();
              innerIndex++)
         {
             char *currentName = m_deletableChildren->ElementAt(innerIndex);
             if (!longestName || strlen(longestName) < strlen(currentName))
             {
                 longestName = currentName;
--- a/mailnews/import/eudora/src/nsEudoraAddress.cpp
+++ b/mailnews/import/eudora/src/nsEudoraAddress.cpp
@@ -56,18 +56,18 @@ public:
 
 class CAliasEntry {
 public:
   CAliasEntry(nsCString& name) { m_name = name;}
   ~CAliasEntry() { EmptyList();}
 
   void EmptyList(void) {
     CAliasData *pData;
-    for (int32_t i = 0; i < m_list.Length(); i++) {
-      pData = (CAliasData *)m_list.ElementAt(i);
+    for (size_t i = 0; i < m_list.Length(); i++) {
+      pData = m_list.ElementAt(i);
       delete pData;
     }
     m_list.Clear();
   }
 
 public:
   nsCString  m_name;
   nsTArray<CAliasData*>  m_list;
@@ -152,17 +152,17 @@ int32_t nsEudoraAddress::CountWhiteSpace
   }
 
   return cnt;
 }
 
 void nsEudoraAddress::EmptyAliases(void)
 {
   CAliasEntry *pData;
-  for (int32_t i = 0; i < m_alias.Length(); i++) {
+  for (size_t i = 0; i < m_alias.Length(); i++) {
     pData = m_alias.ElementAt(i);
     delete pData;
   }
   m_alias.Clear();
 }
 
 void nsEudoraAddress::ProcessLine(const char *pLine, int32_t len, nsString& errors)
 {
@@ -541,25 +541,25 @@ void DumpAliasArray(nsTArray<CAliasEntry
   int32_t cnt = a.Length();
   IMPORT_LOG1("Alias list size: %ld\n", cnt);
   for (int32_t i = 0; i < cnt; i++) {
     pEntry = a.ElementAt(i);
     IMPORT_LOG1("\tAlias: %s\n", pEntry->m_name.get());
     if (pEntry->m_list.Length() > 1) {
       IMPORT_LOG1("\tList count #%ld\n", pEntry->m_list.Length());
       for (int32_t j = 0; j < pEntry->m_list.Length(); j++) {
-        pData = (CAliasData *) pEntry->m_list.ElementAt(j);
+        pData = pEntry->m_list.ElementAt(j);
         IMPORT_LOG0("\t\t--------\n");
         IMPORT_LOG1("\t\temail: %s\n", pData->m_email.get());
         IMPORT_LOG1("\t\trealName: %s\n", pData->m_realName.get());
         IMPORT_LOG1("\t\tnickName: %s\n", pData->m_nickName.get());
       }
     }
     else if (pEntry->m_list.Length()) {
-      pData = (CAliasData *) pEntry->m_list.ElementAt(0);
+      pData = pEntry->m_list.ElementAt(0);
       IMPORT_LOG1("\t\temail: %s\n", pData->m_email.get());
       IMPORT_LOG1("\t\trealName: %s\n", pData->m_realName.get());
       IMPORT_LOG1("\t\tnickName: %s\n", pData->m_nickName.get());
     }
   }
 }
 #endif
 
@@ -584,17 +584,17 @@ void nsEudoraAddress::ResolveEntries(nsC
     if (result.Length() > m_alias.Length())
         return;
 
     int32_t         max = list.Length();
     int32_t         i;
     CAliasData *    pData;
     CAliasEntry *   pEntry;
     for (i = 0; i < max; i++) {
-        pData = (CAliasData *)list.ElementAt(i);
+        pData = list.ElementAt(i);
         // resolve the email to an existing alias!
         if (!name.Equals(pData->m_email, nsCaseInsensitiveCStringComparator()) &&
              ((pEntry = ResolveAlias(pData->m_fullEntry)) != nullptr)) {
             // This new entry has all of the entries for this puppie.
             // Resolve all of it's entries!
             numResolved++;  // Track the number of entries resolved
 
             // We pass in true for the 5th parameter so that we know that we're
@@ -858,17 +858,17 @@ void nsEudoraAddress::AddSingleCard(CAli
         // Store other web sites in the notes field, labeled nicely
         FormatExtraDataInNoteField(EUDORAIMPORT_ADDRESS_LABEL_OTHERWEB, otherWeb, noteUTF16);
       }
 
       noteUTF16.Append(NS_ConvertASCIItoUTF16(note));
     }
   }
 
-  CAliasData *pData = emailList.Length() ? (CAliasData *)emailList.ElementAt(0) : nullptr;
+  CAliasData *pData = emailList.Length() ? emailList.ElementAt(0) : nullptr;
 
   if (pData && !pData->m_realName.IsEmpty())
     displayName = pData->m_realName;
   else if (!name.IsEmpty())
     displayName = name;
   else
     displayName = pEntry->m_name;
 
@@ -1009,17 +1009,17 @@ void nsEudoraAddress::AddSingleCard(CAli
 //
 void nsEudoraAddress::RememberGroupMembers(nsTArray<CAliasData*> &membersArray, nsTArray<CAliasData*> &emailList)
 {
   int32_t cnt = emailList.Length();
   CAliasData *pData;
 
   for (int32_t i = 0; i < cnt; i++)
   {
-    pData = (CAliasData *)emailList.ElementAt(i);
+    pData = emailList.ElementAt(i);
     if (!pData)
       continue;
 
     int32_t memberCnt = membersArray.Length();
     int32_t j = 0;
     for (j = 0; j < memberCnt; j++)
     {
       if (pData == membersArray.ElementAt(j))
@@ -1036,17 +1036,17 @@ nsresult nsEudoraAddress::AddGroupMember
   CAliasData *pData;
   nsresult rv = NS_OK;
   nsCOMPtr <nsIMdbRow> newRow;
   nsAutoString uniStr;
   nsAutoCString  displayName;
 
   for (int32_t i = 0; i < max; i++)
   {
-    pData = (CAliasData *)membersArray.ElementAt(i);
+    pData = membersArray.ElementAt(i);
 
     if (!pData || (pData->m_email.IsEmpty()))
       continue;
 
     rv = pDb->GetNewRow(getter_AddRefs(newRow));
     if (NS_FAILED(rv) || !newRow)
       return rv;
 
@@ -1090,17 +1090,17 @@ nsresult nsEudoraAddress::AddSingleList(
   // Add the name in pEntry as the list nickname, because it was the Eudora nickname
   rv = pDb->AddListNickName(newRow, pEntry->m_name.get());
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Now add the members.
   int32_t max = emailList.Length();
   for (int32_t i = 0; i < max; i++)
   {
-    CAliasData *pData = (CAliasData *)emailList.ElementAt(i);
+    CAliasData *pData = emailList.ElementAt(i);
     nsAutoCString ldifValue("mail");
     ldifValue.Append(pData->m_email);
     rv = pDb->AddLdifListMember(newRow, ldifValue.get());
   }
 
   rv = pDb->AddCardRowToDB(newRow);
   NS_ENSURE_SUCCESS(rv, rv);
 
--- a/mailnews/import/eudora/src/nsEudoraCompose.cpp
+++ b/mailnews/import/eudora/src/nsEudoraCompose.cpp
@@ -516,17 +516,17 @@ nsresult nsEudoraCompose::GetLocalAttach
   ImportAttachment * pAttach;
 
   for (int32_t i = 0; i < count; i++) {
     nsCOMPtr<nsIMsgAttachedFile> a(do_CreateInstance(NS_MSGATTACHEDFILE_CONTRACTID, &rv));
     NS_ENSURE_SUCCESS(rv, rv);
     // nsMsgNewURL(&url, "file://C:/boxster.jpg");
     // a[i].orig_url = url;
 
-    pAttach = (ImportAttachment *) m_pAttachments->ElementAt(i);
+    pAttach = m_pAttachments->ElementAt(i);
     nsCOMPtr<nsIFile> tmpFile = do_QueryInterface(pAttach->pAttachment);
     a->SetTmpFile(tmpFile);
     urlStr.Adopt(0);
 
     nsCOMPtr <nsIURI> uri;
     nsresult rv = NS_NewFileURI(getter_AddRefs(uri), pAttach->pAttachment);
     NS_ENSURE_SUCCESS(rv, rv);
     uri->GetSpec(urlStr);
--- a/mailnews/import/eudora/src/nsEudoraMailbox.cpp
+++ b/mailnews/import/eudora/src/nsEudoraMailbox.cpp
@@ -1214,17 +1214,17 @@ nsresult nsEudoraMailbox::WriteFromSep(n
   return rv;
 }
 
 void nsEudoraMailbox::EmptyAttachments(void)
 {
   int32_t max = m_attachments.Length();
   ImportAttachment *  pAttach;
   for (int32_t i = 0; i < max; i++) {
-    pAttach = (ImportAttachment *) m_attachments.ElementAt(i);
+    pAttach = m_attachments.ElementAt(i);
     if (pAttach) {
       NS_Free(pAttach->description);
       NS_Free(pAttach->mimeType);
       delete pAttach;
     }
   }
 
   m_attachments.Clear();
--- a/mailnews/import/outlook/src/MapiApi.cpp
+++ b/mailnews/import/outlook/src/MapiApi.cpp
@@ -1101,17 +1101,17 @@ void CMapiApi::GetStoreInfo(CMapiFolder 
   }
 }
 
 
 void CMapiApi::ClearMessageStores(void)
 {
   if (m_pStores) {
     CMsgStore *  pStore;
-    for (int i = 0; i < m_pStores->Length(); i++) {
+    for (size_t i = 0; i < m_pStores->Length(); i++) {
       pStore = m_pStores->ElementAt(i);
       delete pStore;
     }
     m_pStores->Clear();
   }
 }
 
 void CMapiApi::AddMessageStore(CMsgStore *pStore)
@@ -1126,17 +1126,17 @@ CMsgStore *  CMapiApi::FindMessageStore(
     MAPI_TRACE0("FindMessageStore called before session is open\n");
     m_lastError = -1;
     return NULL;
   }
 
   ULONG    result;
   HRESULT    hr;
   CMsgStore *  pStore;
-  for (int i = 0; i < m_pStores->Length(); i++) {
+  for (size_t i = 0; i < m_pStores->Length(); i++) {
     pStore = m_pStores->ElementAt(i);
     hr = m_lpSession->CompareEntryIDs(cbEid, lpEid, pStore->GetCBEntryID(), pStore->GetLPEntryID(),
                       0, &result);
     if (HR_FAILED(hr)) {
       MAPI_TRACE2("CompareEntryIDs failed: 0x%lx, %d\n", (long)hr, (int)hr);
       m_lastError = hr;
       return NULL;
     }
@@ -1630,32 +1630,32 @@ void CMapiFolderList::GenerateFilePath(C
   }
   pFolder->GetDisplayName(name);
   pFolder->SetFilePath(name.get());
 }
 
 void CMapiFolderList::ClearAll(void)
 {
   CMapiFolder *pFolder;
-  for (int i = 0; i < m_array.Length(); i++) {
+  for (size_t i = 0; i < m_array.Length(); i++) {
     pFolder = GetAt(i);
     delete pFolder;
   }
   m_array.Clear();
 }
 
 void CMapiFolderList::DumpList(void)
 {
   CMapiFolder *pFolder;
   nsString  str;
   int      depth;
   char    prefix[256];
 
   MAPI_TRACE0("Folder List ---------------------------------\n");
-  for (int i = 0; i < m_array.Length(); i++) {
+  for (size_t i = 0; i < m_array.Length(); i++) {
     pFolder = GetAt(i);
     depth = pFolder->GetDepth();
     pFolder->GetDisplayName(str);
     depth *= 2;
     if (depth > 255)
       depth = 255;
     memset(prefix, ' ', depth);
     prefix[depth] = 0;
--- a/mailnews/import/outlook/src/MapiApi.h
+++ b/mailnews/import/outlook/src/MapiApi.h
@@ -193,17 +193,17 @@ private:
 };
 
 class CMapiFolderList {
 public:
   CMapiFolderList();
   ~CMapiFolderList();
 
   void      AddItem(CMapiFolder *pFolder);
-  CMapiFolder *  GetItem(int index) { if ((index >= 0) && (index < m_array.Length())) return GetAt(index); else return NULL;}
+  CMapiFolder *  GetItem(int index) { if ((index >= 0) && (index < (int)m_array.Length())) return GetAt(index); else return NULL;}
   void      ClearAll(void);
 
   // Debugging and reporting
   void      DumpList(void);
 
   CMapiFolder *  GetAt(int index) { return m_array.ElementAt(index);}
   int        GetSize(void) { return m_array.Length();}
 
--- a/mailnews/import/src/nsImportFieldMap.cpp
+++ b/mailnews/import/src/nsImportFieldMap.cpp
@@ -71,17 +71,17 @@ nsImportFieldMap::~nsImportFieldMap()
 {
   if (m_pFields)
     delete [] m_pFields;
   if (m_pActive)
     delete [] m_pActive;
 
   nsString *  pStr;
   for (int32_t i = 0; i < m_mozFieldCount; i++) {
-    pStr = (nsString *) m_descriptions.ElementAt(i);
+    pStr = m_descriptions.ElementAt(i);
     delete pStr;
   }
   m_descriptions.Clear();
 }
 
 
 NS_IMETHODIMP nsImportFieldMap::GetNumMozFields(int32_t *aNumFields)
 {
@@ -105,20 +105,20 @@ NS_IMETHODIMP nsImportFieldMap::GetMapSi
 
 NS_IMETHODIMP nsImportFieldMap::GetFieldDescription(int32_t index, char16_t **_retval)
 {
     NS_PRECONDITION(_retval != nullptr, "null ptr");
   if (!_retval)
     return NS_ERROR_NULL_POINTER;
 
   *_retval = nullptr;
-  if ((index < 0) || (index >= m_descriptions.Length()))
+  if ((index < 0) || ((size_t)index >= m_descriptions.Length()))
     return NS_ERROR_FAILURE;
 
-  *_retval = ToNewUnicode(*((nsString *)m_descriptions.ElementAt(index)));
+  *_retval = ToNewUnicode(*(m_descriptions.ElementAt(index)));
   return NS_OK;
 }
 
 NS_IMETHODIMP nsImportFieldMap::SetFieldMapSize(int32_t size)
 {
   nsresult rv = Allocate(size);
   if (NS_FAILED(rv))
     return rv;
--- a/mailnews/local/public/nsIPop3Protocol.idl
+++ b/mailnews/local/public/nsIPop3Protocol.idl
@@ -1,25 +1,25 @@
 /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.idl"
 
-[ptr] native nsPop3UidlEntryArrayRef(nsTArray<Pop3UidlEntry*>);
+[ptr] native Pop3UidlEntryArrayRef(nsTArray<Pop3UidlEntry*>);
 
 %{C++
 #include "nsTArray.h"
 struct Pop3UidlEntry;
 %}
 
-[scriptable, uuid(f3e1c1e8-3005-4554-9d46-595b1713a3a6)]
+[scriptable, uuid(3aff0550-87de-4337-9bc1-c84eb5462afe)]
 interface nsIPop3Protocol : nsISupports {
   /* aUidl is an array of pointers to Pop3UidlEntry's. That structure is
    * currently defined in nsPop3Protocol.h, perhaps it should be here
    * instead...
    */
-  [noscript] void markMessages(in nsPop3UidlEntryArrayRef aUidl);
+  [noscript] void markMessages(in Pop3UidlEntryArrayRef aUidl);
   boolean checkMessage(in string aUidl);
 };
 
 
--- a/mailnews/local/src/nsParseMailbox.cpp
+++ b/mailnews/local/src/nsParseMailbox.cpp
@@ -861,33 +861,33 @@ struct message_header *nsParseMailMessag
 void nsParseMailMessageState::GetAggregateHeader (nsTArray<struct message_header*> &list, struct message_header *outHeader)
 {
   // When parsing a message with multiple To or CC header lines, we're storing each line in a
   // list, where the list represents the "aggregate" total of all the header. Here we combine
   // all the lines together, as though they were really all found on the same line
 
   struct message_header *header = nullptr;
   int length = 0;
-  int i;
+  size_t i;
 
   // Count up the bytes required to allocate the aggregated header
   for (i = 0; i < list.Length(); i++)
   {
     header = list.ElementAt(i);
     length += (header->length + 1); //+ for ","
   }
 
   if (length > 0)
   {
     char *value = (char*) PR_CALLOC (length + 1); //+1 for null term
     if (value)
     {
       // Catenate all the To lines together, separated by commas
       value[0] = '\0';
-      int size = list.Length();
+      size_t size = list.Length();
       for (i = 0; i < size; i++)
       {
         header = list.ElementAt(i);
         PL_strncat (value, header->value, header->length);
         if (i + 1 < size)
           PL_strcat (value, ",");
       }
       outHeader->length = length;
@@ -901,17 +901,17 @@ void nsParseMailMessageState::GetAggrega
   }
 }
 
 void nsParseMailMessageState::ClearAggregateHeader (nsTArray<struct message_header*> &list)
 {
   // Reset the aggregate headers. Free only the message_header struct since
   // we don't own the value pointer
 
-  for (int i = 0; i < list.Length(); i++)
+  for (size_t i = 0; i < list.Length(); i++)
     PR_Free (list.ElementAt(i));
   list.Clear();
 }
 
 // We've found a new envelope to parse.
 nsresult nsParseMailMessageState::StartNewEnvelope(const char *line, uint32_t lineLength)
 {
   m_envelope_pos = m_position;
--- a/mailnews/mime/emitters/nsMimeBaseEmitter.cpp
+++ b/mailnews/mime/emitters/nsMimeBaseEmitter.cpp
@@ -86,31 +86,29 @@ nsMimeBaseEmitter::nsMimeBaseEmitter()
   // Do prefs last since we can live without this if it fails...
   nsCOMPtr<nsIPrefBranch> pPrefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
   if (pPrefBranch)
     pPrefBranch->GetIntPref("mail.show_headers", &mHeaderDisplayType);
 }
 
 nsMimeBaseEmitter::~nsMimeBaseEmitter(void)
 {
-  int32_t i;
-
   // Delete the buffer manager...
   if (mBufferMgr)
   {
     delete mBufferMgr;
     mBufferMgr = nullptr;
   }
 
   // Clean up the attachment array structures...
   if (mAttachArray)
   {
-    for (i=0; i<mAttachArray->Length(); i++)
+    for (size_t i = 0; i < mAttachArray->Length(); i++)
     {
-      attachmentInfoType *attachInfo = (attachmentInfoType *)mAttachArray->ElementAt(i);
+      attachmentInfoType *attachInfo = mAttachArray->ElementAt(i);
       if (!attachInfo)
         continue;
 
       PR_FREEIF(attachInfo->contentType);
       if (attachInfo->displayName)
         NS_Free(attachInfo->displayName);
       PR_FREEIF(attachInfo->urlSpec);
       PR_FREEIF(attachInfo);
@@ -133,17 +131,17 @@ NS_IMETHODIMP nsMimeBaseEmitter::GetInte
 }
 
 void
 nsMimeBaseEmitter::CleanupHeaderArray(nsTArray<headerInfoType*> *aArray)
 {
   if (!aArray)
     return;
 
-  for (int32_t i=0; i<aArray->Length(); i++)
+  for (size_t i = 0; i < aArray->Length(); i++)
   {
     headerInfoType *headerInfo = aArray->ElementAt(i);
     if (!headerInfo)
       continue;
 
     PR_FREEIF(headerInfo->name);
     PR_FREEIF(headerInfo->value);
     PR_FREEIF(headerInfo);
@@ -495,24 +493,23 @@ nsMimeBaseEmitter::WriteHelper(const nsA
 }
 
 //
 // Find a cached header! Note: Do NOT free this value!
 //
 const char *
 nsMimeBaseEmitter::GetHeaderValue(const char  *aHeaderName)
 {
-  int32_t     i;
   char        *retVal = nullptr;
   nsTArray<headerInfoType*> *array = mDocHeader? mHeaderArray : mEmbeddedHeaderArray;
 
   if (!array)
     return nullptr;
 
-  for (i = 0; i < array->Length(); i++)
+  for (size_t i = 0; i < array->Length(); i++)
   {
     headerInfoType *headerInfo = array->ElementAt(i);
     if ( (!headerInfo) || (!headerInfo->name) || (!(*headerInfo->name)) )
       continue;
 
     if (!PL_strcasecmp(aHeaderName, headerInfo->name))
     {
       retVal = headerInfo->value;
@@ -980,22 +977,21 @@ nsMimeBaseEmitter::DumpToCC()
   }
 
   return NS_OK;
 }
 
 nsresult
 nsMimeBaseEmitter::DumpRestOfHeaders()
 {
-  int32_t     i;
   nsTArray<headerInfoType*> *array = mDocHeader? mHeaderArray : mEmbeddedHeaderArray;
 
   mHTMLHeaders.Append("<table border=0 cellspacing=0 cellpadding=0 width=\"100%\" class=\"header-part3\">");
 
-  for (i = 0; i < array->Length(); i++)
+  for (size_t i = 0; i < array->Length(); i++)
   {
     headerInfoType *headerInfo = array->ElementAt(i);
     if ( (!headerInfo) || (!headerInfo->name) || (!(*headerInfo->name)) ||
       (!headerInfo->value) || (!(*headerInfo->value)))
       continue;
 
     if ( (!PL_strcasecmp(HEADER_SUBJECT, headerInfo->name)) ||
       (!PL_strcasecmp(HEADER_DATE, headerInfo->name)) ||
--- a/mailnews/mime/emitters/nsMimeHtmlEmitter.cpp
+++ b/mailnews/mime/emitters/nsMimeHtmlEmitter.cpp
@@ -179,17 +179,17 @@ nsresult nsMimeHtmlDisplayEmitter::Broad
     // todo - should make this upper case
     if (!extraExpandedHeaders.IsEmpty())
     {
       ToLowerCase(extraExpandedHeaders);
       ParseString(extraExpandedHeaders, ' ', extraExpandedHeadersArray);
     }
   }
 
-  for (int32_t i=0; i<mHeaderArray->Length(); i++)
+  for (size_t i = 0; i < mHeaderArray->Length(); i++)
   {
     headerInfoType * headerInfo = mHeaderArray->ElementAt(i);
     if ( (!headerInfo) || (!headerInfo->name) || (!(*headerInfo->name)) || (!headerInfo->value) || (!(*headerInfo->value)))
       continue;
 
     const char * headerValue = headerInfo->value;
 
     // optimization: if we aren't in view all header view mode, we only show a small set of the total # of headers.
@@ -246,17 +246,17 @@ NS_IMETHODIMP nsMimeHtmlDisplayEmitter::
       mFormat = nsMimeOutput::nsMimeMessagePrintOutput;
 
     return nsMimeBaseEmitter::WriteHTMLHeaders(name);
   }
   else
     mFirstHeaders = false;
 
   bool bFromNewsgroups = false;
-  for (int32_t j=0; j < mHeaderArray->Length(); j++)
+  for (size_t j = 0; j < mHeaderArray->Length(); j++)
   {
     headerInfoType *headerInfo = mHeaderArray->ElementAt(j);
     if (!(headerInfo && headerInfo->name && *headerInfo->name))
       continue;
 
     if (!PL_strcasecmp("Newsgroups", headerInfo->name))
     {
       bFromNewsgroups = true;