Closed Bug 1278214 Opened 4 years ago Closed 4 years ago
[Static Analysis][Result is not floating-point] In function Compute
Spaced Repeat Size
58 bytes, text/x-review-board-request
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
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)
I don't think the #ifdef is needed, just use: float ratio = static_cast<float>(aAvailableSpace) / aImageDimension; it will work for both cases.
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.
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.
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 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
You need to log in before you can comment on or make changes to this bug.