Fix -Wconversion warnings that prevent compiling netwerk/cookie/src/ (which makes warnings fatal) with gcc 4.3 on x86_64. b=409384 r=bsmedberg a=beltzner
authordbaron@dbaron.org
Thu, 06 Mar 2008 15:03:50 -0800
changeset 12692 fcd13a27039ccbc4be8a382680faef0050eea830
parent 12691 80fa3e80e67141b1da34626935113a64b1b43230
child 12693 4f7c6278f114bdc0fd0459c744900f37eb4aeabf
push idunknown
push userunknown
push dateunknown
reviewersbsmedberg, beltzner
bugs409384
milestone1.9b5pre
Fix -Wconversion warnings that prevent compiling netwerk/cookie/src/ (which makes warnings fatal) with gcc 4.3 on x86_64. b=409384 r=bsmedberg a=beltzner
xpcom/glue/nsISupportsImpl.h
xpcom/glue/nsVoidArray.h
xpcom/string/public/nsCharTraits.h
xpcom/string/public/nsTDependentString.h
xpcom/string/public/nsTDependentSubstring.h
xpcom/string/public/nsTString.h
--- a/xpcom/glue/nsISupportsImpl.h
+++ b/xpcom/glue/nsISupportsImpl.h
@@ -428,28 +428,28 @@ NS_IMETHODIMP _class::QueryInterface(REF
                "QueryInterface requires a non-NULL destination!");            \
   nsresult rv = NS_ERROR_FAILURE;
 
 #define NS_INTERFACE_TABLE_BEGIN                                              \
   static const QITableEntry table[] = {
 
 #define NS_INTERFACE_TABLE_ENTRY(_class, _interface)                          \
   { &_interface::COMTypeInfo<int>::kIID,                                      \
-    reinterpret_cast<char*>(                                                  \
+    PROffset32(reinterpret_cast<char*>(                                       \
                         static_cast<_interface*>((_class*) 0x1000)) -         \
-    reinterpret_cast<char*>((_class*) 0x1000)                                 \
+               reinterpret_cast<char*>((_class*) 0x1000))                     \
   },
 
 #define NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, _interface, _implClass)    \
   { &_interface::COMTypeInfo<int>::kIID,                                      \
-    reinterpret_cast<char*>(                                                  \
+    PROffset32(reinterpret_cast<char*>(                                       \
                         static_cast<_interface*>(                             \
                                        static_cast<_implClass*>(              \
                                                       (_class*) 0x1000))) -   \
-    reinterpret_cast<char*>((_class*) 0x1000)                                 \
+               reinterpret_cast<char*>((_class*) 0x1000))                     \
   },
 
 #define NS_INTERFACE_TABLE_END_WITH_PTR(_ptr)                                 \
   { nsnull, 0 } };                                                            \
   rv = NS_TableDrivenQI(static_cast<void*>(_ptr),                             \
                         table, aIID, aInstancePtr);
 
 #define NS_INTERFACE_TABLE_END                                                \
--- a/xpcom/glue/nsVoidArray.h
+++ b/xpcom/glue/nsVoidArray.h
@@ -401,17 +401,17 @@ public:
 
   PRBool EnumerateForwards(nsVoidArrayEnumFunc aFunc, void* aData);
   PRBool EnumerateBackwards(nsVoidArrayEnumFunc aFunc, void* aData);
 
 private:
 
   PRBool HasSingle() const
   {
-    return reinterpret_cast<PRWord>(mImpl) & 0x1;
+    return !!(reinterpret_cast<PRWord>(mImpl) & 0x1);
   }
   void* GetSingle() const
   {
     NS_ASSERTION(HasSingle(), "wrong type");
     return reinterpret_cast<void*>
                            (reinterpret_cast<PRWord>(mImpl) & ~0x1);
   }
   void SetSingle(void *aChild)
--- a/xpcom/string/public/nsCharTraits.h
+++ b/xpcom/string/public/nsCharTraits.h
@@ -666,17 +666,17 @@ struct nsCharSourceTraits
   {
     typedef typename InputIterator::difference_type difference_type;
 
     static
     PRUint32
     readable_distance( const InputIterator& first, const InputIterator& last )
       {
         // assumes single fragment
-        return last.get() - first.get();
+        return PRUint32(last.get() - first.get());
       }
 
     static
     const typename InputIterator::value_type*
     read( const InputIterator& iter )
       {
         return iter.get();
       }
--- a/xpcom/string/public/nsTDependentString.h
+++ b/xpcom/string/public/nsTDependentString.h
@@ -68,30 +68,30 @@ class nsTDependentString_CharT : public 
         }
 
 
         /**
          * constructors
          */
 
       nsTDependentString_CharT( const char_type* start, const char_type* end )
-        : string_type(const_cast<char_type*>(start), end - start, F_TERMINATED)
+        : string_type(const_cast<char_type*>(start), PRUint32(end - start), F_TERMINATED)
         {
           AssertValid();
         }
 
       nsTDependentString_CharT( const char_type* data, PRUint32 length )
         : string_type(const_cast<char_type*>(data), length, F_TERMINATED)
         {
           AssertValid();
         }
 
       explicit
       nsTDependentString_CharT( const char_type* data )
-        : string_type(const_cast<char_type*>(data), char_traits::length(data), F_TERMINATED)
+        : string_type(const_cast<char_type*>(data), PRUint32(char_traits::length(data)), F_TERMINATED)
         {
           AssertValid();
         }
 
       explicit
       nsTDependentString_CharT( const substring_type& str )
         : string_type(const_cast<char_type*>(str.Data()), str.Length(), F_TERMINATED)
         {
@@ -109,24 +109,24 @@ class nsTDependentString_CharT : public 
 
 
         /**
          * allow this class to be bound to a different string...
          */
 
       void Rebind( const char_type* data )
         {
-          Rebind(data, char_traits::length(data));
+          Rebind(data, PRUint32(char_traits::length(data)));
         }
 
       NS_COM void Rebind( const char_type* data, size_type length );
 
       void Rebind( const char_type* start, const char_type* end )
         {
-          Rebind(start, end - start);
+          Rebind(start, PRUint32(end - start));
         }
 
     private:
       
       // NOT USED
       nsTDependentString_CharT( const substring_tuple_type& );
 #ifdef MOZ_V1_STRING_ABI
       nsTDependentString_CharT( const abstract_string_type& );
--- a/xpcom/string/public/nsTDependentSubstring.h
+++ b/xpcom/string/public/nsTDependentSubstring.h
@@ -66,20 +66,20 @@ class nsTDependentSubstring_CharT : publ
 
       nsTDependentSubstring_CharT( const substring_type& str, PRUint32 startPos, PRUint32 length = size_type(-1) )
         : substring_type()
         {
           Rebind(str, startPos, length);
         }
 
       nsTDependentSubstring_CharT( const char_type* start, const char_type* end )
-        : substring_type(const_cast<char_type*>(start), end - start, F_NONE) {}
+        : substring_type(const_cast<char_type*>(start), PRUint32(end - start), F_NONE) {}
 
       nsTDependentSubstring_CharT( const const_iterator& start, const const_iterator& end )
-        : substring_type(const_cast<char_type*>(start.get()), end.get() - start.get(), F_NONE) {}
+        : substring_type(const_cast<char_type*>(start.get()), PRUint32(end.get() - start.get()), F_NONE) {}
 
       // Create a nsTDependentSubstring to be bound later
       nsTDependentSubstring_CharT()
         : substring_type() {}
 
       // auto-generated copy-constructor OK (XXX really?? what about base class copy-ctor?)
 
     private:
--- a/xpcom/string/public/nsTString.h
+++ b/xpcom/string/public/nsTString.h
@@ -444,17 +444,17 @@ class nsTFixedString_CharT : public nsTS
          *        this buffer may be modified by the string)
          * @param storageSize
          *        the size of the fixed buffer
          * @param length (optional)
          *        the length of the string already contained in the buffer
          */
 
       nsTFixedString_CharT( char_type* data, size_type storageSize )
-        : string_type(data, char_traits::length(data), F_TERMINATED | F_FIXED | F_CLASS_FIXED)
+        : string_type(data, PRUint32(char_traits::length(data)), F_TERMINATED | F_FIXED | F_CLASS_FIXED)
         , mFixedCapacity(storageSize - 1)
         , mFixedBuf(data)
         {}
 
       nsTFixedString_CharT( char_type* data, size_type storageSize, size_type length )
         : string_type(data, length, F_TERMINATED | F_FIXED | F_CLASS_FIXED)
         , mFixedCapacity(storageSize - 1)
         , mFixedBuf(data)