Closed Bug 560126 Opened 14 years ago Closed 14 years ago

funobj is uselessly set in WrapFunction

Categories

(Core :: XPConnect, defect)

defect
Not set
minor

Tracking

()

RESOLVED FIXED
mozilla1.9.3a5
Tracking Status
blocking2.0 --- final+

People

(Reporter: timeless, Assigned: timeless)

References

(Blocks 1 open bug, )

Details

(Keywords: coverity)

Attachments

(1 file)

412 WrapFunction(JSContext *cx, JSObject *scope, JSObject *funobj, jsval *rval)

419   if (native == XPC_COW_FunctionWrapper) {

426     funobj = JSVAL_TO_OBJECT(funobjVal);
427   }
428 
429   JSFunction *funWrapper =
430     JS_NewFunction(cx, XPC_COW_FunctionWrapper,
431                    JS_GetFunctionArity(wrappedFun), 0,
432                    scope,
433                    JS_GetFunctionName(wrappedFun));
434   if (!funWrapper) {
435     return JS_FALSE;
436   }
437 
438   JSObject *funWrapperObj = JS_GetFunctionObject(funWrapper);
439   *rval = OBJECT_TO_JSVAL(funWrapperObj);
440 
441   return JS_SetReservedSlot(cx, funWrapperObj,
442                             XPCWrapper::eWrappedFunctionSlot,
443                             funobjVal);
444 }
Should we be using that (but fail to) or is this just a set that shouldn't be there?

Requesting blocking in case it's the former...
blocking2.0: --- → ?
Attached patch proposalSplinter Review
so, jsvals are aliases to jsobjects. i'm hoping it's just someone trying to keep the function argument in sync with the local jsobject. I'd rather we have a DO_NOT_USE(function_argument) statement at the point where it's stale and rely on static analysis to complain if it's used. The current approach risks compilers not optimizing away the useless bookkeeping we have. -- Assuming I'm right that it's useless (instead of errantly unused).
Assignee: nobody → timeless
Status: NEW → ASSIGNED
Attachment #439863 - Flags: review?(mrbkap)
Comment on attachment 439863 [details] [diff] [review]
proposal

I think that I might have wanted to re-load wrappedFun out of funobj (as well as just keep it updated), but since we only use wrappedFun for its name and arity, this is fine.
Attachment #439863 - Flags: review?(mrbkap) → review+
http://hg.mozilla.org/mozilla-central/rev/996419229468
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Flags: in-testsuite-
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9.3a5
blocking2.0: ? → final+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: