Last Comment Bug 745272 - nsAudioAvailableEventManager.cpp:195:35: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
: nsAudioAvailableEventManager.cpp:195:35: warning: comparison of unsigned expr...
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: Audio/Video (show other bugs)
: Trunk
: x86_64 Linux
: -- normal (vote)
: mozilla14
Assigned To: Daniel Holbert [:dholbert]
:
: Maire Reavy [:mreavy]
Mentors:
Depends on:
Blocks: buildwarning 490705
  Show dependency treegraph
 
Reported: 2012-04-13 11:37 PDT by Daniel Holbert [:dholbert]
Modified: 2012-04-17 07:34 PDT (History)
3 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
fix (1.93 KB, patch)
2012-04-13 11:41 PDT, Daniel Holbert [:dholbert]
david.humphrey: review+
cpearce: review+
Details | Diff | Splinter Review

Description Daniel Holbert [:dholbert] 2012-04-13 11:37:28 PDT
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.
Comment 1 Daniel Holbert [:dholbert] 2012-04-13 11:41:09 PDT
Created attachment 614866 [details] [diff] [review]
fix
Comment 2 Daniel Holbert [:dholbert] 2012-04-13 11:42:29 PDT
(this is a build warning from g++ 4.6.3, FWIW)
Comment 3 David Humphrey (:humph) 2012-04-16 10:08:41 PDT
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.
Comment 4 Chris Pearce (:cpearce) 2012-04-16 14:17:43 PDT
Comment on attachment 614866 [details] [diff] [review]
fix

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

Looks good.
Comment 5 Daniel Holbert [:dholbert] 2012-04-16 14:30:11 PDT
https://hg.mozilla.org/integration/mozilla-inbound/rev/cfcd178b2f5f
Comment 6 Marco Bonardo [::mak] 2012-04-17 07:34:54 PDT
https://hg.mozilla.org/mozilla-central/rev/cfcd178b2f5f

Note You need to log in before you can comment on or make changes to this bug.