Bug 962821 - error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]; r=jcranmer
authorJim Porter <jporter@mozilla.com>
Thu, 23 Jan 2014 17:27:34 -0600
changeset 19335 507cf80a989eeb205649c7d4db7bad995ebe52d4
parent 19334 90bc6a3ced716d86571ce1f310eed22a76c231a3
child 19336 dcc265385f91a1347d8cd4e2a868b174d08cad13
push id1103
push usermbanner@mozilla.com
push dateTue, 18 Mar 2014 07:44:06 +0000
treeherdercomm-beta@50c6279a0af0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjcranmer
bugs962821
Bug 962821 - error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]; r=jcranmer
calendar/libical/src/libical/icalrecur.c
mailnews/addrbook/src/nsAbLDIFService.cpp
mailnews/db/msgdb/src/nsMsgDatabase.cpp
mailnews/local/src/nsPop3Protocol.cpp
--- a/calendar/libical/src/libical/icalrecur.c
+++ b/calendar/libical/src/libical/icalrecur.c
@@ -1892,30 +1892,30 @@ static pvl_list expand_by_day(icalrecur_
             /* First occurrence of dow in year */
             if( dow >= start_dow) {
                 first = dow - start_dow + 1;
             } else {
                 first = dow - start_dow + 8;
             }
 
             /* Then just multiple the position times 7 to get the pos'th day in the year */
-            pvl_push(days_list,(void*)(first+  (pos-1) * 7));
+            pvl_push(days_list,(void*)(ptrdiff_t)(first + (pos-1) * 7));
             
         } else { /* pos < 0 */ 
             int last;
             pos = -pos;
 
             /* last occurrence of dow in year */
             if( dow <= end_dow) {
                 last = end_year_day - end_dow + dow;
             } else {
                 last = end_year_day - end_dow + dow - 7;
             }
 
-            pvl_push(days_list,(void*)(last - (pos-1) * 7));
+            pvl_push(days_list,(void*)(ptrdiff_t)(last - (pos-1) * 7));
         }
     }
     return days_list;
 }
 
 
 /* For INTERVAL=YEARLY, set up the days[] array in the iterator to
    list all of the days of the current year that are specified in this
--- a/mailnews/addrbook/src/nsAbLDIFService.cpp
+++ b/mailnews/addrbook/src/nsAbLDIFService.cpp
@@ -4,17 +4,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 #include "nsIAddrDatabase.h"
 #include "nsStringGlue.h"
 #include "nsAbLDIFService.h"
 #include "nsIFile.h"
 #include "nsILineInputStream.h"
 #include "nsNetUtil.h"
 #include "nsISeekableStream.h"
-#include "nsVoidArray.h"
 #include "mdb.h"
 #include "plstr.h"
 #include "prmem.h"
 #include "prprf.h"
 #include "nsCRTGlue.h"
 
 #include <ctype.h>
 
@@ -66,18 +65,18 @@ NS_IMETHODIMP nsAbLDIFService::ImportLDI
   NS_ENSURE_ARG_POINTER(aDb);
 
   mStoreLocAsHome = aStoreLocAsHome;
 
   char buf[1024];
   char* pBuf = &buf[0];
   int32_t startPos = 0;
   uint32_t len = 0;
-  nsVoidArray listPosArray;   // where each list/group starts in ldif file
-  nsVoidArray listSizeArray;  // size of the list/group info
+  nsTArray<int32_t> listPosArray;   // where each list/group starts in ldif file
+  nsTArray<int32_t> listSizeArray;  // size of the list/group info
   int32_t savedStartPos = 0;
   int32_t filePos = 0;
   uint64_t bytesLeft = 0;
 
   nsCOMPtr<nsIInputStream> inputStream;
   nsresult rv = NS_NewLocalFileInputStream(getter_AddRefs(inputStream), aSrc);
   NS_ENSURE_SUCCESS(rv, rv);
 
@@ -92,45 +91,45 @@ NS_IMETHODIMP nsAbLDIFService::ImportLDI
 
       while (NS_SUCCEEDED(GetLdifStringRecord(buf, len, startPos)))
       {
         if (mLdifLine.Find("groupOfNames") == -1)
           AddLdifRowToDatabase(aDb, false);
         else
         {
           //keep file position for mailing list
-          listPosArray.AppendElement((void*)savedStartPos);
-          listSizeArray.AppendElement((void*)(filePos + startPos-savedStartPos));
+          listPosArray.AppendElement(savedStartPos);
+          listSizeArray.AppendElement(filePos + startPos-savedStartPos);
           ClearLdifRecordBuffer();
         }
         savedStartPos = filePos + startPos;
       }
       filePos += len;
       if (aProgress)
         *aProgress = (uint32_t)filePos;
     }
   }
   //last row
   if (!mLdifLine.IsEmpty() && mLdifLine.Find("groupOfNames") == -1)
-    AddLdifRowToDatabase(aDb, false); 
+    AddLdifRowToDatabase(aDb, false);
 
   // mail Lists
   int32_t i, pos;
   uint32_t size;
-  int32_t listTotal = listPosArray.Count();
+  int32_t listTotal = listPosArray.Length();
   char *listBuf;
   ClearLdifRecordBuffer();  // make sure the buffer is clean
 
   nsCOMPtr<nsISeekableStream> seekableStream = do_QueryInterface(inputStream, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   for (i = 0; i < listTotal; i++)
   {
-    pos  = NS_PTR_TO_INT32(listPosArray.ElementAt(i));
-    size = NS_PTR_TO_INT32(listSizeArray.ElementAt(i));
+    pos  = listPosArray[i];
+    size = listSizeArray[i];
     if (NS_SUCCEEDED(seekableStream->Seek(nsISeekableStream::NS_SEEK_SET, pos)))
     {
       // Allocate enough space for the lists/groups as the size varies.
       listBuf = (char *) PR_Malloc(size);
       if (!listBuf)
         continue;
       if (NS_SUCCEEDED(inputStream->Read(listBuf, size, &len)) && len > 0)
       {
--- a/mailnews/db/msgdb/src/nsMsgDatabase.cpp
+++ b/mailnews/db/msgdb/src/nsMsgDatabase.cpp
@@ -462,17 +462,17 @@ nsresult nsMsgDatabase::AddHdrToCache(ns
     if (!m_cachedHeaders)
       m_cachedHeaders = PL_NewDHashTable(&gMsgDBHashTableOps, (void *) nullptr, sizeof(struct MsgHdrHashElement), m_cacheSize );
     if (m_cachedHeaders)
     {
       if (key == nsMsgKey_None)
         hdr->GetMessageKey(&key);
       if (m_cachedHeaders->entryCount > m_cacheSize)
         ClearHdrCache(true);
-      PLDHashEntryHdr *entry = PL_DHashTableOperate(m_cachedHeaders, (void *) key, PL_DHASH_ADD);
+      PLDHashEntryHdr *entry = PL_DHashTableOperate(m_cachedHeaders, (void *)(uintptr_t) key, PL_DHASH_ADD);
       if (!entry)
         return NS_ERROR_OUT_OF_MEMORY; // XXX out of memory
 
       MsgHdrHashElement* element = reinterpret_cast<MsgHdrHashElement*>(entry);
       element->mHdr = hdr;
       element->mKey = key;
       NS_ADDREF(hdr);     // make the cache hold onto the header
       return NS_OK;
@@ -629,20 +629,20 @@ nsresult nsMsgDatabase::ClearHdrCache(bo
 
 nsresult nsMsgDatabase::RemoveHdrFromCache(nsIMsgDBHdr *hdr, nsMsgKey key)
 {
   if (m_cachedHeaders)
   {
     if (key == nsMsgKey_None)
       hdr->GetMessageKey(&key);
 
-    PLDHashEntryHdr *entry = PL_DHashTableOperate(m_cachedHeaders, (const void *) key, PL_DHASH_LOOKUP);
+    PLDHashEntryHdr *entry = PL_DHashTableOperate(m_cachedHeaders, (const void *)(uintptr_t) key, PL_DHASH_LOOKUP);
     if (PL_DHASH_ENTRY_IS_BUSY(entry))
     {
-      PL_DHashTableOperate(m_cachedHeaders, (void *) key, PL_DHASH_REMOVE);
+      PL_DHashTableOperate(m_cachedHeaders, (void *)(uintptr_t) key, PL_DHASH_REMOVE);
       NS_RELEASE(hdr); // get rid of extra ref the cache was holding.
     }
 
   }
   return NS_OK;
 }
 
 
@@ -653,17 +653,17 @@ nsresult nsMsgDatabase::GetHdrFromUseCac
 
   nsresult rv = NS_ERROR_FAILURE;
 
   *result = nullptr;
 
   if (m_headersInUse)
   {
     PLDHashEntryHdr *entry;
-    entry = PL_DHashTableOperate(m_headersInUse, (const void *) key, PL_DHASH_LOOKUP);
+    entry = PL_DHashTableOperate(m_headersInUse, (const void *)(uintptr_t) key, PL_DHASH_LOOKUP);
     if (PL_DHASH_ENTRY_IS_BUSY(entry))
     {
       MsgHdrHashElement* element = reinterpret_cast<MsgHdrHashElement*>(entry);
       *result = element->mHdr;
     }
     if (*result)
     {
       NS_ADDREF(*result);
@@ -692,17 +692,17 @@ nsMsgDatabase::HashKey(PLDHashTable* aTa
 {
   return PLDHashNumber(NS_PTR_TO_INT32(aKey));
 }
 
 bool
 nsMsgDatabase::MatchEntry(PLDHashTable* aTable, const PLDHashEntryHdr* aEntry, const void* aKey)
 {
   const MsgHdrHashElement* hdr = reinterpret_cast<const MsgHdrHashElement*>(aEntry);
-  return aKey == (const void *) hdr->mKey; // ### or get the key from the hdr...
+  return aKey == (const void *)(uintptr_t) hdr->mKey; // ### or get the key from the hdr...
 }
 
 void
 nsMsgDatabase::MoveEntry(PLDHashTable* aTable, const PLDHashEntryHdr* aFrom, PLDHashEntryHdr* aTo)
 {
   const MsgHdrHashElement* from = reinterpret_cast<const MsgHdrHashElement*>(aFrom);
   MsgHdrHashElement* to = reinterpret_cast<MsgHdrHashElement*>(aTo);
   // ### eh? Why is this needed? I don't think we have a copy operator?
@@ -726,17 +726,17 @@ nsresult nsMsgDatabase::AddHdrToUseCache
     if (m_mdbAllMsgHeadersTable)
       m_mdbAllMsgHeadersTable->GetCount(GetEnv(), &numHdrs);
     m_headersInUse = PL_NewDHashTable(&gMsgDBHashTableOps, (void *) nullptr, sizeof(struct MsgHdrHashElement), std::max((mdb_count)MSG_HASH_SIZE, numHdrs));
   }
   if (m_headersInUse)
   {
     if (key == nsMsgKey_None)
       hdr->GetMessageKey(&key);
-    PLDHashEntryHdr *entry = PL_DHashTableOperate(m_headersInUse, (void *) key, PL_DHASH_ADD);
+    PLDHashEntryHdr *entry = PL_DHashTableOperate(m_headersInUse, (void *)(uintptr_t) key, PL_DHASH_ADD);
     if (!entry)
       return NS_ERROR_OUT_OF_MEMORY; // XXX out of memory
 
     MsgHdrHashElement* element = reinterpret_cast<MsgHdrHashElement*>(entry);
     element->mHdr = hdr;
     element->mKey = key;
     // the hash table won't add ref, we'll do it ourselves
     // stand for the addref that CreateMsgHdr normally does.
@@ -762,17 +762,17 @@ nsresult nsMsgDatabase::ClearUseHdrCache
 
 nsresult nsMsgDatabase::RemoveHdrFromUseCache(nsIMsgDBHdr *hdr, nsMsgKey key)
 {
   if (m_headersInUse)
   {
     if (key == nsMsgKey_None)
       hdr->GetMessageKey(&key);
 
-    PL_DHashTableOperate(m_headersInUse, (void *) key, PL_DHASH_REMOVE);
+    PL_DHashTableOperate(m_headersInUse, (void *)(uintptr_t) key, PL_DHASH_REMOVE);
   }
   return NS_OK;
 }
 
 
 nsresult
 nsMsgDatabase::CreateMsgHdr(nsIMdbRow* hdrRow, nsMsgKey key, nsIMsgDBHdr* *result)
 {
--- a/mailnews/local/src/nsPop3Protocol.cpp
+++ b/mailnews/local/src/nsPop3Protocol.cpp
@@ -1085,17 +1085,17 @@ nsresult nsPop3Protocol::LoadUrl(nsIURI*
 
   m_pop3ConData->biffstate = nsIMsgFolder::nsMsgBiffState_NoMail;
 
   if (m_pop3ConData->uidlinfo && numDaysToLeaveOnServer > 0)
   {
     uint32_t nowInSeconds = TimeInSecondsFromPRTime(PR_Now());
     uint32_t cutOffDay = nowInSeconds - (60 * 60 * 24 * numDaysToLeaveOnServer);
 
-    PL_HashTableEnumerateEntries(m_pop3ConData->uidlinfo->hash, net_pop3_delete_old_msgs_mapper, (void *) cutOffDay);
+    PL_HashTableEnumerateEntries(m_pop3ConData->uidlinfo->hash, net_pop3_delete_old_msgs_mapper, (void *)(uintptr_t) cutOffDay);
   }
   const char* uidl = PL_strcasestr(queryPart.get(), "uidl=");
   PR_FREEIF(m_pop3ConData->only_uidl);
 
   if (uidl)
   {
     uidl += 5;
     nsCString unescapedData;