Ran the static analyzer on the codebase and found a few things.

llvm-svn: 160338
diff --git a/lldb/tools/debugserver/source/MacOSX/MachException.cpp b/lldb/tools/debugserver/source/MacOSX/MachException.cpp
index ead512e..9856867 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachException.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/MachException.cpp
@@ -122,7 +122,6 @@
     mach_msg_type_number_t *new_stateCnt
 )
 {
-    kern_return_t kret;
     if (DNBLogCheckLogBit(LOG_EXCEPTIONS))
     {
         DNBLogThreaded("::%s ( exc_port = 0x%4.4x, thd_port = 0x%4.4x, tsk_port = 0x%4.4x, exc_type = %d ( %s ), exc_data[%d] = { 0x%llx, 0x%llx })",
@@ -135,8 +134,8 @@
             (uint64_t)(exc_data_count > 0 ? exc_data[0] : 0xBADDBADD),
             (uint64_t)(exc_data_count > 1 ? exc_data[1] : 0xBADDBADD));
     }
-    kret = mach_port_deallocate (mach_task_self (), task_port);
-    kret = mach_port_deallocate (mach_task_self (), thread_port);
+    mach_port_deallocate (mach_task_self (), task_port);
+    mach_port_deallocate (mach_task_self (), thread_port);
 
     return KERN_FAILURE;
 }
@@ -229,7 +228,7 @@
         if (desc < end_desc)
         {
             const char *sig_str = SysSignal::Name(soft_signal);
-            desc += snprintf(desc, end_desc - desc, " EXC_SOFT_SIGNAL( %i ( %s ))", soft_signal, sig_str ? sig_str : "unknown signal");
+            snprintf(desc, end_desc - desc, " EXC_SOFT_SIGNAL( %i ( %s ))", soft_signal, sig_str ? sig_str : "unknown signal");
         }
     }
     else
diff --git a/lldb/tools/debugserver/source/MacOSX/MachProcess.cpp b/lldb/tools/debugserver/source/MacOSX/MachProcess.cpp
index 4d78778..2dcbb67 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachProcess.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/MachProcess.cpp
@@ -421,8 +421,7 @@
     {
         DisableAllBreakpoints (true);
         DisableAllWatchpoints (true);
-        // The static analyzer complains about this, but just leave the following line in.
-         clear_bps_and_wps = false;
+        //clear_bps_and_wps = false;
     }
     uint32_t thread_idx = m_thread_list.GetThreadIndexForThreadStoppedWithSignal (SIGSTOP);
     if (thread_idx_ptr)
@@ -1865,18 +1864,20 @@
 
         // If our parent is setgid, lets make sure we don't inherit those
         // extra powers due to nepotism.
-        ::setgid (getgid ());
+        if (::setgid (getgid ()) == 0)
+        {
 
-        // Let the child have its own process group. We need to execute
-        // this call in both the child and parent to avoid a race condition
-        // between the two processes.
-        ::setpgid (0, 0);    // Set the child process group to match its pid
+            // Let the child have its own process group. We need to execute
+            // this call in both the child and parent to avoid a race condition
+            // between the two processes.
+            ::setpgid (0, 0);    // Set the child process group to match its pid
 
-        // Sleep a bit to before the exec call
-        ::sleep (1);
+            // Sleep a bit to before the exec call
+            ::sleep (1);
 
-        // Turn this process into
-        ::execv (path, (char * const *)argv);
+            // Turn this process into
+            ::execv (path, (char * const *)argv);
+        }
         // Exit with error code. Child process should have taken
         // over in above exec call and if the exec fails it will
         // exit the child process below.
diff --git a/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp b/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp
index b8044fe..8e35069 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp
@@ -470,9 +470,9 @@
 uint32_t
 MachThreadList::EnableHardwareWatchpoint (const DNBBreakpoint* wp) const
 {
+    uint32_t hw_index = INVALID_NUB_HW_INDEX;
     if (wp != NULL)
     {
-        uint32_t hw_index;
         PTHREAD_MUTEX_LOCKER (locker, m_threads_mutex);
         const uint32_t num_threads = m_threads.size();
         for (uint32_t idx = 0; idx < num_threads; ++idx)
@@ -492,9 +492,8 @@
         // Use an arbitrary thread to signal the completion of our transaction.
         if (num_threads)
             m_threads[0]->HardwareWatchpointStateChanged();
-        return hw_index;
     }
-    return INVALID_NUB_HW_INDEX;
+    return hw_index;
 }
 
 bool