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

RESOLVED FIXED in mozilla26

Status

()

Core
XUL
RESOLVED FIXED
4 years ago
4 years ago

People

(Reporter: mrbkap, Assigned: mrbkap)

Tracking

17 Branch
mozilla26
x86
Mac OS X
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Assignee)

Description

4 years ago
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.
(Assignee)

Comment 1

4 years ago
Created attachment 798861 [details] [diff] [review]
patch v1

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+
(Assignee)

Comment 3

4 years ago
https://hg.mozilla.org/integration/mozilla-inbound/rev/a484e79df631
https://hg.mozilla.org/mozilla-central/rev/a484e79df631
Status: NEW → RESOLVED
Last Resolved: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla26
You need to log in before you can comment on or make changes to this bug.