Closed
Bug 1278214
Opened 8 years ago
Closed 8 years ago
[Static Analysis][Result is not floating-point] In function ComputeSpacedRepeatSize
Categories
(Core :: Layout, defect)
Core
Layout
Tracking
()
RESOLVED
FIXED
mozilla50
People
(Reporter: andi, Assigned: andi)
References
(Blocks 1 open bug)
Details
(Keywords: coverity, Whiteboard: CID 1362551)
Attachments
(1 file)
The Static Analysis tool Coverity added that the result of the following operation is not floating point:
>> float ratio = aAvailableSpace / aImageDimension;
This is only when NS_COORD_IS_FLOAT is not defined.
I think the correct method should be:
>>#ifdef NS_COORD_IS_FLOAT
>> float ratio = aAvailableSpace / aImageDimension;
>>#else
>> float ratio = static_cast<float>(aAvailableSpace) / aImageDimension;
>>#endif
Assignee | ||
Comment 1•8 years ago
|
||
Review commit: https://reviewboard.mozilla.org/r/57890/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/57890/
Attachment #8760233 -
Flags: review?(smontagu)
Comment 2•8 years ago
|
||
I don't think the #ifdef is needed, just use:
float ratio = static_cast<float>(aAvailableSpace) / aImageDimension;
it will work for both cases.
Flags: needinfo?(bpostelnicu)
Assignee | ||
Comment 3•8 years ago
|
||
sure it will work for both cases, but when nscoord is defined as float do we really want to do the static_cast? In this case is useless. That's why i've used the ifdef. But if you still think i should change it i will update the patch.
Flags: needinfo?(bpostelnicu)
Comment 4•8 years ago
|
||
It's unlikely that we will ever enable NS_COORD_IS_FLOAT so we should try
to avoid introducing new uses of it when it can be avoided. I think
the one-liner is the preferred way for cases like this.
Assignee | ||
Comment 5•8 years ago
|
||
Comment on attachment 8760233 [details]
Bug 1278214 - ensure operation result is floating point.
Review request updated; see interdiff: https://reviewboard.mozilla.org/r/57890/diff/1-2/
Attachment #8760233 -
Flags: review?(smontagu) → review?(mats)
Comment 6•8 years ago
|
||
Comment on attachment 8760233 [details]
Bug 1278214 - ensure operation result is floating point.
https://reviewboard.mozilla.org/r/57890/#review54754
Thanks.
Attachment #8760233 -
Flags: review?(mats) → review+
Pushed by Bogdan.Postelnicu@softvision.ro:
https://hg.mozilla.org/integration/mozilla-inbound/rev/ffe52673664f
ensure operation result is floating point. r=mats
Comment 8•8 years ago
|
||
bugherder |
Status: NEW → RESOLVED
Closed: 8 years ago
status-firefox50:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla50
You need to log in
before you can comment on or make changes to this bug.
Description
•