Bug 458722 - gcc warning mainly 64 bit: src/xpcconvert.cpp:1931: warning: comparison is always false due to limited range of data type; r=bz
authorAtul Aggarwal <atulagrwl@gmail.com>
Mon, 05 Sep 2011 10:29:06 +0100
changeset 76552 1a9a2270cc4743e015d33ea0270aecc19a12897b
parent 76551 b435b37b32c76764fe43a3090d6c2b087be35fd6
child 76553 89d9b45ef2416ff45b8b4a1cc207db3609eec0ce
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewersbz
bugs458722
milestone9.0a1
Bug 458722 - gcc warning mainly 64 bit: src/xpcconvert.cpp:1931: warning: comparison is always false due to limited range of data type; r=bz
js/src/xpconnect/src/xpcconvert.cpp
--- a/js/src/xpconnect/src/xpcconvert.cpp
+++ b/js/src/xpconnect/src/xpcconvert.cpp
@@ -2114,17 +2114,18 @@ XPCConvert::JSArray2Native(XPCCallContex
     }
 
     if(pErr)
         *pErr = NS_ERROR_XPC_BAD_CONVERT_JS;
 
 #define POPULATE(_mode, _t)                                                  \
     PR_BEGIN_MACRO                                                           \
         cleanupMode = _mode;                                                 \
-        if (capacity > PR_UINT32_MAX / sizeof(_t) ||                         \
+        size_t max = PR_UINT32_MAX / sizeof(_t);                             \
+        if (capacity > max ||                                                \
             nsnull == (array = nsMemory::Alloc(capacity * sizeof(_t))))      \
         {                                                                    \
             if(pErr)                                                         \
                 *pErr = NS_ERROR_OUT_OF_MEMORY;                              \
             goto failure;                                                    \
         }                                                                    \
         for(initedCount = 0; initedCount < count; initedCount++)             \
         {                                                                    \