Bug 1629315 - Replace MOZ_MUST_USE with [[nodiscard]] in ipc. r=jld

Differential Revision: https://phabricator.services.mozilla.com/D70628
This commit is contained in:
Chris Peterson 2020-04-16 22:14:21 +00:00
Родитель 8101730a74
Коммит 40840febd0
6 изменённых файлов: 37 добавлений и 36 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -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.

Просмотреть файл

@ -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.

Просмотреть файл

@ -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);

Просмотреть файл

@ -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 ')

Просмотреть файл

@ -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<COMPtrType>(aPtr); }