Closed
Bug 534156
Opened 15 years ago
Closed 15 years ago
Fix "nsSVGUtils.cpp:724: warning: ‘axis’ may be used uninitialized in this function"
Categories
(Core :: SVG, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: dholbert, Assigned: dholbert)
References
Details
(Whiteboard: [build_warning])
Attachments
(1 file, 1 obsolete file)
945 bytes,
patch
|
jwatt
:
review+
|
Details | Diff | Splinter Review |
GCC 4.3.3 on Linux gives us this warning, when building mozilla-central:
> /layout/svg/base/src/nsSVGUtils.cpp: In static member function ‘static float nsSVGUtils::ObjectSpace(const gfxRect&, const nsSVGLength2*)’:
> /layout/svg/base/src/nsSVGUtils.cpp:724: warning: ‘axis’ may be used uninitialized in this function
Not all instances of this type of build warning are actually bugs, but this
particular one appears to sort of be, and it's easily fixable. Relevant snippet of code:
724 float fraction, axis;
725
726 switch (aLength->GetCtxType()) {
727 case X:
728 axis = aRect.Width();
729 break;
730 case Y:
731 axis = aRect.Height();
732 break;
733 case XY:
734 axis = float(ComputeNormalizedHypotenuse(aRect.Width(), aRect.Height()));
735 }
[...]
743 return fraction * axis;
The function aLength->GetCtxType() returns a PRUint8. In the (unlikely) event that this value is anything other than the enums X, Y, or XY, then we never set |axis|, and we'll return a completely bogus value from ObjectSpace().
Attached patch trivially fixes this by zeroing |axis| in a new 'default' case of the switch statement, with a NS_NOTREACHED to more explicitly state our assumption that we should never get there.
Attachment #417065 -
Flags: review?(jwatt)
Assignee | ||
Comment 1•15 years ago
|
||
I changed "0" to "0.0f" in this version. (since axis is a float)
Assignee | ||
Updated•15 years ago
|
Attachment #417065 -
Attachment is obsolete: true
Attachment #417065 -
Flags: review?(jwatt)
![]() |
||
Updated•15 years ago
|
Attachment #417066 -
Flags: review?(jwatt) → review+
Assignee | ||
Comment 2•15 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Assignee | ||
Updated•15 years ago
|
Whiteboard: [build_warning]
You need to log in
before you can comment on or make changes to this bug.
Description
•