Bug 1338086 - Remove useless else blocks in order to reduce complexity in security/sandbox/linux/ r?gcp draft
authorSylvestre Ledru <sledru@mozilla.com>
Thu, 09 Feb 2017 10:56:05 +0100
changeset 484412 2cc9e578b620f057c2c69006508fffc183deef59
parent 484411 abd4456d4ea9027b64a5330fc23711679bd7a8a9
child 484413 1dbc4995b356600ba011d63d9bcfbdb458be71b4
push id45470
push userbmo:sledru@mozilla.com
push dateWed, 15 Feb 2017 08:57:47 +0000
reviewersgcp
bugs1338086
milestone54.0a1
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)
 {