Closed
Bug 846552
Opened 13 years ago
Closed 13 years ago
Fix "variable is used uninitialized whenever switch default is taken" warnings in nsRuleNode.cpp
Categories
(Core :: CSS Parsing and Computation, defect)
Tracking
()
RESOLVED
DUPLICATE
of bug 918176
People
(Reporter: jwatt, Unassigned)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
|
1.41 KB,
patch
|
dholbert
:
review-
|
Details | Diff | Splinter Review |
There's a "variable is used uninitialized whenever switch default is taken" warnings in nsRuleNode.cpp that we should fix.
| Reporter | ||
Comment 1•13 years ago
|
||
Attachment #719730 -
Flags: review?(dholbert)
Comment 2•13 years ago
|
||
Hmm. So if this were an enum, we could just drop the "default" case entirely, and the compiler would take care of warning us if we add a new enum type later on without adding it to this switch statement.
I'm wary about using MOZ_NOT_REACHED, because behavior is literally undefined when we hit that statement, and triggering undefined behavior is scary. It's rarely the right thing to use -- see bug 820686 comment 0 and bug 820686 comment 8.
I'd feel better about this if we had NS_RUNTIMEABORT() (or the MOZ_ equivalent) before the MOZ_NOT_REACHED, to ensure that we safely crash, even in opt builds, rather than triggering undefined behavior.
Even with that, though, I still feel a bit hesitant -- a runtime abort is a bit heavy-handed, just to fix a build warning. (Plus, we don't really have any type-enforced guarantees that the value we're switching over will be in the expected range -- it's just an int with some #define'd values, not an enum or anything.)
I'd rather we just initialized the variable to some reasonable value in the "default" case (maybe whatever the property's initial value is). We'll still hit the NS_ERROR(), so debug builds will complain, but our actual release builds won't crash & will have defined (& likely-reasonable) behavior.
How does that sound?
Updated•13 years ago
|
Blocks: buildwarning
Updated•13 years ago
|
Attachment #719730 -
Flags: review?(dholbert) → review-
Updated•13 years ago
|
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → DUPLICATE
| Reporter | ||
Updated•13 years ago
|
Assignee: jwatt → nobody
You need to log in
before you can comment on or make changes to this bug.
Description
•