Closed Bug 1278214 Opened 7 years ago Closed 7 years ago

[Static Analysis][Result is not floating-point] In function ComputeSpacedRepeatSize

Categories

(Core :: Layout, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla50
Tracking Status
firefox49 --- affected
firefox50 --- fixed

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
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)
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)
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
https://hg.mozilla.org/mozilla-central/rev/ffe52673664f
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla50
You need to log in before you can comment on or make changes to this bug.