Bug 726416 - Fix some content/ build warnings; r=mounir
authorMs2ger <ms2ger@gmail.com>
Tue, 21 Feb 2012 10:34:01 +0100
changeset 88723 254285dbf95469aeb902d422d12e2def71d77eee
parent 88722 93e2945d9f7381e121aa3d7d7102e92eb35fcdd3
child 88724 b2e52f75b118f0c110c2101a4d46ad4e093807fd
push idunknown
push userunknown
push dateunknown
reviewersmounir
bugs726416
milestone13.0a1
Bug 726416 - Fix some content/ build warnings; r=mounir
content/base/src/nsDocument.cpp
content/base/src/nsFrameMessageManager.cpp
content/media/nsBuiltinDecoder.cpp
content/media/nsBuiltinDecoderStateMachine.cpp
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -8115,17 +8115,17 @@ nsIDocument::ScheduleFrameRequestCallbac
 {
   if (mFrameRequestCallbackCounter == PR_INT32_MAX) {
     // Can't increment without overflowing; bail out
     return NS_ERROR_NOT_AVAILABLE;
   }
   PRInt32 newHandle = ++mFrameRequestCallbackCounter;
 
   bool alreadyRegistered = !mFrameRequestCallbacks.IsEmpty();
-  FrameRequest *request =
+  DebugOnly<FrameRequest*> request =
     mFrameRequestCallbacks.AppendElement(FrameRequest(aCallback, newHandle));
   NS_ASSERTION(request, "This is supposed to be infallible!");
   if (!alreadyRegistered && mPresShell && IsEventHandlingEnabled()) {
     mPresShell->GetPresContext()->RefreshDriver()->
       ScheduleFrameRequestCallbacks(this);
   }
 
   *aHandle = newHandle;
@@ -8298,21 +8298,18 @@ nsDocument::NotifyAudioAvailableListener
 }
 
 nsresult
 nsDocument::RemoveImage(imgIRequest* aImage)
 {
   NS_ENSURE_ARG_POINTER(aImage);
 
   // Get the old count. It should exist and be > 0.
-  PRUint32 count;
-#ifdef DEBUG
-  bool found =
-#endif
-  mImageTracker.Get(aImage, &count);
+  PRUint32 count = 0;
+  DebugOnly<bool> found = mImageTracker.Get(aImage, &count);
   NS_ABORT_IF_FALSE(found, "Removing image that wasn't in the tracker!");
   NS_ABORT_IF_FALSE(count > 0, "Entry in the cache tracker with count 0!");
 
   // We're removing, so decrement the count.
   count--;
 
   // If the count is now zero, remove from the tracker.
   // Otherwise, set the new value.
--- a/content/base/src/nsFrameMessageManager.cpp
+++ b/content/base/src/nsFrameMessageManager.cpp
@@ -344,17 +344,18 @@ nsFrameMessageManager::Atob(const nsAStr
 {
   return NS_OK;
 }
 
 class MMListenerRemover
 {
 public:
   MMListenerRemover(nsFrameMessageManager* aMM)
-  : mMM(aMM), mWasHandlingMessage(aMM->mHandlingMessage)
+    : mWasHandlingMessage(aMM->mHandlingMessage)
+    , mMM(aMM)
   {
     mMM->mHandlingMessage = true;
   }
   ~MMListenerRemover()
   {
     if (!mWasHandlingMessage) {
       mMM->mHandlingMessage = false;
       if (mMM->mDisconnected) {
--- a/content/media/nsBuiltinDecoder.cpp
+++ b/content/media/nsBuiltinDecoder.cpp
@@ -322,17 +322,19 @@ nsresult nsBuiltinDecoder::Seek(double a
   // If the position we want to seek to is not in a seekable range, we seek
   // to the closest position in the seekable ranges instead. If two positions
   // are equally close, we seek to the closest position from the currentTime.
   // See seeking spec, point 7 :
   // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#seeking
   PRInt32 range = 0;
   if (!IsInRanges(seekable, aTime, range)) {
     if (range != -1) {
-      if (range + 1 < length) {
+      // |range + 1| can't be negative, because the only possible negative value
+      // for |range| is -1.
+      if (PRUint32(range + 1) < length) {
         double leftBound, rightBound;
         res = seekable.End(range, &leftBound);
         NS_ENSURE_SUCCESS(res, NS_OK);
         res = seekable.Start(range + 1, &rightBound);
         NS_ENSURE_SUCCESS(res, NS_OK);
         double distanceLeft = NS_ABS(leftBound - aTime);
         double distanceRight = NS_ABS(rightBound - aTime);
         if (distanceLeft == distanceRight) {
--- a/content/media/nsBuiltinDecoderStateMachine.cpp
+++ b/content/media/nsBuiltinDecoderStateMachine.cpp
@@ -44,16 +44,17 @@
 #include "nsBuiltinDecoderStateMachine.h"
 #include "mozilla/mozalloc.h"
 #include "VideoUtils.h"
 #include "nsTimeRanges.h"
 #include "nsDeque.h"
 
 #include "mozilla/Preferences.h"
 #include "mozilla/StdInt.h"
+#include "mozilla/Util.h"
 
 using namespace mozilla;
 using namespace mozilla::layers;
 
 #ifdef PR_LOGGING
 extern PRLogModuleInfo* gBuiltinDecoderLog;
 #define LOG(type, msg) PR_LOG(gBuiltinDecoderLog, type, msg)
 #else
@@ -302,19 +303,18 @@ StateMachineTracker& StateMachineTracker
 }
 
 void StateMachineTracker::EnsureGlobalStateMachine() 
 {
   NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
   ReentrantMonitorAutoEnter mon(mMonitor);
   if (mStateMachineCount == 0) {
     NS_ASSERTION(!mStateMachineThread, "Should have null state machine thread!");
-    nsresult res = NS_NewThread(&mStateMachineThread,
-                                nsnull);
-    NS_ABORT_IF_FALSE(NS_SUCCEEDED(res), "Can't create media state machine thread");
+    DebugOnly<nsresult> rv = NS_NewThread(&mStateMachineThread, nsnull);
+    NS_ABORT_IF_FALSE(NS_SUCCEEDED(rv), "Can't create media state machine thread");
   }
   mStateMachineCount++;
 }
 
 #ifdef DEBUG
 bool StateMachineTracker::IsQueued(nsBuiltinDecoderStateMachine* aStateMachine)
 {
   ReentrantMonitorAutoEnter mon(mMonitor);
@@ -861,21 +861,21 @@ void nsBuiltinDecoderStateMachine::Audio
   {
     // Last frame pushed to audio hardware, wait for the audio to finish,
     // before the audio thread terminates.
     bool seeking = false;
     {
       ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
       PRInt64 unplayedFrames = audioDuration % minWriteFrames;
       if (minWriteFrames > 1 && unplayedFrames > 0) {
-        // Sound is written by libsydneyaudio to the hardware in blocks of
-        // frames of size minWriteFrames. So if the number of frames we've
-        // written isn't an exact multiple of minWriteFrames, we'll have
-        // left over audio data which hasn't yet been written to the hardware,
-        // and so that audio will not start playing. Write silence to ensure
+        // Sound is written by libsydneyaudio to the hardware in blocks of
+        // frames of size minWriteFrames. So if the number of frames we've
+        // written isn't an exact multiple of minWriteFrames, we'll have
+        // left over audio data which hasn't yet been written to the hardware,
+        // and so that audio will not start playing. Write silence to ensure
         // the last block gets pushed to hardware, so that playback starts.
         PRInt64 framesToWrite = minWriteFrames - unplayedFrames;
         if (framesToWrite < PR_UINT32_MAX / channels) {
           // Write silence manually rather than using PlaySilence(), so that
           // the AudioAPI doesn't get a copy of the audio frames.
           PRUint32 numSamples = framesToWrite * channels;
           nsAutoArrayPtr<AudioDataValue> buf(new AudioDataValue[numSamples]);
           memset(buf.get(), 0, numSamples * sizeof(AudioDataValue));