Closed Bug 912044 Opened 11 years ago Closed 11 years ago

mozilla/content/xul/document/src/XULDocument.cpp:3505:9: warning: variable 'rv' is used uninitialized whenever 'if' condition is false

Categories

(Core :: XUL, defect)

17 Branch
x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla26

People

(Reporter: mrbkap, Assigned: mrbkap)

References

Details

Attachments

(1 file)

Compiling content/xul/document/src gives me the output:

 0:39.58 Warning: -Wsometimes-uninitialized in /Users/mrbkap/work/git-mozilla/mozilla/content/xul/document/src/XULDocument.cpp: variable 'rv' is used uninitialized whenever 'if' condition is false
 0:39.58 /Users/mrbkap/work/git-mozilla/mozilla/content/xul/document/src/XULDocument.cpp:3505:9: warning: variable 'rv' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
 0:39.58     if (NS_SUCCEEDED(aStatus)) {
 0:39.58         ^~~~~~~~~~~~~~~~~~~~~
 0:39.58 ../../../../dist/include/nsError.h:183:33: note: expanded from macro 'NS_SUCCEEDED'
 0:39.58 #define NS_SUCCEEDED(_nsresult) ((bool)MOZ_LIKELY(!NS_FAILED_impl(_nsresult)))
 0:39.58                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 0:39.58 /Users/mrbkap/work/git-mozilla/mozilla/content/xul/document/src/XULDocument.cpp:3540:76: note: uninitialized use occurs here
 0:39.58     return OnScriptCompileComplete(mCurrentScriptProto->GetScriptObject(), rv);
 0:39.58                                                                            ^~
 0:39.58 /Users/mrbkap/work/git-mozilla/mozilla/content/xul/document/src/XULDocument.cpp:3505:5: note: remove the 'if' if its condition is always true
 0:39.58     if (NS_SUCCEEDED(aStatus)) {
 0:39.58     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
 0:39.58 /Users/mrbkap/work/git-mozilla/mozilla/content/xul/document/src/XULDocument.cpp:3496:5: note: variable 'rv' is declared here
 0:39.58     nsresult rv;
 0:39.58     ^

and indeed, the compiler is right. This appears to be fallout from bug 897655.
Attached patch patch v1Splinter Review
This seems to be what was intended here. If aStatus was a failure status, then we shouldn't execute the script and simply continue resuming walk.

I'm not sure if it's possible to test this.
Attachment #798861 - Flags: review?(bzbarsky)
Comment on attachment 798861 [details] [diff] [review]
patch v1

r=me
Attachment #798861 - Flags: review?(bzbarsky) → review+
https://hg.mozilla.org/mozilla-central/rev/a484e79df631
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla26
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: