Bug 1260672: Use |UniquePtr| for Gonk alarms, r=gsvelto
authorThomas Zimmermann <tdz@users.sourceforge.net>
Wed, 30 Mar 2016 13:18:00 +0200
changeset 291050 1fde84b4a3a104907c16073d52383f0c75976341
parent 291049 90e08b7ccdd35136009da55794590d6a356f6e1a
child 291051 860aa4598f135cae09f9d69b33f3cbc81f26b6d4
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgsvelto
bugs1260672
milestone48.0a1
Bug 1260672: Use |UniquePtr| for Gonk alarms, r=gsvelto
hal/gonk/GonkHal.cpp
--- a/hal/gonk/GonkHal.cpp
+++ b/hal/gonk/GonkHal.cpp
@@ -1122,17 +1122,17 @@ EnableAlarm()
   MOZ_ASSERT(!sAlarmData);
 
   int alarmFd = open("/dev/alarm", O_RDWR);
   if (alarmFd < 0) {
     HAL_LOG("Failed to open alarm device: %s.", strerror(errno));
     return false;
   }
 
-  nsAutoPtr<AlarmData> alarmData(new AlarmData(alarmFd));
+  UniquePtr<AlarmData> alarmData = MakeUnique<AlarmData>(alarmFd);
 
   struct sigaction actions;
   memset(&actions, 0, sizeof(actions));
   sigemptyset(&actions.sa_mask);
   actions.sa_flags = 0;
   actions.sa_handler = ShutDownAlarm;
   if (sigaction(SIGUSR1, &actions, nullptr)) {
     HAL_LOG("Failed to set SIGUSR1 signal for alarm-watcher thread.");
@@ -1141,25 +1141,25 @@ EnableAlarm()
 
   pthread_attr_t attr;
   pthread_attr_init(&attr);
   pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
 
   int status = pthread_create(&sAlarmFireWatcherThread, &attr, WaitForAlarm,
                               alarmData.get());
   if (status) {
-    alarmData = nullptr;
+    alarmData.reset();
     HAL_LOG("Failed to create alarm-watcher thread. Status: %d.", status);
     return false;
   }
 
   pthread_attr_destroy(&attr);
 
   // The thread owns this now.  We only hold a pointer.
-  sAlarmData = alarmData.forget();
+  sAlarmData = alarmData.release();
   return true;
 }
 
 void
 DisableAlarm()
 {
   MOZ_ASSERT(sAlarmData);
 
@@ -1292,17 +1292,17 @@ OomVictimLogger::Observe(
   }
 
 #ifndef KLOG_SIZE_BUFFER
   // Upstream bionic in commit
   // e249b059637b49a285ed9f58a2a18bfd054e5d95
   // deprecated the old klog defs.
   // Our current bionic does not hit this
   // change yet so handle the future change.
-  // (ICS doesn't have KLOG_SIZE_BUFFER but 
+  // (ICS doesn't have KLOG_SIZE_BUFFER but
   // JB and onwards does.)
   #define KLOG_SIZE_BUFFER KLOG_WRITE
 #endif
   // Retreive kernel log
   int msg_buf_size = klogctl(KLOG_SIZE_BUFFER, NULL, 0);
   UniqueFreePtr<char> msg_buf(static_cast<char *>(malloc(msg_buf_size + 1)));
   int read_size = klogctl(KLOG_READ_ALL, msg_buf.get(), msg_buf_size);
 
@@ -1458,17 +1458,17 @@ private:
            NS_LITERAL_CSTRING("cgroup.procs");
   }
 
   nsCString MemCGroupProcsFilename()
   {
     nsCString cgroupName = mGroup;
 
     /* If mGroup is empty, our cgroup.procs file is the root procs file,
-     * located at /sys/fs/cgroup/memory/cgroup.procs.  Otherwise our procs 
+     * located at /sys/fs/cgroup/memory/cgroup.procs.  Otherwise our procs
      * file is /sys/fs/cgroup/memory/NAME/cgroup.procs. */
 
     if (!mGroup.IsEmpty()) {
       cgroupName.AppendLiteral("/");
     }
 
     return NS_LITERAL_CSTRING("/sys/fs/cgroup/memory/") + cgroupName +
            NS_LITERAL_CSTRING("cgroup.procs");