Closed Bug 1250083 Opened 4 years ago Closed 4 years ago

[Static Analysis][Result is not floating-point] In function WAVTrackDemuxer::Duration

Categories

(Core :: Audio/Video: Playback, defect)

defect
Not set

Tracking

()

RESOLVED FIXED
mozilla47
Tracking Status
firefox47 --- fixed

People

(Reporter: andi, Assigned: andi)

References

(Blocks 1 open bug)

Details

(Keywords: coverity, Whiteboard: CID 1353467)

Attachments

(1 file)

The Static Analysis tool Coverity added even though variable |usPerDataChunk| is declared as double it's attributed value will not be a floating point since no operand is a floating point type:

>>  const double usPerDataChunk = USECS_PER_S * mSamplesPerChunk /
>>                                mSamplesPerSecond;
>>  return TimeUnit::FromMicroseconds(aNumDataChunks * usPerDataChunk);

The result will be loss of fractional value.
Component: Audio/Video → Audio/Video: Playback
Attachment #8721936 - Flags: review?(cpearce) → review+
Comment on attachment 8721936 [details]
MozReview Request: Bug 1250083 - make sure value attributed to usPerDataChunk is floating point value. r=cpearce

https://reviewboard.mozilla.org/r/35799/#review32747

Thanks!

::: dom/media/wave/WaveDemuxer.cpp:430
(Diff revision 1)
> -  const double usPerDataChunk = USECS_PER_S * mSamplesPerChunk /
> +  const double usPerDataChunk = USECS_PER_S * (double)mSamplesPerChunk /

C++ style case, i.e.:

static_cast<double>(mSamplesPerChunk)
Attachment #8721936 - Attachment description: MozReview Request: Bug 1250083 - make sure value attributed to usPerDataChunk is floating point value. r?cpearce → MozReview Request: Bug 1250083 - make sure value attributed to usPerDataChunk is floating point value. r=cpearce
Comment on attachment 8721936 [details]
MozReview Request: Bug 1250083 - make sure value attributed to usPerDataChunk is floating point value. r=cpearce

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/35799/diff/1-2/
Comment on attachment 8721936 [details]
MozReview Request: Bug 1250083 - make sure value attributed to usPerDataChunk is floating point value. r=cpearce

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/35799/diff/2-3/
https://hg.mozilla.org/mozilla-central/rev/80bce7740b80
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla47
> > -  const double usPerDataChunk = USECS_PER_S * mSamplesPerChunk /
> > +  const double usPerDataChunk = USECS_PER_S * (double)mSamplesPerChunk /
> 
> C++ style case, i.e.:
> 
> static_cast<double>(mSamplesPerChunk)

FWIW, I would have done |double(mSamplesPerChunk)|.
You need to log in before you can comment on or make changes to this bug.