Bug 1368837 - MockMediaResource should fread individual bytes - r=cpearce
authorGerald Squelart <gsquelart@mozilla.com>
Fri, 26 May 2017 15:15:14 +1200
changeset 361719 2f9a486c2dbbfce70a97ea9ae2832ed9fac0f266
parent 361718 a341e170f306d01a9ade7eba3158edfe1c50995c
child 361720 9b1ef0d8d9605c49a7a96214107be59d94a227dd
push id31939
push usercbook@mozilla.com
push dateThu, 01 Jun 2017 11:49:28 +0000
treeherdermozilla-central@d96110d76619 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1368837
milestone55.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 1368837 - MockMediaResource should fread individual bytes - r=cpearce `fread(buf, count, 1, f)` meant that exactly one object of size `count` could be read. Changing that to `fread(buf, 1, count, f)` now reads up to `count` size-1 objects (aka bytes) up to `count` and returns that number of bytes read, which is usually what we want from a read, i.e. as much as possible even if it's less than requested. MozReview-Commit-ID: 3Lgvws19SFd
dom/media/gtest/MockMediaResource.cpp
--- a/dom/media/gtest/MockMediaResource.cpp
+++ b/dom/media/gtest/MockMediaResource.cpp
@@ -46,18 +46,17 @@ MockMediaResource::ReadAt(int64_t aOffse
 
   // Make it fail if we're re-entrant
   if (mEntry++) {
     MOZ_ASSERT(false);
     return NS_ERROR_FAILURE;
   }
 
   fseek(mFileHandle, aOffset, SEEK_SET);
-  size_t objectsRead = fread(aBuffer, aCount, 1, mFileHandle);
-  *aBytes = objectsRead == 1 ? aCount : 0;
+  *aBytes = fread(aBuffer, 1, aCount, mFileHandle);
 
   mEntry--;
 
   return ferror(mFileHandle) ? NS_ERROR_FAILURE : NS_OK;
 }
 
 int64_t
 MockMediaResource::GetLength()