Bug 1318335 - Converts for(...; ...; ...) loops to use the new range-based loops in C++11 in ipc/. r=billm
authorAndi-Bogdan Postelnicu <bpostelnicu@mozilla.com>
Thu, 17 Nov 2016 15:06:25 +0200
changeset 324598 841c964971a8741b53634a35a5ad65e7c9ddc280
parent 324597 53d1dbd5e9059e8fb7319c9a13ec43bcc41f6383
child 324599 d27c040abf57c04727a97e9079d759d71a77cebb
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersbillm
bugs1318335
milestone53.0a1
Bug 1318335 - Converts for(...; ...; ...) loops to use the new range-based loops in C++11 in ipc/. r=billm MozReview-Commit-ID: CXLSBRhANNW
ipc/glue/SharedMemoryBasic_mach.mm
--- a/ipc/glue/SharedMemoryBasic_mach.mm
+++ b/ipc/glue/SharedMemoryBasic_mach.mm
@@ -446,25 +446,25 @@ SharedMemoryBasic::SetupMachMemory(pid_t
   mozilla::ipc::SetupMachMemory(pid, listen_port, listen_port_ack, send_port, send_port_ack, pidIsParent);
 }
 
 void
 SharedMemoryBasic::Shutdown()
 {
   StaticMutexAutoLock smal(gMutex);
 
-  for (auto it = gThreads.begin(); it != gThreads.end(); ++it) {
+  for (auto& thread : gThreads) {
     MachSendMessage shutdownMsg(kShutdownMsg);
-    it->second.mPorts->mReceiver->SendMessageToSelf(shutdownMsg, kTimeout);
+    thread.second.mPorts->mReceiver->SendMessageToSelf(shutdownMsg, kTimeout);
   }
   gThreads.clear();
 
-  for (auto it = gMemoryCommPorts.begin(); it != gMemoryCommPorts.end(); ++it) {
-    delete it->second.mSender;
-    delete it->second.mReceiver;
+  for (auto& memoryCommPort : gMemoryCommPorts) {
+    delete memoryCommPort.second.mSender;
+    delete memoryCommPort.second.mReceiver;
   }
   gMemoryCommPorts.clear();
 }
 
 void
 SharedMemoryBasic::CleanupForPid(pid_t pid)
 {
   if (gThreads.find(pid) == gThreads.end()) {
@@ -475,21 +475,21 @@ SharedMemoryBasic::CleanupForPid(pid_t p
   kern_return_t ret = listeningThread.mPorts->mReceiver->SendMessageToSelf(shutdownMsg, kTimeout);
   if (ret != KERN_SUCCESS) {
     LOG_ERROR("sending shutdown msg failed %s %x\n", mach_error_string(ret), ret);
   }
   gThreads.erase(pid);
 
   if (gParentPid == 0) {
     // We're the parent. Broadcast the cleanup message to everyone else.
-    for (auto it = gMemoryCommPorts.begin(); it != gMemoryCommPorts.end(); ++it) {
+    for (auto& memoryCommPort : gMemoryCommPorts) {
       MachSendMessage msg(kCleanupMsg);
       msg.SetData(&pid, sizeof(pid));
       // We don't really care if this fails, we could be trying to send to an already shut down proc
-      it->second.mSender->SendMessage(msg, kTimeout);
+      memoryCommPort.second.mSender->SendMessage(msg, kTimeout);
     }
   }
 
   MemoryPorts& ports = gMemoryCommPorts[pid];
   delete ports.mSender;
   delete ports.mReceiver;
   gMemoryCommPorts.erase(pid);
 }