summaryrefslogtreecommitdiff
path: root/utils/KillTheDoctor
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2010-12-06 04:28:01 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2010-12-06 04:28:01 +0000
commit93e5ec2cba6656417c9502ad80709aeca5eac968 (patch)
tree84f43d69ad02577ff49ea5ca61779d461eba474d /utils/KillTheDoctor
parenta1d942fb70bfb76a3e6e2e2104b7ddecdcaf1244 (diff)
downloadllvm-93e5ec2cba6656417c9502ad80709aeca5eac968.tar.gz
llvm-93e5ec2cba6656417c9502ad80709aeca5eac968.tar.bz2
llvm-93e5ec2cba6656417c9502ad80709aeca5eac968.tar.xz
KillTheDoctor: Cleanup error_code usage.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120986 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/KillTheDoctor')
-rw-r--r--utils/KillTheDoctor/KillTheDoctor.cpp32
1 files changed, 14 insertions, 18 deletions
diff --git a/utils/KillTheDoctor/KillTheDoctor.cpp b/utils/KillTheDoctor/KillTheDoctor.cpp
index 282cfda8a6..a623d6af8d 100644
--- a/utils/KillTheDoctor/KillTheDoctor.cpp
+++ b/utils/KillTheDoctor/KillTheDoctor.cpp
@@ -164,10 +164,6 @@ namespace {
typedef ScopedHandle<ThreadHandle> ThreadScopedHandle;
typedef ScopedHandle<TokenHandle> TokenScopedHandle;
typedef ScopedHandle<FileHandle> FileScopedHandle;
-
- error_code get_windows_last_error() {
- return make_error_code(windows_error(::GetLastError()));
- }
}
static error_code GetFileNameFromHandle(HANDLE FileHandle,
@@ -181,7 +177,7 @@ static error_code GetFileNameFromHandle(HANDLE FileHandle,
Sucess = ::GetFileSizeEx(FileHandle, &FileSize);
if (!Sucess)
- return get_windows_last_error();
+ return windows_error(::GetLastError());
// Create a file mapping object.
FileMappingScopedHandle FileMapping(
@@ -193,14 +189,14 @@ static error_code GetFileNameFromHandle(HANDLE FileHandle,
NULL));
if (!FileMapping)
- return get_windows_last_error();
+ return windows_error(::GetLastError());
// Create a file mapping to get the file name.
MappedViewOfFileScopedHandle MappedFile(
::MapViewOfFile(FileMapping, FILE_MAP_READ, 0, 0, 1));
if (!MappedFile)
- return get_windows_last_error();
+ return windows_error(::GetLastError());
Sucess = ::GetMappedFileNameA(::GetCurrentProcess(),
MappedFile,
@@ -208,7 +204,7 @@ static error_code GetFileNameFromHandle(HANDLE FileHandle,
array_lengthof(Filename) - 1);
if (!Sucess)
- return get_windows_last_error();
+ return windows_error(::GetLastError());
else {
Name = Filename;
return windows_error::success;
@@ -256,10 +252,10 @@ static std::string FindProgram(const std::string &Program, error_code &ec) {
PathName,
NULL);
if (length == 0)
- ec = get_windows_last_error();
+ ec = windows_error(::GetLastError());
else if (length > array_lengthof(PathName)) {
// This may have been the file, return with error.
- ec = error_code(windows_error::buffer_overflow);
+ ec = windows_error::buffer_overflow;
break;
} else {
// We found the path! Return it.
@@ -279,7 +275,7 @@ static error_code EnableDebugPrivileges() {
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
&TokenHandle);
if (!success)
- return error_code(::GetLastError(), system_category());
+ return windows_error(::GetLastError());
TokenScopedHandle Token(TokenHandle);
TOKEN_PRIVILEGES TokenPrivileges;
@@ -289,7 +285,7 @@ static error_code EnableDebugPrivileges() {
SE_DEBUG_NAME,
&LocallyUniqueID);
if (!success)
- return error_code(::GetLastError(), system_category());
+ return windows_error(::GetLastError());
TokenPrivileges.PrivilegeCount = 1;
TokenPrivileges.Privileges[0].Luid = LocallyUniqueID;
@@ -303,7 +299,7 @@ static error_code EnableDebugPrivileges() {
NULL);
// The value of success is basically useless. Either way we are just returning
// the value of ::GetLastError().
- return error_code(::GetLastError(), system_category());
+ return windows_error(::GetLastError());
}
static StringRef ExceptionCodeToString(DWORD ExceptionCode) {
@@ -404,7 +400,7 @@ int main(int argc, char **argv) {
&ProcessInfo);
if (!success) {
errs() << ToolName << ": Failed to run program: '" << ProgramToRun
- << "': " << error_code(::GetLastError(), system_category()).message()
+ << "': " << error_code(windows_error(::GetLastError())).message()
<< '\n';
return -1;
}
@@ -432,7 +428,7 @@ int main(int argc, char **argv) {
&KernelTime,
&UserTime);
if (!success) {
- ec = error_code(::GetLastError(), system_category());
+ ec = windows_error(::GetLastError());
errs() << ToolName << ": Failed to get process times: "
<< ec.message() << '\n';
@@ -467,9 +463,9 @@ int main(int argc, char **argv) {
success = WaitForDebugEvent(&DebugEvent, TimeLeft);
if (!success) {
- ec = error_code(::GetLastError(), system_category());
+ ec = windows_error(::GetLastError());
- if (ec == error_condition(errc::timed_out)) {
+ if (ec == errc::timed_out) {
errs() << ToolName << ": Process timed out.\n";
::TerminateProcess(ProcessInfo.hProcess, -1);
// Otherwise other stuff starts failing...
@@ -586,7 +582,7 @@ int main(int argc, char **argv) {
DebugEvent.dwThreadId,
dwContinueStatus);
if (!success) {
- ec = error_code(::GetLastError(), system_category());
+ ec = windows_error(::GetLastError());
errs() << ToolName << ": Failed to continue debugging program: '"
<< ProgramToRun << "': " << ec.message() << '\n';
return -1;