Bug 1318335 - Use auto type specifier where aplicable for variable declarations to improve code readability and maintainability in ipc/. r=billm
authorAndi-Bogdan Postelnicu <bpostelnicu@mozilla.com>
Thu, 17 Nov 2016 15:07:35 +0200
changeset 324599 d27c040abf57c04727a97e9079d759d71a77cebb
parent 324598 841c964971a8741b53634a35a5ad65e7c9ddc280
child 324600 e8582a4033dcc63a0fbc529586773166fb43f9ef
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersbillm
bugs1318335
milestone53.0a1
Bug 1318335 - Use auto type specifier where aplicable for variable declarations to improve code readability and maintainability in ipc/. r=billm MozReview-Commit-ID: K4NAI8HjUd2
ipc/glue/GeckoChildProcessHost.cpp
ipc/glue/SharedMemoryBasic_mach.mm
ipc/testshell/XPCShellEnvironment.cpp
--- a/ipc/glue/GeckoChildProcessHost.cpp
+++ b/ipc/glue/GeckoChildProcessHost.cpp
@@ -963,36 +963,36 @@ GeckoChildProcessHost::PerformAsyncLaunc
     CHROMIUM_LOG(ERROR) << "parent GetTranslatedPort(1) failed.";
     return false;
   }
   MachPortSender parent_sender(child_message.GetTranslatedPort(1));
 
   if (child_message.GetTranslatedPort(2) == MACH_PORT_NULL) {
     CHROMIUM_LOG(ERROR) << "parent GetTranslatedPort(2) failed.";
   }
-  MachPortSender* parent_recv_port_memory_ack = new MachPortSender(child_message.GetTranslatedPort(2));
+  auto* parent_recv_port_memory_ack = new MachPortSender(child_message.GetTranslatedPort(2));
 
   if (child_message.GetTranslatedPort(3) == MACH_PORT_NULL) {
     CHROMIUM_LOG(ERROR) << "parent GetTranslatedPort(3) failed.";
   }
-  MachPortSender* parent_send_port_memory = new MachPortSender(child_message.GetTranslatedPort(3));
+  auto* parent_send_port_memory = new MachPortSender(child_message.GetTranslatedPort(3));
 
   MachSendMessage parent_message(/* id= */0);
   if (!parent_message.AddDescriptor(MachMsgPortDescriptor(bootstrap_port))) {
     CHROMIUM_LOG(ERROR) << "parent AddDescriptor(" << bootstrap_port << ") failed.";
     return false;
   }
 
-  ReceivePort* parent_recv_port_memory = new ReceivePort();
+  auto* parent_recv_port_memory = new ReceivePort();
   if (!parent_message.AddDescriptor(MachMsgPortDescriptor(parent_recv_port_memory->GetPort()))) {
     CHROMIUM_LOG(ERROR) << "parent AddDescriptor(" << parent_recv_port_memory->GetPort() << ") failed.";
     return false;
   }
 
-  ReceivePort* parent_send_port_memory_ack = new ReceivePort();
+  auto* parent_send_port_memory_ack = new ReceivePort();
   if (!parent_message.AddDescriptor(MachMsgPortDescriptor(parent_send_port_memory_ack->GetPort()))) {
     CHROMIUM_LOG(ERROR) << "parent AddDescriptor(" << parent_send_port_memory_ack->GetPort() << ") failed.";
     return false;
   }
 
   err = parent_sender.SendMessage(parent_message, kTimeoutMs);
   if (err != KERN_SUCCESS) {
     std::string errString = StringPrintf("0x%x %s", err, mach_error_string(err));
--- a/ipc/glue/SharedMemoryBasic_mach.mm
+++ b/ipc/glue/SharedMemoryBasic_mach.mm
@@ -145,17 +145,17 @@ SetupMachMemory(pid_t pid,
                 MachPortSender* listen_port_ack,
                 MachPortSender* send_port,
                 ReceivePort* send_port_ack,
                 bool pidIsParent)
 {
   if (pidIsParent) {
     gParentPid = pid;
   }
-  MemoryPorts* listen_ports = new MemoryPorts(listen_port_ack, listen_port);
+  auto* listen_ports = new MemoryPorts(listen_port_ack, listen_port);
   pthread_t thread;
   pthread_attr_t attr;
   pthread_attr_init(&attr);
   pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
   int err = pthread_create(&thread, &attr, PortServerThread, listen_ports);
   if (err) {
     LOG_ERROR("pthread_create failed with %x\n", err);
     return;
@@ -244,32 +244,32 @@ GetMemoryPortsForPid(pid_t pid)
       LOG_ERROR("request for ports for pid %d, but we're the chrome process\n", pid);
       return nullptr;
     }
     const MemoryPorts& parent = gMemoryCommPorts[gParentPid];
 
     // Create two receiving ports in this process to send to the parent. One will be used for
     // for listening for incoming memory to be shared, the other for getting the Handle of
     // memory we share to the other process.
-    ReceivePort* ports_in_receiver = new ReceivePort();
-    ReceivePort* ports_out_receiver = new ReceivePort();
+    auto* ports_in_receiver = new ReceivePort();
+    auto* ports_out_receiver = new ReceivePort();
     mach_port_t raw_ports_in_sender, raw_ports_out_sender;
     if (!RequestPorts(parent,
                       ports_in_receiver->GetPort(),
                       &raw_ports_in_sender,
                       &raw_ports_out_sender,
                       ports_out_receiver->GetPort(),
                       PIDPair(getpid(), pid))) {
       LOG_ERROR("failed to request ports\n");
       return nullptr;
     }
     // Our parent process sent us two ports, one is for sending new memory to, the other
     // is for replying with the Handle when we receive new memory.
-    MachPortSender* ports_in_sender = new MachPortSender(raw_ports_in_sender);
-    MachPortSender* ports_out_sender = new MachPortSender(raw_ports_out_sender);
+    auto* ports_in_sender = new MachPortSender(raw_ports_in_sender);
+    auto* ports_out_sender = new MachPortSender(raw_ports_out_sender);
     SetupMachMemory(pid,
                     ports_in_receiver,
                     ports_in_sender,
                     ports_out_sender,
                     ports_out_receiver,
                     false);
     MOZ_ASSERT(gMemoryCommPorts.find(pid) != gMemoryCommPorts.end());
   }
@@ -367,21 +367,21 @@ HandleGetPortsMessage(MachReceiveMessage
       return;
     }
 
     if (rmsg->GetTranslatedPort(1) == MACH_PORT_NULL) {
       LOG_ERROR("GetTranslatedPort(1) failed");
       return;
     }
 
-    MachPortSender* ports_in_sender = new MachPortSender(rmsg->GetTranslatedPort(0));
-    MachPortSender* ports_out_sender = new MachPortSender(rmsg->GetTranslatedPort(1));
+    auto* ports_in_sender = new MachPortSender(rmsg->GetTranslatedPort(0));
+    auto* ports_out_sender = new MachPortSender(rmsg->GetTranslatedPort(1));
 
-    ReceivePort* ports_in_receiver = new ReceivePort();
-    ReceivePort* ports_out_receiver = new ReceivePort();
+    auto* ports_in_receiver = new ReceivePort();
+    auto* ports_out_receiver = new ReceivePort();
     if (SendReturnPortsMsg(ports->mSender, ports_in_receiver->GetPort(), ports_out_receiver->GetPort())) {
       SetupMachMemory(pid_pair->mRequester,
                       ports_out_receiver,
                       ports_out_sender,
                       ports_in_sender,
                       ports_in_receiver,
                       false);
     }
--- a/ipc/testshell/XPCShellEnvironment.cpp
+++ b/ipc/testshell/XPCShellEnvironment.cpp
@@ -373,17 +373,17 @@ XPCShellEnvironment::ProcessFile(JSConte
 
     fprintf(stdout, "\n");
 }
 
 // static
 XPCShellEnvironment*
 XPCShellEnvironment::CreateEnvironment()
 {
-    XPCShellEnvironment* env = new XPCShellEnvironment();
+    auto* env = new XPCShellEnvironment();
     if (env && !env->Init()) {
         delete env;
         env = nullptr;
     }
     return env;
 }
 
 XPCShellEnvironment::XPCShellEnvironment()