Bug 1594529 - Replace MOZ_MUST_USE with [[nodiscard]] in dom/media. r=bryce
authorChris Peterson <cpeterson@mozilla.com>
Mon, 27 Apr 2020 15:18:07 +0000
changeset 526372 63a755d0e9b187c54a662e8ffd74bf7476cea905
parent 526371 1589fcd0929c82cc73b1874f144910bc2786d67a
child 526373 c54fde7ed1587ad174f6418579847f79c06675a0
push id37355
push useraiakab@mozilla.com
push dateTue, 28 Apr 2020 10:01:41 +0000
treeherdermozilla-central@a99c73301874 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbryce
bugs1594529
milestone77.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 1594529 - Replace MOZ_MUST_USE with [[nodiscard]] in dom/media. r=bryce Depends on D72565 Differential Revision: https://phabricator.services.mozilla.com/D72566
dom/media/BufferReader.h
dom/media/ByteWriter.h
dom/media/MediaData.h
dom/media/gmp/widevine-adapter/WidevineVideoFrame.h
--- a/dom/media/BufferReader.h
+++ b/dom/media/BufferReader.h
@@ -269,31 +269,31 @@ class MOZ_RAII BufferReader {
       MOZ_LOG(gMP4MetadataLog, mozilla::LogLevel::Error,
               ("%s: failure", __func__));
       return 0;
     }
     return *reinterpret_cast<const T*>(ptr);
   }
 
   template <typename T>
-  MOZ_MUST_USE bool ReadArray(nsTArray<T>& aDest, size_t aLength) {
+  [[nodiscard]] bool ReadArray(nsTArray<T>& aDest, size_t aLength) {
     auto ptr = Read(aLength * sizeof(T));
     if (!ptr) {
       MOZ_LOG(gMP4MetadataLog, mozilla::LogLevel::Error,
               ("%s: failure", __func__));
       return false;
     }
 
     aDest.Clear();
     aDest.AppendElements(reinterpret_cast<const T*>(ptr), aLength);
     return true;
   }
 
   template <typename T>
-  MOZ_MUST_USE bool ReadArray(FallibleTArray<T>& aDest, size_t aLength) {
+  [[nodiscard]] bool ReadArray(FallibleTArray<T>& aDest, size_t aLength) {
     auto ptr = Read(aLength * sizeof(T));
     if (!ptr) {
       MOZ_LOG(gMP4MetadataLog, mozilla::LogLevel::Error,
               ("%s: failure", __func__));
       return false;
     }
 
     aDest.Clear();
--- a/dom/media/ByteWriter.h
+++ b/dom/media/ByteWriter.h
@@ -11,49 +11,49 @@
 namespace mozilla {
 
 template <typename Endianess>
 class ByteWriter {
  public:
   explicit ByteWriter(nsTArray<uint8_t>& aData) : mPtr(aData) {}
   ~ByteWriter() = default;
 
-  MOZ_MUST_USE bool WriteU8(uint8_t aByte) { return Write(&aByte, 1); }
+  [[nodiscard]] bool WriteU8(uint8_t aByte) { return Write(&aByte, 1); }
 
-  MOZ_MUST_USE bool WriteU16(uint16_t aShort) {
+  [[nodiscard]] bool WriteU16(uint16_t aShort) {
     uint8_t c[2];
     Endianess::writeUint16(&c[0], aShort);
     return Write(&c[0], 2);
   }
 
-  MOZ_MUST_USE bool WriteU32(uint32_t aLong) {
+  [[nodiscard]] bool WriteU32(uint32_t aLong) {
     uint8_t c[4];
     Endianess::writeUint32(&c[0], aLong);
     return Write(&c[0], 4);
   }
 
-  MOZ_MUST_USE bool Write32(int32_t aLong) {
+  [[nodiscard]] bool Write32(int32_t aLong) {
     uint8_t c[4];
     Endianess::writeInt32(&c[0], aLong);
     return Write(&c[0], 4);
   }
 
-  MOZ_MUST_USE bool WriteU64(uint64_t aLongLong) {
+  [[nodiscard]] bool WriteU64(uint64_t aLongLong) {
     uint8_t c[8];
     Endianess::writeUint64(&c[0], aLongLong);
     return Write(&c[0], 8);
   }
 
-  MOZ_MUST_USE bool Write64(int64_t aLongLong) {
+  [[nodiscard]] bool Write64(int64_t aLongLong) {
     uint8_t c[8];
     Endianess::writeInt64(&c[0], aLongLong);
     return Write(&c[0], 8);
   }
 
-  MOZ_MUST_USE bool Write(const uint8_t* aSrc, size_t aCount) {
+  [[nodiscard]] bool Write(const uint8_t* aSrc, size_t aCount) {
     return mPtr.AppendElements(aSrc, aCount, mozilla::fallible);
   }
 
  private:
   nsTArray<uint8_t>& mPtr;
 };
 
 }  // namespace mozilla
--- a/dom/media/MediaData.h
+++ b/dom/media/MediaData.h
@@ -586,31 +586,31 @@ class MediaRawDataWriter {
   size_t Size();
   // Writeable reference to MediaRawData::mCryptoInternal
   CryptoSample& mCrypto;
 
   // Data manipulation methods. mData and mSize may be updated accordingly.
 
   // Set size of buffer, allocating memory as required.
   // If size is increased, new buffer area is filled with 0.
-  MOZ_MUST_USE bool SetSize(size_t aSize);
+  [[nodiscard]] bool SetSize(size_t aSize);
   // Add aData at the beginning of buffer.
-  MOZ_MUST_USE bool Prepend(const uint8_t* aData, size_t aSize);
-  MOZ_MUST_USE bool Append(const uint8_t* aData, size_t aSize);
+  [[nodiscard]] bool Prepend(const uint8_t* aData, size_t aSize);
+  [[nodiscard]] bool Append(const uint8_t* aData, size_t aSize);
   // Replace current content with aData.
-  MOZ_MUST_USE bool Replace(const uint8_t* aData, size_t aSize);
+  [[nodiscard]] bool Replace(const uint8_t* aData, size_t aSize);
   // Clear the memory buffer. Will set target mData and mSize to 0.
   void Clear();
   // Remove aSize bytes from the front of the sample.
   void PopFront(size_t aSize);
 
  private:
   friend class MediaRawData;
   explicit MediaRawDataWriter(MediaRawData* aMediaRawData);
-  MOZ_MUST_USE bool EnsureSize(size_t aSize);
+  [[nodiscard]] bool EnsureSize(size_t aSize);
   MediaRawData* mTarget;
 };
 
 class MediaRawData final : public MediaData {
  public:
   MediaRawData();
   MediaRawData(const uint8_t* aData, size_t aSize);
   MediaRawData(const uint8_t* aData, size_t aSize, const uint8_t* aAlphaData,
--- a/dom/media/gmp/widevine-adapter/WidevineVideoFrame.h
+++ b/dom/media/gmp/widevine-adapter/WidevineVideoFrame.h
@@ -33,18 +33,18 @@ class WidevineVideoFrame : public cdm::V
   uint32_t PlaneOffset(cdm::VideoFrame::VideoPlane aPlane) override;
 
   void SetStride(cdm::VideoFrame::VideoPlane aPlane, uint32_t aStride) override;
   uint32_t Stride(cdm::VideoFrame::VideoPlane aPlane) override;
 
   void SetTimestamp(int64_t aTimestamp) override;
   int64_t Timestamp() const override;
 
-  MOZ_MUST_USE bool InitToBlack(int32_t aWidth, int32_t aHeight,
-                                int64_t aTimeStamp);
+  [[nodiscard]] bool InitToBlack(int32_t aWidth, int32_t aHeight,
+                                 int64_t aTimeStamp);
 
  protected:
   cdm::VideoFormat mFormat;
   cdm::Size mSize;
   cdm::Buffer* mBuffer;
   uint32_t mPlaneOffsets[kMaxPlanes];
   uint32_t mPlaneStrides[kMaxPlanes];
   int64_t mTimestamp;