Bug 1338086 - Remove useless else blocks in order to reduce complexity in security/sandbox/linux/ r=gcp
authorSylvestre Ledru <sledru@mozilla.com>
Thu, 09 Feb 2017 10:56:05 +0100
changeset 389666 3096b29c3a5bb448c938fd99b4b0ff8fc1baaf3e
parent 389665 cd8319b71afd713b3d6c64d2751bd32ae0356235
child 389667 aea7a26ac8fc4de4079d4091dc81e43b6a9732dd
push id7198
push userjlorenzo@mozilla.com
push dateTue, 18 Apr 2017 12:07:49 +0000
treeherdermozilla-beta@d57aa49c3948 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgcp
bugs1338086
milestone54.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 1338086 - Remove useless else blocks in order to reduce complexity in security/sandbox/linux/ r=gcp MozReview-Commit-ID: 5UWtAe6THd6
security/sandbox/linux/SandboxChroot.cpp
security/sandbox/linux/broker/SandboxBroker.cpp
--- a/security/sandbox/linux/SandboxChroot.cpp
+++ b/security/sandbox/linux/SandboxChroot.cpp
@@ -44,27 +44,27 @@ SandboxChroot::~SandboxChroot()
 bool
 SandboxChroot::SendCommand(Command aComm)
 {
   MOZ_ALWAYS_ZERO(pthread_mutex_lock(&mMutex));
   if (mCommand == NO_THREAD) {
     MOZ_RELEASE_ASSERT(aComm == JUST_EXIT);
     MOZ_ALWAYS_ZERO(pthread_mutex_unlock(&mMutex));
     return false;
-  } else {
-    MOZ_ASSERT(mCommand == NO_COMMAND);
-    mCommand = aComm;
-    MOZ_ALWAYS_ZERO(pthread_mutex_unlock(&mMutex));
-    MOZ_ALWAYS_ZERO(pthread_cond_signal(&mWakeup));
-    void *retval;
-    if (pthread_join(mThread, &retval) != 0 || retval != nullptr) {
-      MOZ_CRASH("Failed to stop privileged chroot thread");
-    }
-    MOZ_ASSERT(mCommand == NO_THREAD);
   }
+  MOZ_ASSERT(mCommand == NO_COMMAND);
+  mCommand = aComm;
+  MOZ_ALWAYS_ZERO(pthread_mutex_unlock(&mMutex));
+  MOZ_ALWAYS_ZERO(pthread_cond_signal(&mWakeup));
+  void *retval;
+  if (pthread_join(mThread, &retval) != 0 || retval != nullptr) {
+    MOZ_CRASH("Failed to stop privileged chroot thread");
+  }
+  MOZ_ASSERT(mCommand == NO_THREAD);
+
   return true;
 }
 
 static void
 AlwaysClose(int fd)
 {
   if (IGNORE_EINTR(close(fd)) != 0) {
     SANDBOX_LOG_ERROR("close: %s", strerror(errno));
--- a/security/sandbox/linux/broker/SandboxBroker.cpp
+++ b/security/sandbox/linux/broker/SandboxBroker.cpp
@@ -406,17 +406,18 @@ DoStat(const char* aPath, void* aBuff, i
 }
 
 static int
 DoLink(const char* aPath, const char* aPath2,
        SandboxBrokerCommon::Operation aOper)
 {
   if (aOper == SandboxBrokerCommon::Operation::SANDBOX_FILE_LINK) {
     return link(aPath, aPath2);
-  } else if (aOper == SandboxBrokerCommon::Operation::SANDBOX_FILE_SYMLINK) {
+  }
+  if (aOper == SandboxBrokerCommon::Operation::SANDBOX_FILE_SYMLINK) {
     return symlink(aPath, aPath2);
   }
   MOZ_CRASH("SandboxBroker: Unknown link operation");
 }
 
 size_t
 SandboxBroker::ConvertToRealPath(char* aPath, size_t aBufSize, size_t aPathLen)
 {