diff --git a/js/public/CallNonGenericMethod.h b/js/public/CallNonGenericMethod.h index 35805f049281..8fb357252d52 100644 --- a/js/public/CallNonGenericMethod.h +++ b/js/public/CallNonGenericMethod.h @@ -46,8 +46,9 @@ CallMethodIfWrapped(JSContext* cx, IsAcceptableThis test, NativeImpl impl, const // static bool // IsAnswerObject(const Value& v) // { -// if (!v.isObject()) +// if (!v.isObject()) { // return false; +// } // return JS_GetClass(&v.toObject()) == &AnswerClass; // } // diff --git a/js/public/Class.h b/js/public/Class.h index e6284f173b87..3d3c73b5b6c2 100644 --- a/js/public/Class.h +++ b/js/public/Class.h @@ -102,10 +102,12 @@ IsArray(JSContext* cx, HandleObject obj, IsArrayAnswer* answer); * Typical usage: * * ObjectOpResult result; - * if (!DefineProperty(cx, obj, id, ..., result)) + * if (!DefineProperty(cx, obj, id, ..., result)) { * return false; - * if (!result) + * } + * if (!result) { * return result.reportError(cx, obj, id); + * } * * Users don't have to call `result.report()`; another possible ending is: * @@ -161,8 +163,9 @@ class ObjectOpResult * * Always returns true, as a convenience. Typical usage will be: * - * if (funny condition) + * if (funny condition) { * return result.fail(JSMSG_CANT_DO_THE_THINGS); + * } * * The true return value indicates that no exception is pending, and it * would be OK to ignore the failure and continue. diff --git a/js/public/Debug.h b/js/public/Debug.h index 0c8a47133c8c..33e28bfeac13 100644 --- a/js/public/Debug.h +++ b/js/public/Debug.h @@ -97,8 +97,9 @@ namespace dbg { // Builder::Object& result) // { // JSObject* eventObject = ... obtain debuggee event object somehow ...; -// if (!eventObject) +// if (!eventObject) { // return false; +// } // result = builder.newObject(cx); // return result && // result.defineProperty(cx, "eventType", SafelyFetchType(eventObject)) && diff --git a/js/public/UbiNode.h b/js/public/UbiNode.h index 72cab375dedc..41f83a21d221 100644 --- a/js/public/UbiNode.h +++ b/js/public/UbiNode.h @@ -975,8 +975,9 @@ class PreComputedEdgeRange : public EdgeRange { // { // mozilla::Maybe maybeNoGC; // JS::ubi::RootList rootList(cx, maybeNoGC); -// if (!rootList.init()) +// if (!rootList.init()) { // return false; +// } // // // The AutoCheckCannotGC is guaranteed to exist if init returned true. // MOZ_ASSERT(maybeNoGC.isSome()); diff --git a/js/src/builtin/intl/CommonFunctions.h b/js/src/builtin/intl/CommonFunctions.h index ff29c47f3b6c..676bab070739 100644 --- a/js/src/builtin/intl/CommonFunctions.h +++ b/js/src/builtin/intl/CommonFunctions.h @@ -137,8 +137,9 @@ using GetAvailable = const char* (*)(int32_t localeIndex); * returns the corresponding locale as a borrowed string. For example: * * RootedValue v(cx); - * if (!GetAvailableLocales(cx, unum_countAvailable, unum_getAvailable, &v)) + * if (!GetAvailableLocales(cx, unum_countAvailable, unum_getAvailable, &v)) { * return false; + * } */ extern bool GetAvailableLocales(JSContext* cx, CountAvailable countAvailable, GetAvailable getAvailable, diff --git a/js/src/frontend/FoldConstants.h b/js/src/frontend/FoldConstants.h index 30501104f443..89a3ca96c624 100644 --- a/js/src/frontend/FoldConstants.h +++ b/js/src/frontend/FoldConstants.h @@ -24,10 +24,12 @@ template class PerHandlerParser; // // Usage: // pn = parser->statement(); -// if (!pn) +// if (!pn) { // return false; -// if (!FoldConstants(cx, &pn, parser)) +// } +// if (!FoldConstants(cx, &pn, parser)) { // return false; +// } extern MOZ_MUST_USE bool FoldConstants(JSContext* cx, ParseNode** pnp, PerHandlerParser* parser); diff --git a/js/src/frontend/JumpList.h b/js/src/frontend/JumpList.h index 9f83bf5375f2..ab3bd39c95d4 100644 --- a/js/src/frontend/JumpList.h +++ b/js/src/frontend/JumpList.h @@ -21,15 +21,18 @@ namespace frontend { // Example: // // JumpList brList; -// if (!emitJump(JSOP_IFEQ, &brList)) +// if (!emitJump(JSOP_IFEQ, &brList)) { // return false; +// } // ... // JumpTarget label; -// if (!emitJumpTarget(&label)) +// if (!emitJumpTarget(&label)) { // return false; +// } // ... -// if (!emitJump(JSOP_GOTO, &brList)) +// if (!emitJump(JSOP_GOTO, &brList)) { // return false; +// } // ... // patchJumpsToTarget(brList, label); // diff --git a/js/src/frontend/Parser.h b/js/src/frontend/Parser.h index bac609961fdf..b3bde51e65ec 100644 --- a/js/src/frontend/Parser.h +++ b/js/src/frontend/Parser.h @@ -805,19 +805,22 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_TYPE) * PossibleError possibleError(*this); * possibleError.setPendingExpressionErrorAt(pos, JSMSG_BAD_PROP_ID); * // A JSMSG_BAD_PROP_ID ParseError is reported, returns false. - * if (!possibleError.checkForExpressionError()) + * if (!possibleError.checkForExpressionError()) { * return false; // we reach this point with a pending exception + * } * * PossibleError possibleError(*this); * possibleError.setPendingExpressionErrorAt(pos, JSMSG_BAD_PROP_ID); * // Returns true, no error is reported. - * if (!possibleError.checkForDestructuringError()) + * if (!possibleError.checkForDestructuringError()) { * return false; // not reached, no pending exception + * } * * PossibleError possibleError(*this); * // Returns true, no error is reported. - * if (!possibleError.checkForExpressionError()) + * if (!possibleError.checkForExpressionError()) { * return false; // not reached, no pending exception + * } */ class MOZ_STACK_CLASS PossibleError { diff --git a/js/src/gc/GC-inl.h b/js/src/gc/GC-inl.h index 32e7d87f2f2e..da81b0b20e20 100644 --- a/js/src/gc/GC-inl.h +++ b/js/src/gc/GC-inl.h @@ -289,11 +289,13 @@ class ZoneCellIter { // Iterator over the cells in a Zone, where the GC type (JSString, JSObject) is // known, for a single AllocKind. Example usages: // -// for (auto obj = zone->cellIter(AllocKind::OBJECT0); !obj.done(); obj.next()) +// for (auto obj = zone->cellIter(AllocKind::OBJECT0); !obj.done(); obj.next()) { // ... +// } // -// for (auto script = zone->cellIter(); !script.done(); script.next()) +// for (auto script = zone->cellIter(); !script.done(); script.next()) { // f(script->code()); +// } // // As this code demonstrates, you can use 'script' as if it were a JSScript*. // Its actual type is ZoneCellIter, but for most purposes it will diff --git a/js/src/jit/BaselineDebugModeOSR.h b/js/src/jit/BaselineDebugModeOSR.h index 0feb2df5d96e..3fc9f1530173 100644 --- a/js/src/jit/BaselineDebugModeOSR.h +++ b/js/src/jit/BaselineDebugModeOSR.h @@ -33,8 +33,9 @@ namespace jit { // // Call out to the VM // // Other effectful operations like TypeScript::Monitor // -// if (stub.invalid()) +// if (stub.invalid()) { // return true; +// } // // // First use of stub after VM call. // diff --git a/js/src/jit/MacroAssembler.cpp b/js/src/jit/MacroAssembler.cpp index 69034e0b4300..29a793ea32ee 100644 --- a/js/src/jit/MacroAssembler.cpp +++ b/js/src/jit/MacroAssembler.cpp @@ -2827,8 +2827,9 @@ MacroAssembler::alignJitStackBasedOnNArgs(Register nargs) // aligned if |nargs| is odd. // if (nargs % 2 == 0) { - // if (sp % JitStackAlignment == 0) + // if (sp % JitStackAlignment == 0) { // sp -= sizeof(Value); + // } // MOZ_ASSERT(sp % JitStackAlignment == JitStackAlignment - sizeof(Value)); // } else { // sp = sp & ~(JitStackAlignment - 1); diff --git a/js/src/jit/OptimizationTracking.cpp b/js/src/jit/OptimizationTracking.cpp index d9d90e7ded4f..345c3632f2a2 100644 --- a/js/src/jit/OptimizationTracking.cpp +++ b/js/src/jit/OptimizationTracking.cpp @@ -1271,8 +1271,9 @@ IonTrackedOptimizationsTypeInfo::ForEachOpAdapter::readType(const IonTrackedType // void* addr = JS_FUNC_TO_DATA_PTR(void*, fun->native()); // uintptr_t offset; // Dl_info info; - // if (dladdr(addr, &info) != 0) + // if (dladdr(addr, &info) != 0) { // offset = uintptr_t(addr) - uintptr_t(info.dli_fbase); + // } // char locationBuf[20]; if (!name) { diff --git a/js/src/jsapi.h b/js/src/jsapi.h index 96835b5c0fbf..99f0051ce05d 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -2526,8 +2526,9 @@ JS_DeleteElement(JSContext* cx, JS::HandleObject obj, uint32_t index); * This function is roughly equivalent to: * * var result = []; - * for (key in obj) + * for (key in obj) { * result.push(key); + * } * return result; * * This is the closest thing we currently have to the ES6 [[Enumerate]] @@ -3776,8 +3777,9 @@ JS_PutEscapedString(JSContext* cx, char* buffer, size_t size, JSString* str, cha * * // in a fallible context * JSFlatString* fstr = JS_FlattenString(cx, str); - * if (!fstr) + * if (!fstr) { * return false; + * } * MOZ_ASSERT(fstr == JS_ASSERT_STRING_IS_FLAT(str)); * * // in an infallible context, for the same 'str' @@ -4787,17 +4789,21 @@ DeserializeWasmModule(PRFileDesc* bytecode, JS::UniqueChars filename, unsigned l * Convenience class for imitating a JS level for-of loop. Typical usage: * * ForOfIterator it(cx); - * if (!it.init(iterable)) + * if (!it.init(iterable)) { * return false; + * } * RootedValue val(cx); * while (true) { * bool done; - * if (!it.next(&val, &done)) + * if (!it.next(&val, &done)) { * return false; - * if (done) + * } + * if (done) { * break; - * if (!DoStuff(cx, val)) + * } + * if (!DoStuff(cx, val)) { * return false; + * } * } */ class MOZ_STACK_CLASS JS_PUBLIC_API(ForOfIterator) {