[Lldb-commits] [lldb] r235515 - MI Refactor CMIUtilSystemWindows::GetExecutablesPath()

Ilia K ki.stfu at gmail.com
Wed Apr 22 08:43:43 PDT 2015


Author: ki.stfu
Date: Wed Apr 22 10:43:43 2015
New Revision: 235515

URL: http://llvm.org/viewvc/llvm-project?rev=235515&view=rev
Log:
MI Refactor CMIUtilSystemWindows::GetExecutablesPath()

Summary:
My understanding of the Windows API call GetLastError() is that it should only be checked when ::GetModuleFileName()  returns 0 on error.
Otherwise GetExecutablesPath() could return an error despite nLen being valid if GetLastError() was inconsistent.
Patch updates function to only call GetOSLastError() when nLen == 0

Patch from ewan at codeplay.com

Reviewers: EwanCrawford

Subscribers: lldb-commits, deepak2427

Differential Revision: http://reviews.llvm.org/D9154

Modified:
    lldb/trunk/tools/lldb-mi/MIUtilSystemWindows.cpp

Modified: lldb/trunk/tools/lldb-mi/MIUtilSystemWindows.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MIUtilSystemWindows.cpp?rev=235515&r1=235514&r2=235515&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MIUtilSystemWindows.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MIUtilSystemWindows.cpp Wed Apr 22 10:43:43 2015
@@ -110,15 +110,13 @@ CMIUtilSystemWindows::GetExecutablesPath
     bool bOk = MIstatus::success;
     HMODULE hModule = ::GetModuleHandle(nullptr);
     char pPath[MAX_PATH];
-    const DWORD nLen = ::GetModuleFileName(hModule, &pPath[0], MAX_PATH);
-    const CMIUtilString strLastErr(GetOSLastError());
-    if ((nLen != 0) && (strLastErr == "Unknown OS error"))
-        vrwFileNamePath = &pPath[0];
-    else
+    if (!::GetModuleFileName(hModule, &pPath[0], MAX_PATH))
     {
         bOk = MIstatus::failure;
-        vrwFileNamePath = strLastErr;
+        vrwFileNamePath = GetOSLastError();
     }
+    else
+        vrwFileNamePath = &pPath[0];
 
     return bOk;
 }





More information about the lldb-commits mailing list