Address static analysis issues in SSH remoting (#4083)

* address static analysis issues
- remoteRunspaces is not used TFS:10618323
- not checking return value of ResumeThread() TFS:10618344

* fixed magic number use

* changed magic number to Uint.MaxValue
This commit is contained in:
Steve Lee
2017-06-28 16:27:54 -07:00
committed by Mike Richmond
parent b25b8df7ca
commit 40c479d071
3 changed files with 7 additions and 2 deletions
@@ -1360,7 +1360,6 @@ namespace Microsoft.PowerShell.Commands
protected void CreateHelpersForSpecifiedSSHHashComputerNames()
{
var sshConnections = ParseSSHConnectionHashTable();
var remoteRunspaces = new List<RemoteRunspace>();
foreach (var sshConnection in sshConnections)
{
var sshConnectionInfo = new SSHConnectionInfo(
@@ -2483,7 +2483,12 @@ namespace System.Management.Automation.Runspaces
// At this point, we should have a suspended process. Get the .Net Process object, resume the process, and return.
Process result = Process.GetProcessById(lpProcessInformation.dwProcessId);
PlatformInvokes.ResumeThread(lpProcessInformation.hThread);
uint returnValue = PlatformInvokes.ResumeThread(lpProcessInformation.hThread);
if (returnValue == PlatformInvokes.RESUME_THREAD_FAILED)
{
throw new Win32Exception(Marshal.GetLastWin32Error());
}
return result;
}
@@ -701,6 +701,7 @@ namespace System.Management.Automation
[DllImport(PinvokeDllNames.ResumeThreadDllName, CharSet = CharSet.Unicode, SetLastError = true)]
public static extern uint ResumeThread(IntPtr threadHandle);
internal static uint RESUME_THREAD_FAILED = System.UInt32.MaxValue; // (DWORD)-1
[DllImport(PinvokeDllNames.CreateFileDllName, CharSet = CharSet.Unicode, SetLastError = true)]
public static extern System.IntPtr CreateFileW(