diff --git a/ipc/chromium/src/base/pickle.h b/ipc/chromium/src/base/pickle.h index 759f0f06a9c8..ee2c7cb18053 100644 --- a/ipc/chromium/src/base/pickle.h +++ b/ipc/chromium/src/base/pickle.h @@ -92,36 +92,37 @@ class Pickle { // the Pickle, initialize *iter to NULL. If successful, these methods return // true. Otherwise, false is returned to indicate that the result could not // be extracted. - MOZ_MUST_USE bool ReadBool(PickleIterator* iter, bool* result) const; - MOZ_MUST_USE bool ReadInt16(PickleIterator* iter, int16_t* result) const; - MOZ_MUST_USE bool ReadUInt16(PickleIterator* iter, uint16_t* result) const; - MOZ_MUST_USE bool ReadShort(PickleIterator* iter, short* result) const; - MOZ_MUST_USE bool ReadInt(PickleIterator* iter, int* result) const; - MOZ_MUST_USE bool ReadLong(PickleIterator* iter, long* result) const; - MOZ_MUST_USE bool ReadULong(PickleIterator* iter, - unsigned long* result) const; - MOZ_MUST_USE bool ReadInt32(PickleIterator* iter, int32_t* result) const; - MOZ_MUST_USE bool ReadUInt32(PickleIterator* iter, uint32_t* result) const; - MOZ_MUST_USE bool ReadInt64(PickleIterator* iter, int64_t* result) const; - MOZ_MUST_USE bool ReadUInt64(PickleIterator* iter, uint64_t* result) const; - MOZ_MUST_USE bool ReadDouble(PickleIterator* iter, double* result) const; - MOZ_MUST_USE bool ReadIntPtr(PickleIterator* iter, intptr_t* result) const; - MOZ_MUST_USE bool ReadUnsignedChar(PickleIterator* iter, - unsigned char* result) const; - MOZ_MUST_USE bool ReadString(PickleIterator* iter, std::string* result) const; - MOZ_MUST_USE bool ReadWString(PickleIterator* iter, - std::wstring* result) const; - MOZ_MUST_USE bool ReadBytesInto(PickleIterator* iter, void* data, - uint32_t length) const; - MOZ_MUST_USE bool ExtractBuffers( + [[nodiscard]] bool ReadBool(PickleIterator* iter, bool* result) const; + [[nodiscard]] bool ReadInt16(PickleIterator* iter, int16_t* result) const; + [[nodiscard]] bool ReadUInt16(PickleIterator* iter, uint16_t* result) const; + [[nodiscard]] bool ReadShort(PickleIterator* iter, short* result) const; + [[nodiscard]] bool ReadInt(PickleIterator* iter, int* result) const; + [[nodiscard]] bool ReadLong(PickleIterator* iter, long* result) const; + [[nodiscard]] bool ReadULong(PickleIterator* iter, + unsigned long* result) const; + [[nodiscard]] bool ReadInt32(PickleIterator* iter, int32_t* result) const; + [[nodiscard]] bool ReadUInt32(PickleIterator* iter, uint32_t* result) const; + [[nodiscard]] bool ReadInt64(PickleIterator* iter, int64_t* result) const; + [[nodiscard]] bool ReadUInt64(PickleIterator* iter, uint64_t* result) const; + [[nodiscard]] bool ReadDouble(PickleIterator* iter, double* result) const; + [[nodiscard]] bool ReadIntPtr(PickleIterator* iter, intptr_t* result) const; + [[nodiscard]] bool ReadUnsignedChar(PickleIterator* iter, + unsigned char* result) const; + [[nodiscard]] bool ReadString(PickleIterator* iter, + std::string* result) const; + [[nodiscard]] bool ReadWString(PickleIterator* iter, + std::wstring* result) const; + [[nodiscard]] bool ReadBytesInto(PickleIterator* iter, void* data, + uint32_t length) const; + [[nodiscard]] bool ExtractBuffers( PickleIterator* iter, size_t length, BufferList* buffers, uint32_t alignment = sizeof(memberAlignmentType)) const; // Safer version of ReadInt() checks for the result not being negative. // Use it for reading the object sizes. - MOZ_MUST_USE bool ReadLength(PickleIterator* iter, int* result) const; + [[nodiscard]] bool ReadLength(PickleIterator* iter, int* result) const; - MOZ_MUST_USE bool ReadSentinel(PickleIterator* iter, uint32_t sentinel) const + [[nodiscard]] bool ReadSentinel(PickleIterator* iter, uint32_t sentinel) const #ifdef MOZ_PICKLE_SENTINEL_CHECKING ; #else diff --git a/ipc/chromium/src/base/shared_memory.h b/ipc/chromium/src/base/shared_memory.h index 8f7fa4e3b092..5762d8907670 100644 --- a/ipc/chromium/src/base/shared_memory.h +++ b/ipc/chromium/src/base/shared_memory.h @@ -122,7 +122,7 @@ class SharedMemory { // // (See bug 1479960 comment #0 for OS-specific implementation // details.) - MOZ_MUST_USE bool Freeze() { + [[nodiscard]] bool Freeze() { Unmap(); return ReadOnlyCopy(this); } @@ -141,7 +141,7 @@ class SharedMemory { // only if the memory was unmapped, but this is an implementation // detail and shouldn't be relied on; for that use case Freeze() // should be used instead.) - MOZ_MUST_USE bool ReadOnlyCopy(SharedMemory* ro_out); + [[nodiscard]] bool ReadOnlyCopy(SharedMemory* ro_out); // Closes the open shared memory segment. // It is safe to call Close repeatedly. diff --git a/ipc/glue/IPCStreamUtils.h b/ipc/glue/IPCStreamUtils.h index d30cd4738321..da854722478f 100644 --- a/ipc/glue/IPCStreamUtils.h +++ b/ipc/glue/IPCStreamUtils.h @@ -164,16 +164,16 @@ class AutoIPCStream { bool Serialize(nsIInputStream* aStream, net::SocketProcessChild* aManager); // Serialize the input stream. - MOZ_MUST_USE bool Serialize(nsIInputStream* aStream, - dom::ContentParent* aManager); + [[nodiscard]] bool Serialize(nsIInputStream* aStream, + dom::ContentParent* aManager); // Serialize the input stream. - MOZ_MUST_USE bool Serialize(nsIInputStream* aStream, - PBackgroundParent* aManager); + [[nodiscard]] bool Serialize(nsIInputStream* aStream, + PBackgroundParent* aManager); // Serialize the input stream. - MOZ_MUST_USE bool Serialize(nsIInputStream* aStream, - net::SocketProcessParent* aManager); + [[nodiscard]] bool Serialize(nsIInputStream* aStream, + net::SocketProcessParent* aManager); // Get the IPCStream as a non-optional value. This will // assert if a stream has not been serialized or if it has already been taken. diff --git a/ipc/glue/SharedMemory.h b/ipc/glue/SharedMemory.h index 5f180f67be58..c7c230389e16 100644 --- a/ipc/glue/SharedMemory.h +++ b/ipc/glue/SharedMemory.h @@ -83,8 +83,8 @@ class SharedMemory { NS_INLINE_DECL_THREADSAFE_REFCOUNTING(SharedMemory) static void SystemProtect(char* aAddr, size_t aSize, int aRights); - static MOZ_MUST_USE bool SystemProtectFallible(char* aAddr, size_t aSize, - int aRights); + [[nodiscard]] static bool SystemProtectFallible(char* aAddr, size_t aSize, + int aRights); static size_t SystemPageSize(); static size_t PageAlignedSize(size_t aSize); diff --git a/ipc/ipdl/ipdl/cxx/cgen.py b/ipc/ipdl/ipdl/cxx/cgen.py index b87721124dfb..cc4391b463fe 100644 --- a/ipc/ipdl/ipdl/cxx/cgen.py +++ b/ipc/ipdl/ipdl/cxx/cgen.py @@ -218,7 +218,7 @@ class CxxCodeGen(CodePrinter, Visitor): self.printdent() if md.warn_unused: - self.write('MOZ_MUST_USE ') + self.write('[[nodiscard]] ') if md.methodspec == MethodSpec.STATIC: self.write('static ') diff --git a/ipc/mscom/COMPtrHolder.h b/ipc/mscom/COMPtrHolder.h index d817bac27a60..ee807e838c10 100644 --- a/ipc/mscom/COMPtrHolder.h +++ b/ipc/mscom/COMPtrHolder.h @@ -41,7 +41,7 @@ class COMPtrHolder { Interface* Get() const { return mPtr.get(); } - MOZ_MUST_USE Interface* Release() { return mPtr.release(); } + [[nodiscard]] Interface* Release() { return mPtr.release(); } void Set(COMPtrType&& aPtr) { mPtr = std::forward(aPtr); }