Closed Bug 745272 Opened 8 years ago Closed 8 years ago

nsAudioAvailableEventManager.cpp:195:35: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]

Categories

(Core :: Audio/Video, defect)

x86_64
Linux
defect
Not set

Tracking

()

RESOLVED FIXED
mozilla14

People

(Reporter: dholbert, Assigned: dholbert)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

Filing bug on this build warning...
{
../../../mozilla/content/media/nsAudioAvailableEventManager.cpp: In member function ‘void nsAudioAvailableEventManager::QueueWrittenAudioData(AudioDataValue*, PRUint32, PRUint64)’:
../../../mozilla/content/media/nsAudioAvailableEventManager.cpp:195:35: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
}

...for this chunk of code...

> 149   PRUint32 audioDataLength = aAudioDataLength;
[...]
> 153   while (signalBufferTail <= audioDataLength) {
[...]
> 167     audioData += signalBufferTail;
> 168     audioDataLength -= signalBufferTail;
[...]
> 195     NS_ASSERTION(audioDataLength >= 0, "Past new signal data length.");
[...]
> 209   }

...which was added in bug 490705.

Note that audioDataLength is unsigned, so it's >= 0 by definition.

If we actually want to assert that it's not going to wrap around, we should assert _just before_ line 168 that we're not about to subtract a value larger than audioDataLength.
Attached patch fixSplinter Review
Assignee: nobody → dholbert
Status: NEW → ASSIGNED
Attachment #614866 - Flags: review?(david.humphrey)
Blocks: buildwarning
(this is a build warning from g++ 4.6.3, FWIW)
Comment on attachment 614866 [details] [diff] [review]
fix

Review of attachment 614866 [details] [diff] [review]:
-----------------------------------------------------------------

This looks good, thanks for catching it.  Since I'm not an owner/peer, I'm going to ask cpearce to look at this.
Attachment #614866 - Flags: review?(david.humphrey)
Attachment #614866 - Flags: review?(cpearce)
Attachment #614866 - Flags: review+
Comment on attachment 614866 [details] [diff] [review]
fix

Review of attachment 614866 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good.
Attachment #614866 - Flags: review?(cpearce) → review+
https://hg.mozilla.org/mozilla-central/rev/cfcd178b2f5f
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.