Bug 1066935 - Part 1: Fix -Wsign-compare and -Wunreachable-code warnings in webrtc/signaling. r=jesup
authorChris Peterson <cpeterson@mozilla.com>
Fri, 12 Sep 2014 23:17:08 -0700
changeset 205214 51cb121dd56e2f9fd513baa00397fec6b4ea7ca3
parent 205213 f91c37926ae87b8811baf4370bea32f2ad8a5671
child 205215 df5e004949644858d92ff517f1da698f18509645
push id49112
push usercpeterson@mozilla.com
push dateSun, 14 Sep 2014 06:18:45 +0000
treeherdermozilla-inbound@df5e00494964 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup
bugs1066935
milestone35.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1066935 - Part 1: Fix -Wsign-compare and -Wunreachable-code warnings in webrtc/signaling. r=jesup
media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.cpp
--- a/media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.cpp
+++ b/media/webrtc/signaling/src/media-conduit/WebrtcGmpVideoCodec.cpp
@@ -96,18 +96,17 @@ WebrtcFrameTypeToGmpFrameType(webrtc::Vi
       break;
     case webrtc::kAltRefFrame:
       *aOut = kGMPAltRefFrame;
       break;
     case webrtc::kSkipFrame:
       *aOut = kGMPSkipFrame;
       break;
     default:
-      MOZ_CRASH();
-      return WEBRTC_VIDEO_CODEC_ERROR;
+      MOZ_CRASH("Unexpected VideoFrameType");
   }
 
   return WEBRTC_VIDEO_CODEC_OK;
 }
 
 static int
 GmpFrameTypeToWebrtcFrameType(GMPVideoFrameType aIn,
                               webrtc::VideoFrameType *aOut)
@@ -125,24 +124,22 @@ GmpFrameTypeToWebrtcFrameType(GMPVideoFr
       break;
     case kGMPAltRefFrame:
       *aOut = webrtc::kAltRefFrame;
       break;
     case kGMPSkipFrame:
       *aOut = webrtc::kSkipFrame;
       break;
     default:
-      MOZ_CRASH();
-      return WEBRTC_VIDEO_CODEC_ERROR;
+      MOZ_CRASH("Unexpected GMPVideoFrameType");
   }
 
   return WEBRTC_VIDEO_CODEC_OK;
 }
 
-
 int32_t
 WebrtcGmpVideoEncoder::InitEncode(const webrtc::VideoCodec* aCodecSettings,
                                   int32_t aNumberOfCores,
                                   uint32_t aMaxPayloadSize)
 {
   if (!mMPS) {
     mMPS = do_GetService("@mozilla.org/gecko-media-plugin-service;1");
   }
@@ -228,31 +225,31 @@ WebrtcGmpVideoEncoder::Encode(const webr
                                 &aInputImage,
                                 aCodecSpecificInfo,
                                 aFrameTypes,
                                 &ret));
 
   return ret;
 }
 
-
 int32_t
 WebrtcGmpVideoEncoder::Encode_g(const webrtc::I420VideoFrame* aInputImage,
                                 const webrtc::CodecSpecificInfo* aCodecSpecificInfo,
                                 const std::vector<webrtc::VideoFrameType>* aFrameTypes)
 {
   MOZ_ASSERT(mHost);
   if (!mGMP) {
     // destroyed via Terminate()
     return WEBRTC_VIDEO_CODEC_ERROR;
   }
 
-  if (aInputImage->width() != mCodecParams.mWidth ||
-      aInputImage->height() != mCodecParams.mHeight) {
-    LOGD(("GMP Encode: resolution change from %ux%u to %ux%u",
+  MOZ_ASSERT(aInputImage->width() >= 0 && aInputImage->height() >= 0);
+  if (static_cast<uint32_t>(aInputImage->width()) != mCodecParams.mWidth ||
+      static_cast<uint32_t>(aInputImage->height()) != mCodecParams.mHeight) {
+    LOGD(("GMP Encode: resolution change from %ux%u to %dx%d",
           mCodecParams.mWidth, mCodecParams.mHeight, aInputImage->width(), aInputImage->height()));
 
     mGMP->Close();
 
     // OpenH264 codec (at least) can't handle dynamic input resolution changes
     // re-init the plugin when the resolution changes
     // XXX allow codec to indicate it doesn't need re-init!
     nsTArray<nsCString> tags;
@@ -324,18 +321,16 @@ WebrtcGmpVideoEncoder::Encode_g(const we
   err = mGMP->Encode(Move(frame), codecSpecificInfo, gmp_frame_types);
   if (err != GMPNoErr) {
     return err;
   }
 
   return WEBRTC_VIDEO_CODEC_OK;
 }
 
-
-
 int32_t
 WebrtcGmpVideoEncoder::RegisterEncodeCompleteCallback(webrtc::EncodedImageCallback* aCallback)
 {
   mCallback = aCallback;
 
   return WEBRTC_VIDEO_CODEC_OK;
 }