Bug 1514158 - Fix MediaRecorder static-analysis warnings. r=bryce
authorAndreas Pehrson <apehrson@mozilla.com>
Thu, 03 Oct 2019 22:09:06 +0000
changeset 496304 afa7200292eb7e36fac30eab6837e68aa1e52a85
parent 496303 c60d1d4fe9f44743cbface9d892a6b04bce9106e
child 496305 6ce6f0e0471bbd5375247912ccc45b07c8342504
push id97160
push userpehrsons@gmail.com
push dateFri, 04 Oct 2019 09:26:59 +0000
treeherderautoland@d7ab956c2962 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbryce
bugs1514158
milestone71.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 1514158 - Fix MediaRecorder static-analysis warnings. r=bryce Differential Revision: https://phabricator.services.mozilla.com/D41588
dom/media/MediaRecorder.cpp
dom/media/MediaRecorder.h
--- a/dom/media/MediaRecorder.cpp
+++ b/dom/media/MediaRecorder.cpp
@@ -299,23 +299,23 @@ class MediaRecorder::Session : public Pr
         : Runnable("StoreEncodedBufferRunnable"),
           mSession(aSession),
           mBuffer(std::move(aBuffer)) {}
 
     NS_IMETHOD
     Run() override {
       MOZ_ASSERT(NS_IsMainThread());
       mSession->MaybeCreateMutableBlobStorage();
-      for (uint32_t i = 0; i < mBuffer.Length(); i++) {
-        if (mBuffer[i].IsEmpty()) {
+      for (const auto& part : mBuffer) {
+        if (part.IsEmpty()) {
           continue;
         }
 
-        nsresult rv = mSession->mMutableBlobStorage->Append(
-            mBuffer[i].Elements(), mBuffer[i].Length());
+        nsresult rv = mSession->mMutableBlobStorage->Append(part.Elements(),
+                                                            part.Length());
         if (NS_WARN_IF(NS_FAILED(rv))) {
           mSession->DoSessionEndTask(rv);
           break;
         }
       }
 
       return NS_OK;
     }
@@ -1545,17 +1545,19 @@ static char const* const gOggAudioEncode
     // we could support vorbis here too, but don't
     nullptr,
 };
 
 template <class String>
 static bool CodecListContains(char const* const* aCodecs,
                               const String& aCodec) {
   for (int32_t i = 0; aCodecs[i]; ++i) {
-    if (aCodec.EqualsASCII(aCodecs[i])) return true;
+    if (aCodec.EqualsASCII(aCodecs[i])) {
+      return true;
+    }
   }
   return false;
 }
 
 /* static */
 bool MediaRecorder::IsTypeSupported(GlobalObject& aGlobal,
                                     const nsAString& aMIMEType) {
   return IsTypeSupported(aMIMEType);
--- a/dom/media/MediaRecorder.h
+++ b/dom/media/MediaRecorder.h
@@ -77,18 +77,19 @@ class MediaRecorder final : public DOMEv
   void RequestData(ErrorResult& aResult);
   // Return the The DOMMediaStream passed from UA.
   DOMMediaStream* Stream() const { return mStream; }
   // Return the current encoding MIME type selected by the MediaEncoder.
   void GetMimeType(nsString& aMimeType);
   // The current state of the MediaRecorder object.
   RecordingState State() const { return mState; }
 
-  static bool IsTypeSupported(GlobalObject& aGlobal, const nsAString& aType);
-  static bool IsTypeSupported(const nsAString& aType);
+  static bool IsTypeSupported(GlobalObject& aGlobal,
+                              const nsAString& aMIMEType);
+  static bool IsTypeSupported(const nsAString& aMIMEType);
 
   // Construct a recorder with a DOM media stream object as its source.
   static already_AddRefed<MediaRecorder> Constructor(
       const GlobalObject& aGlobal, DOMMediaStream& aStream,
       const MediaRecorderOptions& aOptions, ErrorResult& aRv);
   // Construct a recorder with a Web Audio destination node as its source.
   static already_AddRefed<MediaRecorder> Constructor(
       const GlobalObject& aGlobal, AudioNode& aAudioNode,