# Backport of # HG changeset patch # User Ehsan Akhgari # Date 1420727118 18000 # Node ID bcacb5692ad902fc0ec6ebea2ad382a8a3fd5183 # Parent 48f8a884901ba9753d3bddab08f25c60e1915601 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] diff --git a/js/public/Utility.h b/js/public/Utility.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 @@ -403,17 +403,17 @@ } return nullptr; } #endif /* JSGC_GENERATIONAL */ static inline bool PossiblyFail() { - JS_OOM_POSSIBLY_FAIL(); + JS_OOM_POSSIBLY_FAIL_BOOL(); return true; } template static inline bool CheckAllocatorState(ThreadSafeContext *cx, AllocKind kind) { if (!cx->isJSContext())