Closed Bug 469072 Opened 16 years ago Closed 16 years ago

outparam analysis confused by nsCOMPtr<>.forget(T**)

Categories

(Developer Infrastructure :: Source Code Analysis, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: bent.mozilla, Assigned: benjamin)

Details

Attachments

(1 file, 1 obsolete file)

Just looked through the warning database on the static analysis tinderbox and was surprised to see my name in there so many times! I see lots of lines like this:

/builds/static-analysis-buildbot/slave/full/build/dom/src/threads/nsDOMWorker.cpp:921: warning: outparam 'aNewObject' not written on NS_SUCCEEDED(return value)
/builds/static-analysis-buildbot/slave/full/build/dom/src/threads/nsDOMWorker.cpp:912:48:   outparam declared here

WARN-DB: (3373, 0, 'dom/src/threads/nsDOMWorker.cpp', 921, "outparam 'aNewObject' not written on NS_SUCCEEDED(return value)", 'hg', 'Ben Turner <bent.mozilla@gmail.com>', 'dom/src/threads/nsDOMWorker.cpp', 'b83d3c8ac166e5f92f36fa44df498e74efd41832', 761)

First, nsDOMWorker.cpp doesn't have 'aNewObject' anywhere line 921 (it's actually on line 802), so the numbers are off for some reason. But moving on, I can't actually see anything wrong with the function as nsCOMPtr<>.forget(T**) always sets the pointer value.
There's nothing *wrong* with the .forget function: it's just not annotated with NS_OUTPARAM, so the analysis doesn't know its semantics. The analysis is not cross-function, so it can't know the behavior of .forget() unless you tell it.
Assignee: nobody → benjamin
Status: NEW → ASSIGNED
Attachment #352554 - Flags: review?(bent.mozilla)
Argh, I didn't mean to include the nsExceptionService change in here.
Attachment #352554 - Attachment is obsolete: true
Attachment #352556 - Flags: review?(bent.mozilla)
Attachment #352554 - Flags: review?(bent.mozilla)
Attachment #352556 - Flags: review?(bent.mozilla) → review+
Comment on attachment 352556 [details] [diff] [review]
Annotate various XPCOM functions, rev. 1.1

This looks great.
Pushed: http://hg.mozilla.org/mozilla-central/rev/dabc6a7b1d50
Status: ASSIGNED → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
Product: Core → Firefox Build System
Product: Firefox Build System → Developer Infrastructure
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: