Bug 1038853 - Use nullptr instead of 0 in Shmem.h and Shmem.cpp. r=bent
authorAndrew McCreight <continuation@gmail.com>
Tue, 15 Jul 2014 16:51:44 -0700
changeset 216187 11add1847747a3f310cf973b988dd12c6c037415
parent 216186 5a5d9f2a29ca0ab220d582a4e3fd8465423accbd
child 216188 c73dc6d84e894fe1cf8f25ac100fac782c429195
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbent
bugs1038853
milestone33.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 1038853 - Use nullptr instead of 0 in Shmem.h and Shmem.cpp. r=bent
ipc/glue/Shmem.cpp
ipc/glue/Shmem.h
--- a/ipc/glue/Shmem.cpp
+++ b/ipc/glue/Shmem.cpp
@@ -118,20 +118,20 @@ CreateSegment(size_t aNBytes, SharedMemo
 
   if (SharedMemorySysV::IsHandleValid(aHandle)) {
     segment = new SharedMemorySysV(aHandle);
   }
   else {
     segment = new SharedMemorySysV();
 
     if (!segment->Create(aNBytes))
-      return 0;
+      return nullptr;
   }
   if (!segment->Map(aNBytes))
-    return 0;
+    return nullptr;
 
   segment->AddRef();
   return segment.forget();
 }
 #endif
 
 static Shmem::SharedMemory*
 CreateSegment(size_t aNBytes, SharedMemoryBasic::Handle aHandle)
@@ -140,20 +140,20 @@ CreateSegment(size_t aNBytes, SharedMemo
 
   if (SharedMemoryBasic::IsHandleValid(aHandle)) {
     segment = new SharedMemoryBasic(aHandle);
   }
   else {
     segment = new SharedMemoryBasic();
 
     if (!segment->Create(aNBytes))
-      return 0;
+      return nullptr;
   }
   if (!segment->Map(aNBytes))
-    return 0;
+    return nullptr;
 
   segment->AddRef();
   return segment.forget();
 }
 
 static void
 DestroySegment(SharedMemory* aSegment)
 {
@@ -276,17 +276,17 @@ Unprotect(SharedMemory* aSegment)
 // The "unmapped" state is used to enforce single-owner semantics of
 // the shmem segment.  If a process other than the current owner tries
 // to touch the segment, it dies with SIGSEGV.
 //
 
 Shmem::Shmem(IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead,
              SharedMemory* aSegment, id_t aId) :
     mSegment(aSegment),
-    mData(0),
+    mData(nullptr),
     mSize(0)
 {
   NS_ABORT_IF_FALSE(mSegment, "NULL segment");
   NS_ABORT_IF_FALSE(aId != 0, "invalid ID");
 
   Unprotect(mSegment);
 
   Header* header;
@@ -371,17 +371,17 @@ Shmem::Alloc(IHadBetterBeIPDLCodeCalling
     segment = CreateSegment(segmentSize, SharedMemorySysV::NULLHandle());
 #endif
   else {
     NS_ERROR("unknown shmem type");
     return nullptr;
   }
 
   if (!segment)
-    return 0;
+    return nullptr;
 
   Header* header;
   char *frontSentinel;
   char *data;
   char *backSentinel;
   GetSections(segment, &header, &frontSentinel, &data, &backSentinel);
 
   // initialize the segment with Shmem-internal information
@@ -408,58 +408,58 @@ Shmem::OpenExisting(IHadBetterBeIPDLCode
                     id_t* aId,
                     bool aProtect)
 {
   if (SHMEM_CREATED_MESSAGE_TYPE != aDescriptor.type()) {
     NS_ERROR("expected 'shmem created' message");
     return nullptr;
   }
 
-  void* iter = 0;
+  void* iter = nullptr;
   SharedMemory::SharedMemoryType type;
   size_t size;
   if (!ShmemCreated::ReadInfo(&aDescriptor, &iter, aId, &size, &type))
-    return 0;
+    return nullptr;
 
-  SharedMemory* segment = 0;
+  SharedMemory* segment = nullptr;
   size_t pageSize = SharedMemory::SystemPageSize();
   // |2*pageSize| is for the front and back sentinels
   size_t segmentSize = SharedMemory::PageAlignedSize(size + 2*pageSize);
 
   if (SharedMemory::TYPE_BASIC == type) {
     SharedMemoryBasic::Handle handle;
     if (!ShmemCreated::ReadHandle(&aDescriptor, &iter, &handle))
-      return 0;
+      return nullptr;
 
     if (!SharedMemoryBasic::IsHandleValid(handle)) {
       NS_ERROR("trying to open invalid handle");
       return nullptr;
     }
     segment = CreateSegment(segmentSize, handle);
   }
 #ifdef MOZ_HAVE_SHAREDMEMORYSYSV
   else if (SharedMemory::TYPE_SYSV == type) {
     SharedMemorySysV::Handle handle;
     if (!ShmemCreated::ReadHandle(&aDescriptor, &iter, &handle))
-      return 0;
+      return nullptr;
 
     if (!SharedMemorySysV::IsHandleValid(handle)) {
       NS_ERROR("trying to open invalid handle");
       return nullptr;
     }
     segment = CreateSegment(segmentSize, handle);
   }
 #endif
   else {
     NS_ERROR("unknown shmem type");
     return nullptr;
   }
 
   if (!segment)
-    return 0;
+    return nullptr;
 
   Header* header = GetHeader(segment);
 
   if (size != header->mSize) {
     NS_ERROR("Wrong size for this Shmem!");
     delete segment;
     return nullptr;
   }
@@ -496,17 +496,17 @@ Shmem::Dealloc(IHadBetterBeIPDLCodeCalli
 }
 
 
 #else  // !defined(DEBUG)
 
 // static
 Shmem::SharedMemory*
 Shmem::Alloc(IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead,
-             size_t aNBytes, 
+             size_t aNBytes,
              SharedMemoryType aType,
              bool /*unused*/,
              bool /*unused*/)
 {
   SharedMemory *segment = nullptr;
 
   if (aType == SharedMemory::TYPE_BASIC)
     segment = CreateSegment(SharedMemory::PageAlignedSize(aNBytes + sizeof(uint32_t)),
@@ -516,17 +516,17 @@ Shmem::Alloc(IHadBetterBeIPDLCodeCalling
     segment = CreateSegment(SharedMemory::PageAlignedSize(aNBytes + sizeof(uint32_t)),
                             SharedMemorySysV::NULLHandle());
 #endif
   else {
     return nullptr;
   }
 
   if (!segment)
-    return 0;
+    return nullptr;
 
   *PtrToSize(segment) = static_cast<uint32_t>(aNBytes);
 
   return segment;
 }
 
 // static
 Shmem::SharedMemory*
@@ -535,53 +535,53 @@ Shmem::OpenExisting(IHadBetterBeIPDLCode
                     id_t* aId,
                     bool /*unused*/)
 {
   if (SHMEM_CREATED_MESSAGE_TYPE != aDescriptor.type()) {
     return nullptr;
   }
 
   SharedMemory::SharedMemoryType type;
-  void* iter = 0;
+  void* iter = nullptr;
   size_t size;
   if (!ShmemCreated::ReadInfo(&aDescriptor, &iter, aId, &size, &type))
-    return 0;
+    return nullptr;
 
-  SharedMemory* segment = 0;
+  SharedMemory* segment = nullptr;
   size_t segmentSize = SharedMemory::PageAlignedSize(size + sizeof(uint32_t));
 
   if (SharedMemory::TYPE_BASIC == type) {
     SharedMemoryBasic::Handle handle;
     if (!ShmemCreated::ReadHandle(&aDescriptor, &iter, &handle))
-      return 0;
+      return nullptr;
 
     if (!SharedMemoryBasic::IsHandleValid(handle)) {
       return nullptr;
     }
 
     segment = CreateSegment(segmentSize, handle);
   }
 #ifdef MOZ_HAVE_SHAREDMEMORYSYSV
   else if (SharedMemory::TYPE_SYSV == type) {
     SharedMemorySysV::Handle handle;
     if (!ShmemCreated::ReadHandle(&aDescriptor, &iter, &handle))
-      return 0;
+      return nullptr;
 
     if (!SharedMemorySysV::IsHandleValid(handle)) {
       return nullptr;
     }
     segment = CreateSegment(segmentSize, handle);
   }
 #endif
   else {
     return nullptr;
   }
 
   if (!segment)
-    return 0;
+    return nullptr;
 
   // this is the only validity check done in non-DEBUG builds
   if (size != static_cast<size_t>(*PtrToSize(segment))) {
     delete segment;
     return nullptr;
   }
 
   return segment;
@@ -627,32 +627,32 @@ Shmem::ShareTo(IHadBetterBeIPDLCodeCalli
   if (aProcess == kInvalidProcessHandle) {
     aProcess = base::GetCurrentProcessHandle();
   }
 
   if (SharedMemory::TYPE_BASIC == mSegment->Type()) {
     SharedMemoryBasic* seg = static_cast<SharedMemoryBasic*>(mSegment);
     SharedMemoryBasic::Handle handle;
     if (!seg->ShareToProcess(aProcess, &handle))
-      return 0;
+      return nullptr;
 
     return new ShmemCreated(routingId, mId, mSize, handle);
   }
 #ifdef MOZ_HAVE_SHAREDMEMORYSYSV
   else if (SharedMemory::TYPE_SYSV == mSegment->Type()) {
     SharedMemorySysV* seg = static_cast<SharedMemorySysV*>(mSegment);
     return new ShmemCreated(routingId, mId, mSize, seg->GetHandle());
   }
 #endif
   else {
     NS_ABORT_IF_FALSE(false, "unknown shmem type (here?!)");
     return nullptr;
   }
 
-  return 0;
+  return nullptr;
 }
 
 IPC::Message*
 Shmem::UnshareFrom(IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead,
                    base::ProcessHandle aProcess,
                    int32_t routingId)
 {
   AssertInvariants();
--- a/ipc/glue/Shmem.h
+++ b/ipc/glue/Shmem.h
@@ -71,18 +71,18 @@ class Shmem MOZ_FINAL
 public:
   typedef int32_t id_t;
   // Low-level wrapper around platform shmem primitives.
   typedef mozilla::ipc::SharedMemory SharedMemory;
   typedef SharedMemory::SharedMemoryType SharedMemoryType;
   struct IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead {};
 
   Shmem() :
-    mSegment(0),
-    mData(0),
+    mSegment(nullptr),
+    mData(nullptr),
     mSize(0),
     mId(0)
   {
   }
 
   Shmem(const Shmem& aOther) :
     mSegment(aOther.mSegment),
     mData(aOther.mData),
@@ -190,18 +190,18 @@ public:
   {
   }
 #else
   void RevokeRights(IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead);
 #endif
 
   void forget(IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead)
   {
-    mSegment = 0;
-    mData = 0;
+    mSegment = nullptr;
+    mData = nullptr;
     mSize = 0;
     mId = 0;
   }
 
   static SharedMemory*
   Alloc(IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead,
         size_t aNBytes,
         SharedMemoryType aType,