Bug 1081871 - Part 1 - Remove dead code and do some minor code style cleanups. r=dhylands
authorGabriele Svelto <gsvelto@mozilla.com>
Thu, 08 Jan 2015 15:39:38 +0100
changeset 222901 a13166f0d914a85a083e5e22fc057be76538f0d8
parent 222900 00fc776b6f556570feb942246093f8f2b6a6f1c7
child 222902 59452425e446c374a486169652abfff985df6759
push id10731
push usercbook@mozilla.com
push dateFri, 09 Jan 2015 14:51:37 +0000
treeherderfx-team@e6756043d930 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdhylands
bugs1081871
milestone37.0a1
Bug 1081871 - Part 1 - Remove dead code and do some minor code style cleanups. r=dhylands
hal/gonk/GonkHal.cpp
--- a/hal/gonk/GonkHal.cpp
+++ b/hal/gonk/GonkHal.cpp
@@ -595,38 +595,16 @@ GetCurrentBatteryInformation(hal::Batter
   }
 }
 
 namespace {
 
 /**
  * RAII class to help us remember to close file descriptors.
  */
-const char *wakeLockFilename = "/sys/power/wake_lock";
-const char *wakeUnlockFilename = "/sys/power/wake_unlock";
-
-template<ssize_t n>
-bool ReadFromFile(const char *filename, char (&buf)[n])
-{
-  int fd = open(filename, O_RDONLY);
-  ScopedClose autoClose(fd);
-  if (fd < 0) {
-    HAL_LOG("Unable to open file %s.", filename);
-    return false;
-  }
-
-  ssize_t numRead = read(fd, buf, n);
-  if (numRead < 0) {
-    HAL_LOG("Error reading from file %s.", filename);
-    return false;
-  }
-
-  buf[std::min(numRead, n - 1)] = '\0';
-  return true;
-}
 
 bool WriteToFile(const char *filename, const char *toWrite)
 {
   int fd = open(filename, O_WRONLY);
   ScopedClose autoClose(fd);
   if (fd < 0) {
     HAL_LOG("Unable to open file %s.", filename);
     return false;
@@ -742,16 +720,19 @@ SetScreenBrightness(double brightness)
   }
 }
 
 static Monitor* sInternalLockCpuMonitor = nullptr;
 
 static void
 UpdateCpuSleepState()
 {
+  const char *wakeLockFilename = "/sys/power/wake_lock";
+  const char *wakeUnlockFilename = "/sys/power/wake_unlock";
+
   sInternalLockCpuMonitor->AssertCurrentThreadOwns();
   bool allowed = sCpuSleepAllowed && !sInternalLockCpuCount;
   WriteToFile(allowed ? wakeUnlockFilename : wakeLockFilename, "gecko");
 }
 
 static void
 InternalLockCpu() {
   MonitorAutoLock monitor(*sInternalLockCpuMonitor);
@@ -1253,17 +1234,16 @@ OomVictimLogger::Observe(
          after_float == ']') {
       if (lineTimestamp <= mLastLineChecked) {
         continue;
       }
 
       lineTimestampFound = true;
       mLastLineChecked = lineTimestamp;
     }
-      
 
     // Log interesting lines
     for (size_t i = 0; i < regex_count; i++) {
       int matching = !regexec(&(mRegexes[i]), line_begin, 0, NULL, 0);
       if (matching) {
         // Log content of kernel message. We try to skip the ], but if for
         // some reason (most likely due to buffer overflow/wraparound), we
         // can't find the ] then we just log the entire line.