Bug 1175513 - Improve code style in nsXPCWrappedJSClass::CleanupOutparams; r=bholley
authorMs2ger <ms2ger@gmail.com>
Sat, 20 Jun 2015 09:16:51 +0200
changeset 280651 a560e8f9999136d20f2b3d6e270fb2e82a1c41d3
parent 280650 45e57f3e386b96cd3119058f169261198c2b00fd
child 280652 5081a6d1bd3845030b8328c7beda877d9a1bacf1
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-beta@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs1175513
milestone41.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1175513 - Improve code style in nsXPCWrappedJSClass::CleanupOutparams; r=bholley
js/xpconnect/src/XPCWrappedJSClass.cpp
--- a/js/xpconnect/src/XPCWrappedJSClass.cpp
+++ b/js/xpconnect/src/XPCWrappedJSClass.cpp
@@ -719,28 +719,27 @@ nsXPCWrappedJSClass::CleanupOutparams(JS
     for (uint8_t i = 0; i < n; i++) {
         const nsXPTParamInfo& param = info->params[i];
         if (!param.IsOut())
             continue;
 
         const nsXPTType& type = param.GetType();
         if (!type.deprecated_IsPointer())
             continue;
-        void* p;
-        if (!(p = nativeParams[i].val.p))
+        void* p = nativeParams[i].val.p;
+        if (!p)
             continue;
 
         // The inOutOnly flag was introduced when consolidating two very
         // similar code paths in CallMethod in bug 1175513. I don't know
         // if and why the difference is necessary.
         if (!inOutOnly || param.IsIn()) {
             if (type.IsArray()) {
-                void** pp;
-                if (nullptr != (pp = *((void***)p))) {
-
+                void** pp = *static_cast<void***>(p);
+                if (pp) {
                     // we need to get the array length and iterate the items
                     uint32_t array_count;
                     nsXPTType datum_type;
 
                     if (NS_SUCCEEDED(mInfo->GetTypeForParam(methodIndex, &param,
                                                             1, &datum_type)) &&
                         datum_type.deprecated_IsPointer() &&
                         GetArraySizeFromParam(cx, info, param, methodIndex,
@@ -748,20 +747,21 @@ nsXPCWrappedJSClass::CleanupOutparams(JS
                         array_count) {
 
                         CleanupPointerArray(datum_type, array_count, pp);
                     }
 
                     // always release the array if it is inout
                     free(pp);
                 }
-            } else
-                CleanupPointerTypeObject(type, (void**)p);
+            } else {
+                CleanupPointerTypeObject(type, static_cast<void**>(p));
+            }
         }
-        *((void**)p) = nullptr;
+        *static_cast<void**>(p) = nullptr;
     }
 }
 
 nsresult
 nsXPCWrappedJSClass::CheckForException(XPCCallContext & ccx,
                                        const char * aPropertyName,
                                        const char * anInterfaceName,
                                        bool aForceReport)