From fdaa6f1aaa6b85a93fec32bde44a020b6bda7d94 Mon Sep 17 00:00:00 2001 From: Tom Schuster Date: Mon, 19 Dec 2011 14:16:53 +0100 Subject: [PATCH] Bug 708695 - Fix issues found by clang's scan-build. r=Waldo --HG-- extra : rebase_source : 5b1970539b2f5b211ebeb97765d8c549371cb888 --- js/src/frontend/TokenStream.cpp | 1 - js/src/jsinfer.cpp | 20 +++++++++++--------- js/src/jsinterp.cpp | 4 +--- js/src/jsobj.cpp | 3 +-- js/src/json.cpp | 1 - js/src/jsopcode.cpp | 6 ++---- js/src/jsxml.cpp | 21 +++++++-------------- js/src/methodjit/FrameState.cpp | 4 +--- 8 files changed, 23 insertions(+), 37 deletions(-) diff --git a/js/src/frontend/TokenStream.cpp b/js/src/frontend/TokenStream.cpp index 227c0002833f..34f5facb23ac 100644 --- a/js/src/frontend/TokenStream.cpp +++ b/js/src/frontend/TokenStream.cpp @@ -1841,7 +1841,6 @@ TokenStream::getTokenInternal() case '\\': hadUnicodeEscape = matchUnicodeEscapeIdStart(&qc); if (hadUnicodeEscape) { - c = qc; identStart = userbuf.addressOfNextRawChar() - 6; goto identifier; } diff --git a/js/src/jsinfer.cpp b/js/src/jsinfer.cpp index 60577549f7eb..979836b4b508 100644 --- a/js/src/jsinfer.cpp +++ b/js/src/jsinfer.cpp @@ -4174,15 +4174,17 @@ ScriptAnalysis::analyzeTypes(JSContext *cx) detached = true; } - /* - * Don't track for parents which add call objects or are generators, - * don't resolve NAME accesses into the parent. - */ - if (!detached && - (nesting->parent->analysis()->addsScopeObjects() || - JSOp(*nesting->parent->code) == JSOP_GENERATOR)) { - DetachNestingParent(script); - detached = true; + + if (!detached) { + /* + * Don't track for parents which add call objects or are generators, + * don't resolve NAME accesses into the parent. + */ + if (nesting->parent->analysis()->addsScopeObjects() || + JSOp(*nesting->parent->code) == JSOP_GENERATOR) + { + DetachNestingParent(script); + } } } diff --git a/js/src/jsinterp.cpp b/js/src/jsinterp.cpp index b5e00496e637..09f18ad92143 100644 --- a/js/src/jsinterp.cpp +++ b/js/src/jsinterp.cpp @@ -2105,14 +2105,12 @@ BEGIN_CASE(JSOP_STOP) if (JS_LIKELY(interpReturnOK)) { TypeScript::Monitor(cx, script, regs.pc, regs.sp[-1]); - op = JSOp(*regs.pc); - len = JSOP_CALL_LENGTH; - if (shiftResult) { regs.sp[-2] = regs.sp[-1]; regs.sp--; } + len = JSOP_CALL_LENGTH; DO_NEXT_OP(len); } diff --git a/js/src/jsobj.cpp b/js/src/jsobj.cpp index 8b912e7dd6c6..945e6b7f16ef 100644 --- a/js/src/jsobj.cpp +++ b/js/src/jsobj.cpp @@ -3197,7 +3197,7 @@ Detecting(JSContext *cx, jsbytecode *pc) */ if (++pc < endpc) { op = JSOp(*pc); - return *pc == JSOP_EQ || *pc == JSOP_NE; + return op == JSOP_EQ || op == JSOP_NE; } return JS_FALSE; @@ -7406,7 +7406,6 @@ js_DumpStackFrame(JSContext *cx, StackFrame *start) fprintf(stderr, "no stack for cx = %p\n", (void*) cx); return; } - start = i.fp(); } else { while (!i.done() && i.fp() != start) ++i; diff --git a/js/src/json.cpp b/js/src/json.cpp index 88333adf1a39..7d38f9956f44 100644 --- a/js/src/json.cpp +++ b/js/src/json.cpp @@ -193,7 +193,6 @@ Quote(JSContext *cx, StringBuffer &sb, JSString *str) : 't'; if (!sb.append('\\') || !sb.append(abbrev)) return false; - mark = i + 1; } else { JS_ASSERT(c < ' '); if (!sb.append("\\u00")) diff --git a/js/src/jsopcode.cpp b/js/src/jsopcode.cpp index 36b4ca33f81f..24807e6acb2d 100644 --- a/js/src/jsopcode.cpp +++ b/js/src/jsopcode.cpp @@ -2560,10 +2560,10 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb) */ op = (JSOp) pc[oplen]; rval = PopStr(ss, op, &lastrvalpc); - lval = PopStr(ss, op, &lastlvalpc); + (void)PopStr(ss, op, &lastlvalpc); + /* Print only the right operand of the assignment-op. */ todo = SprintCString(&ss->sprinter, rval); - op = saveop; } else if (!inXML) { rval = PopStrPrecDupe(ss, cs->prec + !!(cs->format & JOF_LEFTASSOC), &rvalpc); lval = PopStrPrec(ss, cs->prec + !(cs->format & JOF_LEFTASSOC), &lvalpc); @@ -4211,10 +4211,8 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb) } case JSOP_GETELEM2: - op = JSOP_GETELEM; (void) PopOff(ss, lastop); /* FALL THROUGH */ - case JSOP_CALLELEM: case JSOP_GETELEM: op = JSOP_NOP; /* turn off parens */ diff --git a/js/src/jsxml.cpp b/js/src/jsxml.cpp index 6c2e15fec2e2..75b0605e90e2 100644 --- a/js/src/jsxml.cpp +++ b/js/src/jsxml.cpp @@ -3047,22 +3047,17 @@ AddInScopeNamespace(JSContext *cx, JSXML *xml, JSObject *ns) static JSBool Append(JSContext *cx, JSXML *list, JSXML *xml) { - uint32_t i, j, k, n; - JSXML *kid; - JS_ASSERT(list->xml_class == JSXML_CLASS_LIST); - i = list->xml_kids.length; - n = 1; + + uint32_t i = list->xml_kids.length; if (xml->xml_class == JSXML_CLASS_LIST) { list->xml_target = xml->xml_target; list->xml_targetprop = xml->xml_targetprop; - n = JSXML_LENGTH(xml); - k = i + n; - if (!list->xml_kids.setCapacity(cx, k)) + uint32_t n = JSXML_LENGTH(xml); + if (!list->xml_kids.setCapacity(cx, i + n)) return JS_FALSE; - for (j = 0; j < n; j++) { - kid = XMLARRAY_MEMBER(&xml->xml_kids, j, JSXML); - if (kid) + for (uint32_t j = 0; j < n; j++) { + if (JSXML *kid = XMLARRAY_MEMBER(&xml->xml_kids, j, JSXML)) XMLARRAY_SET_MEMBER(&list->xml_kids, i + j, kid); } return JS_TRUE; @@ -6921,7 +6916,6 @@ xml_text_helper(JSContext *cx, JSObject *obj, JSXML *xml, jsval *vp) { JSXML *list, *kid, *vxml; uint32_t i, n; - JSBool ok; JSObject *kidobj; jsval v; @@ -6930,11 +6924,10 @@ xml_text_helper(JSContext *cx, JSObject *obj, JSXML *xml, jsval *vp) return JS_FALSE; if (xml->xml_class == JSXML_CLASS_LIST) { - ok = JS_TRUE; for (i = 0, n = xml->xml_kids.length; i < n; i++) { kid = XMLARRAY_MEMBER(&xml->xml_kids, i, JSXML); if (kid && kid->xml_class == JSXML_CLASS_ELEMENT) { - ok = js_EnterLocalRootScope(cx); + JSBool ok = js_EnterLocalRootScope(cx); if (!ok) break; kidobj = js_GetXMLObject(cx, kid); diff --git a/js/src/methodjit/FrameState.cpp b/js/src/methodjit/FrameState.cpp index 547a774b9fc1..f50ba692ff87 100644 --- a/js/src/methodjit/FrameState.cpp +++ b/js/src/methodjit/FrameState.cpp @@ -1339,15 +1339,13 @@ FrameState::sync(Assembler &masm, Uses uses) const continue; } - FrameEntry *backing = fe; - if (!fe->isCopy()) { if (fe->data.inRegister() && !regstate(fe->data.reg()).isPinned()) avail.putReg(fe->data.reg()); if (fe->type.inRegister() && !regstate(fe->type.reg()).isPinned()) avail.putReg(fe->type.reg()); } else { - backing = fe->copyOf(); + FrameEntry *backing = fe->copyOf(); JS_ASSERT(!backing->isConstant() && !fe->isConstant()); #if defined JS_PUNBOX64