Bug 666612 - Fix compiler warnings in xpt_xdr.c. r=dougt
authorNathan Froyd <froydnj@mozilla.com>
Tue, 21 Feb 2012 08:49:18 -0800
changeset 88311 897ee1cf851407fce0bd6d05b3ae320bdc180ad5
parent 88310 f2585061410d3f5fdcffda2bf26dd5da9fadfc95
child 88312 ac7a006e4420edcea91a0a7d900dc19b837053b3
push id157
push userMs2ger@gmail.com
push dateWed, 07 Mar 2012 19:27:10 +0000
reviewersdougt
bugs666612
milestone13.0a1
Bug 666612 - Fix compiler warnings in xpt_xdr.c. r=dougt
xpcom/typelib/xpt/src/xpt_xdr.c
--- a/xpcom/typelib/xpt/src/xpt_xdr.c
+++ b/xpcom/typelib/xpt/src/xpt_xdr.c
@@ -34,16 +34,17 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 /* Implementation of XDR primitives. */
 
 #include "xpt_xdr.h"
 #include "nspr.h"
+#include "nscore.h"
 #include <string.h>             /* strchr */
 
 static PRBool
 CheckForRepeat(XPTCursor *cursor, void **addrp, XPTPool pool, PRUint32 len,
                    XPTCursor *new_cursor, PRBool *already);
 
 #define ENCODING(cursor)                                                      \
   ((cursor)->state->mode == XPT_ENCODE)
@@ -138,33 +139,33 @@ XPT_HashTableDestroy(XPTHashTable *table
     for (i = 0; i < XPT_HASHSIZE; i++)
         trimrecord(table->arena, table->buckets[i]);
     XPT_FREE(table->arena, table);
 }
 
 static void *
 XPT_HashTableAdd(XPTHashTable *table, void *key, void *value) {
     XPTHashRecord **bucketloc = table->buckets +
-        (((PRUint32)key) % XPT_HASHSIZE);
+        (NS_PTR_TO_UINT32(key) % XPT_HASHSIZE);
     XPTHashRecord *bucket;
 
     while (*bucketloc != NULL)
         bucketloc = &((*bucketloc)->next);
 
     bucket = XPT_NEW(table->arena, XPTHashRecord);
     bucket->key = key;
     bucket->value = value;
     bucket->next = NULL;
     *bucketloc = bucket;
     return value;
 }
 
 static void *
 XPT_HashTableLookup(XPTHashTable *table, void *key) {
-    XPTHashRecord *bucket = table->buckets[(PRUint32)key % XPT_HASHSIZE];
+    XPTHashRecord *bucket = table->buckets[NS_PTR_TO_UINT32(key) % XPT_HASHSIZE];
     while (bucket != NULL) {
         if (bucket->key == key)
             return bucket->value;
         bucket = bucket->next;
     }
     return NULL;
 }
 
@@ -478,37 +479,39 @@ XPT_DoCString(XPTArena *arena, XPTCursor
     return PR_TRUE;
 }
 
 /* XXXjband it bothers me that this is one hashtable instead of two.
  */
 XPT_PUBLIC_API(PRUint32)
 XPT_GetOffsetForAddr(XPTCursor *cursor, void *addr)
 {
-    return (PRUint32)XPT_HashTableLookup(cursor->state->pool->offset_map, addr);
+    XPTHashTable *table = cursor->state->pool->offset_map;
+    return NS_PTR_TO_UINT32(XPT_HashTableLookup(table, addr));
 }
 
 XPT_PUBLIC_API(PRBool)
 XPT_SetOffsetForAddr(XPTCursor *cursor, void *addr, PRUint32 offset)
 {
     return XPT_HashTableAdd(cursor->state->pool->offset_map,
-                            addr, (void *)offset) != NULL;
+                            addr, NS_INT32_TO_PTR(offset)) != NULL;
 }
 
 XPT_PUBLIC_API(PRBool)
 XPT_SetAddrForOffset(XPTCursor *cursor, PRUint32 offset, void *addr)
 {
     return XPT_HashTableAdd(cursor->state->pool->offset_map,
-                            (void *)offset, addr) != NULL;
+                            NS_INT32_TO_PTR(offset), addr) != NULL;
 }
 
 XPT_PUBLIC_API(void *)
 XPT_GetAddrForOffset(XPTCursor *cursor, PRUint32 offset)
 {
-    return XPT_HashTableLookup(cursor->state->pool->offset_map, (void *)offset);
+    return XPT_HashTableLookup(cursor->state->pool->offset_map,
+                               NS_INT32_TO_PTR(offset));
 }
 
 /* Used by XPT_PREAMBLE_NO_ALLOC. */
 static PRBool
 CheckForRepeat(XPTCursor *cursor, void **addrp, XPTPool pool, PRUint32 len,
                XPTCursor *new_cursor, PRBool *already)
 {
     void *last = *addrp;