Bug 1119228 - Fix a fatal warning in PossiblyFail; r=jandem
authorEhsan Akhgari <ehsan@mozilla.com>
Thu, 08 Jan 2015 09:25:18 -0500
changeset 248612 bcacb5692ad902fc0ec6ebea2ad382a8a3fd5183
parent 248611 48f8a884901ba9753d3bddab08f25c60e1915601
child 248613 b2cf412dad7a0c7f9d1df7b612a5c10b3529e3d9
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1119228
milestone37.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 1119228 - Fix a fatal warning in PossiblyFail; r=jandem Recent clang emits the following warning (which is treated as an error) on this code: error: implicit conversion of nullptr constant to 'bool' [-Werror,-Wnull-conversion]
js/public/Utility.h
js/src/jsgcinlines.h
--- a/js/public/Utility.h
+++ b/js/public/Utility.h
@@ -83,19 +83,28 @@ static MOZ_NEVER_INLINE void js_failedAl
 #  define JS_OOM_POSSIBLY_FAIL() \
     do \
     { \
         if (++OOM_counter > OOM_maxAllocations) { \
             JS_OOM_CALL_BP_FUNC();\
             return nullptr; \
         } \
     } while (0)
+#  define JS_OOM_POSSIBLY_FAIL_BOOL() \
+    do \
+    { \
+        if (++OOM_counter > OOM_maxAllocations) { \
+            JS_OOM_CALL_BP_FUNC();\
+            return false; \
+        } \
+    } while (0)
 
 # else
 #  define JS_OOM_POSSIBLY_FAIL() do {} while(0)
+#  define JS_OOM_POSSIBLY_FAIL_BOOL() do {} while(0)
 # endif /* DEBUG || JS_OOM_BREAKPOINT */
 
 static inline void* js_malloc(size_t bytes)
 {
     JS_OOM_POSSIBLY_FAIL();
     return malloc(bytes);
 }
 
--- a/js/src/jsgcinlines.h
+++ b/js/src/jsgcinlines.h
@@ -439,17 +439,17 @@ TryNewNurseryObject(JSContext *cx, size_
         }
     }
     return nullptr;
 }
 
 static inline bool
 PossiblyFail()
 {
-    JS_OOM_POSSIBLY_FAIL();
+    JS_OOM_POSSIBLY_FAIL_BOOL();
     return true;
 }
 
 template <AllowGC allowGC>
 static inline bool
 CheckAllocatorState(ThreadSafeContext *cx, AllocKind kind)
 {
     if (!cx->isJSContext())