diff options
author | Zachary Turner <zturner@google.com> | 2017-05-12 04:51:55 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2017-05-12 04:51:55 +0000 |
commit | 97206d572797bddc1bba71bb1c18c97f19d69053 (patch) | |
tree | fdf21d24485672cf97c800264d135b9d5d2ecdce /lldb/source/Host/windows/PipeWindows.cpp | |
parent | 3086b45a2fae833e8419885e78c598d936cc6429 (diff) | |
download | bcm5719-llvm-97206d572797bddc1bba71bb1c18c97f19d69053.tar.gz bcm5719-llvm-97206d572797bddc1bba71bb1c18c97f19d69053.zip |
Rename Error -> Status.
This renames the LLDB error class to Status, as discussed
on the lldb-dev mailing list.
A change of this magnitude cannot easily be done without
find and replace, but that has potential to catch unwanted
occurrences of common strings such as "Error". Every effort
was made to find all the obvious things such as the word "Error"
appearing in a string, etc, but it's possible there are still
some lingering occurences left around. Hopefully nothing too
serious.
llvm-svn: 302872
Diffstat (limited to 'lldb/source/Host/windows/PipeWindows.cpp')
-rw-r--r-- | lldb/source/Host/windows/PipeWindows.cpp | 78 |
1 files changed, 40 insertions, 38 deletions
diff --git a/lldb/source/Host/windows/PipeWindows.cpp b/lldb/source/Host/windows/PipeWindows.cpp index 407f0468e6c..e8f4753d11e 100644 --- a/lldb/source/Host/windows/PipeWindows.cpp +++ b/lldb/source/Host/windows/PipeWindows.cpp @@ -39,7 +39,7 @@ PipeWindows::PipeWindows() { PipeWindows::~PipeWindows() { Close(); } -Error PipeWindows::CreateNew(bool child_process_inherit) { +Status PipeWindows::CreateNew(bool child_process_inherit) { // Even for anonymous pipes, we open a named pipe. This is because you cannot // get // overlapped i/o on Windows without using a named pipe. So we synthesize a @@ -54,12 +54,13 @@ Error PipeWindows::CreateNew(bool child_process_inherit) { return CreateNew(pipe_name.c_str(), child_process_inherit); } -Error PipeWindows::CreateNew(llvm::StringRef name, bool child_process_inherit) { +Status PipeWindows::CreateNew(llvm::StringRef name, + bool child_process_inherit) { if (name.empty()) - return Error(ERROR_INVALID_PARAMETER, eErrorTypeWin32); + return Status(ERROR_INVALID_PARAMETER, eErrorTypeWin32); if (CanRead() || CanWrite()) - return Error(ERROR_ALREADY_EXISTS, eErrorTypeWin32); + return Status(ERROR_ALREADY_EXISTS, eErrorTypeWin32); std::string pipe_path = "\\\\.\\Pipe\\"; pipe_path.append(name); @@ -71,13 +72,13 @@ Error PipeWindows::CreateNew(llvm::StringRef name, bool child_process_inherit) { pipe_path.c_str(), PIPE_ACCESS_INBOUND | read_mode, PIPE_TYPE_BYTE | PIPE_WAIT, 1, 1024, 1024, 120 * 1000, NULL); if (INVALID_HANDLE_VALUE == m_read) - return Error(::GetLastError(), eErrorTypeWin32); + return Status(::GetLastError(), eErrorTypeWin32); m_read_fd = _open_osfhandle((intptr_t)m_read, _O_RDONLY); ZeroMemory(&m_read_overlapped, sizeof(m_read_overlapped)); m_read_overlapped.hEvent = ::CreateEvent(nullptr, TRUE, FALSE, nullptr); // Open the write end of the pipe. - Error result = OpenNamedPipe(name, child_process_inherit, false); + Status result = OpenNamedPipe(name, child_process_inherit, false); if (!result.Success()) { CloseReadFileDescriptor(); return result; @@ -86,11 +87,11 @@ Error PipeWindows::CreateNew(llvm::StringRef name, bool child_process_inherit) { return result; } -Error PipeWindows::CreateWithUniqueName(llvm::StringRef prefix, - bool child_process_inherit, - llvm::SmallVectorImpl<char> &name) { +Status PipeWindows::CreateWithUniqueName(llvm::StringRef prefix, + bool child_process_inherit, + llvm::SmallVectorImpl<char> &name) { llvm::SmallString<128> pipe_name; - Error error; + Status error; ::UUID unique_id; RPC_CSTR unique_string; RPC_STATUS status = ::UuidCreate(&unique_id); @@ -110,27 +111,28 @@ Error PipeWindows::CreateWithUniqueName(llvm::StringRef prefix, return error; } -Error PipeWindows::OpenAsReader(llvm::StringRef name, - bool child_process_inherit) { +Status PipeWindows::OpenAsReader(llvm::StringRef name, + bool child_process_inherit) { if (CanRead() || CanWrite()) - return Error(ERROR_ALREADY_EXISTS, eErrorTypeWin32); + return Status(ERROR_ALREADY_EXISTS, eErrorTypeWin32); return OpenNamedPipe(name, child_process_inherit, true); } -Error PipeWindows::OpenAsWriterWithTimeout( - llvm::StringRef name, bool child_process_inherit, - const std::chrono::microseconds &timeout) { +Status +PipeWindows::OpenAsWriterWithTimeout(llvm::StringRef name, + bool child_process_inherit, + const std::chrono::microseconds &timeout) { if (CanRead() || CanWrite()) - return Error(ERROR_ALREADY_EXISTS, eErrorTypeWin32); + return Status(ERROR_ALREADY_EXISTS, eErrorTypeWin32); return OpenNamedPipe(name, child_process_inherit, false); } -Error PipeWindows::OpenNamedPipe(llvm::StringRef name, - bool child_process_inherit, bool is_read) { +Status PipeWindows::OpenNamedPipe(llvm::StringRef name, + bool child_process_inherit, bool is_read) { if (name.empty()) - return Error(ERROR_INVALID_PARAMETER, eErrorTypeWin32); + return Status(ERROR_INVALID_PARAMETER, eErrorTypeWin32); assert(is_read ? !CanRead() : !CanWrite()); @@ -144,7 +146,7 @@ Error PipeWindows::OpenNamedPipe(llvm::StringRef name, m_read = ::CreateFileA(pipe_path.c_str(), GENERIC_READ, 0, &attributes, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL); if (INVALID_HANDLE_VALUE == m_read) - return Error(::GetLastError(), eErrorTypeWin32); + return Status(::GetLastError(), eErrorTypeWin32); m_read_fd = _open_osfhandle((intptr_t)m_read, _O_RDONLY); @@ -154,14 +156,14 @@ Error PipeWindows::OpenNamedPipe(llvm::StringRef name, m_write = ::CreateFileA(pipe_path.c_str(), GENERIC_WRITE, 0, &attributes, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL); if (INVALID_HANDLE_VALUE == m_write) - return Error(::GetLastError(), eErrorTypeWin32); + return Status(::GetLastError(), eErrorTypeWin32); m_write_fd = _open_osfhandle((intptr_t)m_write, _O_WRONLY); ZeroMemory(&m_write_overlapped, sizeof(m_write_overlapped)); } - return Error(); + return Status(); } int PipeWindows::GetReadFileDescriptor() const { return m_read_fd; } @@ -217,7 +219,7 @@ void PipeWindows::Close() { CloseWriteFileDescriptor(); } -Error PipeWindows::Delete(llvm::StringRef name) { return Error(); } +Status PipeWindows::Delete(llvm::StringRef name) { return Status(); } bool PipeWindows::CanRead() const { return (m_read != INVALID_HANDLE_VALUE); } @@ -229,18 +231,18 @@ PipeWindows::GetReadNativeHandle() { return m_read; } HANDLE PipeWindows::GetWriteNativeHandle() { return m_write; } -Error PipeWindows::ReadWithTimeout(void *buf, size_t size, - const std::chrono::microseconds &duration, - size_t &bytes_read) { +Status PipeWindows::ReadWithTimeout(void *buf, size_t size, + const std::chrono::microseconds &duration, + size_t &bytes_read) { if (!CanRead()) - return Error(ERROR_INVALID_HANDLE, eErrorTypeWin32); + return Status(ERROR_INVALID_HANDLE, eErrorTypeWin32); bytes_read = 0; DWORD sys_bytes_read = size; BOOL result = ::ReadFile(m_read, buf, sys_bytes_read, &sys_bytes_read, &m_read_overlapped); if (!result && GetLastError() != ERROR_IO_PENDING) - return Error(::GetLastError(), eErrorTypeWin32); + return Status(::GetLastError(), eErrorTypeWin32); DWORD timeout = (duration == std::chrono::microseconds::zero()) ? INFINITE @@ -263,33 +265,33 @@ Error PipeWindows::ReadWithTimeout(void *buf, size_t size, failed = false; } if (failed) - return Error(failure_error, eErrorTypeWin32); + return Status(failure_error, eErrorTypeWin32); } // Now we call GetOverlappedResult setting bWait to false, since we've already // waited // as long as we're willing to. if (!GetOverlappedResult(m_read, &m_read_overlapped, &sys_bytes_read, FALSE)) - return Error(::GetLastError(), eErrorTypeWin32); + return Status(::GetLastError(), eErrorTypeWin32); bytes_read = sys_bytes_read; - return Error(); + return Status(); } -Error PipeWindows::Write(const void *buf, size_t num_bytes, - size_t &bytes_written) { +Status PipeWindows::Write(const void *buf, size_t num_bytes, + size_t &bytes_written) { if (!CanWrite()) - return Error(ERROR_INVALID_HANDLE, eErrorTypeWin32); + return Status(ERROR_INVALID_HANDLE, eErrorTypeWin32); DWORD sys_bytes_written = 0; BOOL write_result = ::WriteFile(m_write, buf, num_bytes, &sys_bytes_written, &m_write_overlapped); if (!write_result && GetLastError() != ERROR_IO_PENDING) - return Error(::GetLastError(), eErrorTypeWin32); + return Status(::GetLastError(), eErrorTypeWin32); BOOL result = GetOverlappedResult(m_write, &m_write_overlapped, &sys_bytes_written, TRUE); if (!result) - return Error(::GetLastError(), eErrorTypeWin32); - return Error(); + return Status(::GetLastError(), eErrorTypeWin32); + return Status(); } |