Bug 1319831 - Clarify some code with explicit casts; r=Waldo
authorMs2ger <Ms2ger@gmail.com>
Thu, 01 Dec 2016 09:23:21 +0100
changeset 324977 77ce40d94cfabce30efafe88835cb7bbe485ba19
parent 324976 296b9cc46b97eaa009a978c32f5a2c6486032677
child 324978 bb0dcd3dc89305e32a5f3e80c4149f862a7ed282
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersWaldo
bugs1319831
milestone53.0a1
Bug 1319831 - Clarify some code with explicit casts; r=Waldo
js/public/Id.h
js/public/Value.h
security/certverifier/CertVerifier.h
--- a/js/public/Id.h
+++ b/js/public/Id.h
@@ -73,34 +73,36 @@ JSID_IS_INT(jsid id)
 {
     return !!(JSID_BITS(id) & JSID_TYPE_INT);
 }
 
 static MOZ_ALWAYS_INLINE int32_t
 JSID_TO_INT(jsid id)
 {
     MOZ_ASSERT(JSID_IS_INT(id));
-    return ((uint32_t)JSID_BITS(id)) >> 1;
+    uint32_t bits = static_cast<uint32_t>(JSID_BITS(id)) >> 1;
+    return static_cast<int32_t>(bits);
 }
 
 #define JSID_INT_MIN  0
 #define JSID_INT_MAX  INT32_MAX
 
 static MOZ_ALWAYS_INLINE bool
 INT_FITS_IN_JSID(int32_t i)
 {
     return i >= 0;
 }
 
 static MOZ_ALWAYS_INLINE jsid
 INT_TO_JSID(int32_t i)
 {
     jsid id;
     MOZ_ASSERT(INT_FITS_IN_JSID(i));
-    JSID_BITS(id) = ((i << 1) | JSID_TYPE_INT);
+    uint32_t bits = (static_cast<uint32_t>(i) << 1) | JSID_TYPE_INT;
+    JSID_BITS(id) = static_cast<size_t>(bits);
     return id;
 }
 
 static MOZ_ALWAYS_INLINE bool
 JSID_IS_SYMBOL(jsid id)
 {
     return (JSID_BITS(id) & JSID_TYPE_MASK) == JSID_TYPE_SYMBOL &&
            JSID_BITS(id) != JSID_TYPE_SYMBOL;
--- a/js/public/Value.h
+++ b/js/public/Value.h
@@ -440,17 +440,17 @@ class MOZ_NON_PARAM alignas(8) Value
         return JSValueTag(data.asBits >> JSVAL_TAG_SHIFT);
 #endif
     }
 
   public:
     /*** JIT-only interfaces to interact with and create raw Values ***/
 #if defined(JS_NUNBOX32)
     PayloadType toNunboxPayload() const {
-        return data.s.payload.i32;
+        return static_cast<PayloadType>(data.s.payload.i32);
     }
 
     JSValueTag toNunboxTag() const {
         return data.s.tag;
     }
 #elif defined(JS_PUNBOX64)
     const void* bitsAsPunboxPointer() const {
         return reinterpret_cast<void*>(data.asBits);
--- a/security/certverifier/CertVerifier.h
+++ b/security/certverifier/CertVerifier.h
@@ -15,19 +15,16 @@
 #include "mozilla/UniquePtr.h"
 #include "pkix/pkixtypes.h"
 
 #if defined(_MSC_VER)
 #pragma warning(push)
 // Silence "RootingAPI.h(718): warning C4324: 'js::DispatchWrapper<T>':
 // structure was padded due to alignment specifier with [ T=void * ]"
 #pragma warning(disable:4324)
-// Silence "Value.h(448): warning C4365: 'return': conversion from 'const
-// int32_t' to 'JS::Value::PayloadType', signed/unsigned mismatch"
-#pragma warning(disable:4365)
 #endif /* defined(_MSC_VER) */
 #include "mozilla/BasePrincipal.h"
 #if defined(_MSC_VER)
 #pragma warning(pop) /* popping the pragma in this file */
 #endif /* defined(_MSC_VER) */
 
 namespace mozilla { namespace ct {