From c17ab6c5969da79621d14fa6af7309a1c594d2c0 Mon Sep 17 00:00:00 2001 From: Stefan Sitter Date: Wed, 13 May 2015 21:07:16 +0200 Subject: [PATCH] Bug 777770 - Replace nsVoidArray with nsTArray, part 2. r=rkent a=me CLOSED TREE --- mailnews/addrbook/src/nsAbView.cpp | 52 ++++++++----------- mailnews/addrbook/src/nsDirPrefs.cpp | 20 +++---- mailnews/addrbook/src/nsDirPrefs.h | 4 +- mailnews/base/src/nsMsgDBView.cpp | 2 +- mailnews/base/src/nsMsgDBView.h | 1 - mailnews/imap/src/nsIMAPBodyShell.cpp | 4 +- mailnews/imap/src/nsIMAPNamespace.cpp | 16 +++--- mailnews/imap/src/nsImapIncomingServer.cpp | 2 +- mailnews/imap/src/nsImapProtocol.cpp | 14 ++--- .../import/eudora/src/nsEudoraAddress.cpp | 20 +++---- .../import/eudora/src/nsEudoraCompose.cpp | 2 +- .../import/eudora/src/nsEudoraMailbox.cpp | 2 +- mailnews/import/outlook/src/MapiApi.cpp | 8 +-- mailnews/import/outlook/src/MapiApi.h | 2 +- mailnews/import/src/nsImportFieldMap.cpp | 6 +-- mailnews/local/public/nsIPop3Protocol.idl | 6 +-- mailnews/local/src/nsParseMailbox.cpp | 6 +-- mailnews/mime/emitters/nsMimeBaseEmitter.cpp | 14 ++--- mailnews/mime/emitters/nsMimeHtmlEmitter.cpp | 4 +- 19 files changed, 86 insertions(+), 99 deletions(-) diff --git a/mailnews/addrbook/src/nsAbView.cpp b/mailnews/addrbook/src/nsAbView.cpp index bc207ce0dc..627caabb20 100644 --- a/mailnews/addrbook/src/nsAbView.cpp +++ b/mailnews/addrbook/src/nsAbView.cpp @@ -98,7 +98,7 @@ 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); @@ -354,7 +354,7 @@ NS_IMETHODIMP nsAbView::GetCellProperties(int32_t row, nsITreeColumn* col, nsASt { 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; @@ -525,7 +525,7 @@ nsresult nsAbView::RefreshTree() 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; @@ -612,12 +612,11 @@ NS_IMETHODIMP nsAbView::PerformActionOnCell(const char16_t *action, int32_t row, 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; @@ -637,13 +636,8 @@ typedef struct SortClosure } 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 @@ -679,19 +673,20 @@ static void SetSortClosure(const char16_t *sortColumn, const char16_t *sortDirec 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) @@ -952,16 +947,13 @@ 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; @@ -1046,7 +1038,7 @@ int32_t nsAbView::FindIndexForCard(nsIAbCard *card) // 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) { @@ -1068,7 +1060,7 @@ NS_IMETHODIMP nsAbView::OnItemPropertyChanged(nsISupports *item, const char *pro 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)); diff --git a/mailnews/addrbook/src/nsDirPrefs.cpp b/mailnews/addrbook/src/nsDirPrefs.cpp index a4aee72dd9..5e4c046b2d 100644 --- a/mailnews/addrbook/src/nsDirPrefs.cpp +++ b/mailnews/addrbook/src/nsDirPrefs.cpp @@ -199,7 +199,7 @@ DIR_Server* DIR_GetServerFromList(const char* prefName) 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) { @@ -249,7 +249,7 @@ nsresult DIR_ContainsServer(DIR_Server* pServer, bool *hasDir) 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; @@ -354,7 +354,7 @@ static bool DIR_SetServerPosition(nsTArray *wholeList, DIR_Server * 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; } @@ -364,7 +364,7 @@ static bool DIR_SetServerPosition(nsTArray *wholeList, DIR_Server * */ if (count > 0) { - s = (DIR_Server *)wholeList->ElementAt(count - 1); + s = wholeList->ElementAt(count - 1); server->position = s->position + 1; } else @@ -418,7 +418,7 @@ static bool DIR_SetServerPosition(nsTArray *wholeList, DIR_Server * 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; } @@ -468,7 +468,7 @@ static DIR_Server *dir_MatchServerPrefToServer(nsTArray *wholeList, 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) { @@ -681,7 +681,7 @@ static void DIR_DeleteServerList(nsTArray *wholeList) 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); } @@ -1191,9 +1191,9 @@ void DIR_SortServersByPosition(nsTArray *serverList) { 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); } @@ -1443,7 +1443,7 @@ static void DIR_SaveServerPreferences(nsTArray *wholeList) for (i = 0; i < count; i++) { - server = (DIR_Server *) wholeList->ElementAt(i); + server = wholeList->ElementAt(i); if (server) DIR_SavePrefsForOneServer(server); } diff --git a/mailnews/addrbook/src/nsDirPrefs.h b/mailnews/addrbook/src/nsDirPrefs.h index e341365a99..d27a4fcb5f 100644 --- a/mailnews/addrbook/src/nsDirPrefs.h +++ b/mailnews/addrbook/src/nsDirPrefs.h @@ -6,13 +6,13 @@ #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 nsTArray; - #define kPreviousListVersion 2 #define kCurrentListVersion 3 #define PREF_LDAP_GLOBAL_TREE_NAME "ldap_2" diff --git a/mailnews/base/src/nsMsgDBView.cpp b/mailnews/base/src/nsMsgDBView.cpp index 27dfe2a208..e314fffcad 100644 --- a/mailnews/base/src/nsMsgDBView.cpp +++ b/mailnews/base/src/nsMsgDBView.cpp @@ -5584,7 +5584,7 @@ NS_IMETHODIMP nsMsgDBView::InsertTreeRows(nsMsgViewIndex aIndex, { // 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; diff --git a/mailnews/base/src/nsMsgDBView.h b/mailnews/base/src/nsMsgDBView.h index 1e4e59eeb0..5babde84c2 100644 --- a/mailnews/base/src/nsMsgDBView.h +++ b/mailnews/base/src/nsMsgDBView.h @@ -12,7 +12,6 @@ #include "nsIMsgDatabase.h" #include "nsIMsgHdr.h" #include "MailNewsTypes.h" -#include "nsTArray.h" #include "nsIDBChangeListener.h" #include "nsITreeView.h" #include "nsITreeBoxObject.h" diff --git a/mailnews/imap/src/nsIMAPBodyShell.cpp b/mailnews/imap/src/nsIMAPBodyShell.cpp index 0cca39b1bc..bd4b2eab13 100644 --- a/mailnews/imap/src/nsIMAPBodyShell.cpp +++ b/mailnews/imap/src/nsIMAPBodyShell.cpp @@ -1013,7 +1013,7 @@ int32_t nsIMAPBodypartMultipart::Generate(nsIMAPBodyShell *aShell, bool stream, 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); @@ -1086,7 +1086,7 @@ 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); diff --git a/mailnews/imap/src/nsIMAPNamespace.cpp b/mailnews/imap/src/nsIMAPNamespace.cpp index 60074a61a3..24df68f7b4 100644 --- a/mailnews/imap/src/nsIMAPNamespace.cpp +++ b/mailnews/imap/src/nsIMAPNamespace.cpp @@ -116,7 +116,7 @@ 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++; @@ -136,7 +136,7 @@ int nsIMAPNamespaceList::AddNewNamespace(nsIMAPNamespace *ns) // 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 @@ -169,7 +169,7 @@ nsIMAPNamespace *nsIMAPNamespaceList::GetDefaultNamespaceOfType(EIMAPNamespaceTy 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) @@ -200,7 +200,7 @@ void nsIMAPNamespaceList::ClearNamespaces(bool deleteFromPrefsNamespaces, bool d // 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) @@ -225,15 +225,15 @@ nsIMAPNamespace *nsIMAPNamespaceList::GetNamespaceNumber(int nodeIndex) 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++; @@ -265,7 +265,7 @@ nsIMAPNamespace *nsIMAPNamespaceList::GetNamespaceForMailbox(const char *boxname 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) { diff --git a/mailnews/imap/src/nsImapIncomingServer.cpp b/mailnews/imap/src/nsImapIncomingServer.cpp index d3dd09e246..cfb6134f3c 100644 --- a/mailnews/imap/src/nsImapIncomingServer.cpp +++ b/mailnews/imap/src/nsImapIncomingServer.cpp @@ -543,7 +543,7 @@ nsImapIncomingServer::LoadNextQueuedUrl(nsIImapProtocol *aProtocol, bool *aResul // 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); diff --git a/mailnews/imap/src/nsImapProtocol.cpp b/mailnews/imap/src/nsImapProtocol.cpp index eaca86f84e..df4d47e59e 100644 --- a/mailnews/imap/src/nsImapProtocol.cpp +++ b/mailnews/imap/src/nsImapProtocol.cpp @@ -6774,15 +6774,15 @@ bool nsImapProtocol::RenameHierarchyByHand(const char *oldParentMailboxName, 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; @@ -6838,8 +6838,8 @@ bool nsImapProtocol::DeleteSubFolders(const char* selectedMailbox, bool &aDelete // 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 @@ -6853,7 +6853,7 @@ bool nsImapProtocol::DeleteSubFolders(const char* selectedMailbox, bool &aDelete strcpy(selectedMailboxDir, selectedMailbox); selectedMailboxDir[length] = onlineDirSeparator; selectedMailboxDir[length+1] = '\0'; - int32_t i; + size_t i; for( i=0; iElementAt(i); @@ -6869,7 +6869,7 @@ bool nsImapProtocol::DeleteSubFolders(const char* selectedMailbox, bool &aDelete 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++) diff --git a/mailnews/import/eudora/src/nsEudoraAddress.cpp b/mailnews/import/eudora/src/nsEudoraAddress.cpp index a3d9f84823..7008bb1b51 100644 --- a/mailnews/import/eudora/src/nsEudoraAddress.cpp +++ b/mailnews/import/eudora/src/nsEudoraAddress.cpp @@ -61,8 +61,8 @@ public: 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(); @@ -157,7 +157,7 @@ int32_t nsEudoraAddress::CountWhiteSpace(const char *pLine, int32_t len) 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; } @@ -546,7 +546,7 @@ void DumpAliasArray(nsTArray& a) 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()); @@ -554,7 +554,7 @@ void DumpAliasArray(nsTArray& a) } } 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()); @@ -589,7 +589,7 @@ void nsEudoraAddress::ResolveEntries(nsCString& name, nsTArray& lis 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)) { @@ -863,7 +863,7 @@ void nsEudoraAddress::AddSingleCard(CAliasEntry *pEntry, nsTArray & } } - 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; @@ -1014,7 +1014,7 @@ void nsEudoraAddress::RememberGroupMembers(nsTArray &membersArray, for (int32_t i = 0; i < cnt; i++) { - pData = (CAliasData *)emailList.ElementAt(i); + pData = emailList.ElementAt(i); if (!pData) continue; @@ -1041,7 +1041,7 @@ nsresult nsEudoraAddress::AddGroupMembersAsCards(nsTArray &membersA for (int32_t i = 0; i < max; i++) { - pData = (CAliasData *)membersArray.ElementAt(i); + pData = membersArray.ElementAt(i); if (!pData || (pData->m_email.IsEmpty())) continue; @@ -1095,7 +1095,7 @@ nsresult nsEudoraAddress::AddSingleList(CAliasEntry *pEntry, nsTArraym_email); rv = pDb->AddLdifListMember(newRow, ldifValue.get()); diff --git a/mailnews/import/eudora/src/nsEudoraCompose.cpp b/mailnews/import/eudora/src/nsEudoraCompose.cpp index 1b82c5764a..e44381e0b1 100644 --- a/mailnews/import/eudora/src/nsEudoraCompose.cpp +++ b/mailnews/import/eudora/src/nsEudoraCompose.cpp @@ -521,7 +521,7 @@ nsresult nsEudoraCompose::GetLocalAttachments(nsIArray **aArray) // nsMsgNewURL(&url, "file://C:/boxster.jpg"); // a[i].orig_url = url; - pAttach = (ImportAttachment *) m_pAttachments->ElementAt(i); + pAttach = m_pAttachments->ElementAt(i); nsCOMPtr tmpFile = do_QueryInterface(pAttach->pAttachment); a->SetTmpFile(tmpFile); urlStr.Adopt(0); diff --git a/mailnews/import/eudora/src/nsEudoraMailbox.cpp b/mailnews/import/eudora/src/nsEudoraMailbox.cpp index 5f2e336e87..f44cc2e07e 100644 --- a/mailnews/import/eudora/src/nsEudoraMailbox.cpp +++ b/mailnews/import/eudora/src/nsEudoraMailbox.cpp @@ -1219,7 +1219,7 @@ 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); diff --git a/mailnews/import/outlook/src/MapiApi.cpp b/mailnews/import/outlook/src/MapiApi.cpp index eeb4e13cd2..257b3873e2 100644 --- a/mailnews/import/outlook/src/MapiApi.cpp +++ b/mailnews/import/outlook/src/MapiApi.cpp @@ -1106,7 +1106,7 @@ 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; } @@ -1131,7 +1131,7 @@ CMsgStore * CMapiApi::FindMessageStore(ULONG cbEid, LPENTRYID lpEid) 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); @@ -1635,7 +1635,7 @@ void CMapiFolderList::GenerateFilePath(CMapiFolder *pFolder) 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; } @@ -1650,7 +1650,7 @@ void CMapiFolderList::DumpList(void) 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); diff --git a/mailnews/import/outlook/src/MapiApi.h b/mailnews/import/outlook/src/MapiApi.h index 7fae8a566d..8b59b80d81 100644 --- a/mailnews/import/outlook/src/MapiApi.h +++ b/mailnews/import/outlook/src/MapiApi.h @@ -198,7 +198,7 @@ public: ~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 diff --git a/mailnews/import/src/nsImportFieldMap.cpp b/mailnews/import/src/nsImportFieldMap.cpp index f62d9413a4..d5e9748dc4 100644 --- a/mailnews/import/src/nsImportFieldMap.cpp +++ b/mailnews/import/src/nsImportFieldMap.cpp @@ -76,7 +76,7 @@ nsImportFieldMap::~nsImportFieldMap() 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(); @@ -110,10 +110,10 @@ NS_IMETHODIMP nsImportFieldMap::GetFieldDescription(int32_t index, char16_t **_r 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; } diff --git a/mailnews/local/public/nsIPop3Protocol.idl b/mailnews/local/public/nsIPop3Protocol.idl index c8a2383d05..9bcdb28d20 100644 --- a/mailnews/local/public/nsIPop3Protocol.idl +++ b/mailnews/local/public/nsIPop3Protocol.idl @@ -5,20 +5,20 @@ #include "nsISupports.idl" -[ptr] native nsPop3UidlEntryArrayRef(nsTArray); +[ptr] native Pop3UidlEntryArrayRef(nsTArray); %{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); }; diff --git a/mailnews/local/src/nsParseMailbox.cpp b/mailnews/local/src/nsParseMailbox.cpp index 26ef544a48..ddbb7ef6c6 100644 --- a/mailnews/local/src/nsParseMailbox.cpp +++ b/mailnews/local/src/nsParseMailbox.cpp @@ -866,7 +866,7 @@ void nsParseMailMessageState::GetAggregateHeader (nsTArrayLength(); i++) + for (size_t i = 0; i < mAttachArray->Length(); i++) { - attachmentInfoType *attachInfo = (attachmentInfoType *)mAttachArray->ElementAt(i); + attachmentInfoType *attachInfo = mAttachArray->ElementAt(i); if (!attachInfo) continue; @@ -138,7 +136,7 @@ nsMimeBaseEmitter::CleanupHeaderArray(nsTArray *aArray) if (!aArray) return; - for (int32_t i=0; iLength(); i++) + for (size_t i = 0; i < aArray->Length(); i++) { headerInfoType *headerInfo = aArray->ElementAt(i); if (!headerInfo) @@ -500,14 +498,13 @@ nsMimeBaseEmitter::WriteHelper(const nsACString &buf, uint32_t *countWritten) const char * nsMimeBaseEmitter::GetHeaderValue(const char *aHeaderName) { - int32_t i; char *retVal = nullptr; nsTArray *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)) ) @@ -985,12 +982,11 @@ nsMimeBaseEmitter::DumpToCC() nsresult nsMimeBaseEmitter::DumpRestOfHeaders() { - int32_t i; nsTArray *array = mDocHeader? mHeaderArray : mEmbeddedHeaderArray; mHTMLHeaders.Append(""); - 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)) || diff --git a/mailnews/mime/emitters/nsMimeHtmlEmitter.cpp b/mailnews/mime/emitters/nsMimeHtmlEmitter.cpp index c4ded05da8..57c502a7ed 100644 --- a/mailnews/mime/emitters/nsMimeHtmlEmitter.cpp +++ b/mailnews/mime/emitters/nsMimeHtmlEmitter.cpp @@ -184,7 +184,7 @@ nsresult nsMimeHtmlDisplayEmitter::BroadcastHeaders(nsIMsgHeaderSink * aHeaderSi } } - for (int32_t i=0; iLength(); 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))) @@ -251,7 +251,7 @@ NS_IMETHODIMP nsMimeHtmlDisplayEmitter::WriteHTMLHeaders(const nsACString &name) 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))