summaryrefslogtreecommitdiffstats
path: root/lldb/source/Host
diff options
context:
space:
mode:
authorRaphael Isemann <teemperor@gmail.com>2020-01-07 12:13:03 +0100
committerRaphael Isemann <teemperor@gmail.com>2020-01-07 13:03:56 +0100
commit65fdb34219f33b2871a532a38814ac4ebea10abc (patch)
tree5ddc3e81290641e13302734ec37030f3013ca77d /lldb/source/Host
parent14cd4a5b32478f76b9fa58825b7c92ba0dd5bc2b (diff)
downloadbcm5719-llvm-65fdb34219f33b2871a532a38814ac4ebea10abc.tar.gz
bcm5719-llvm-65fdb34219f33b2871a532a38814ac4ebea10abc.zip
[lldb][NFC] Use static_cast instead of reinterpret_cast where possible
Summary: There are a few places in LLDB where we do a `reinterpret_cast` for conversions that we could also do with `static_cast`. This patch moves all this code to `static_cast`. Reviewers: shafik, JDevlieghere, labath Reviewed By: labath Subscribers: arphaman, usaxena95, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D72161
Diffstat (limited to 'lldb/source/Host')
-rw-r--r--lldb/source/Host/common/NativeProcessProtocol.cpp4
-rw-r--r--lldb/source/Host/macosx/objcxx/Host.mm4
-rw-r--r--lldb/source/Host/posix/PipePosix.cpp9
3 files changed, 8 insertions, 9 deletions
diff --git a/lldb/source/Host/common/NativeProcessProtocol.cpp b/lldb/source/Host/common/NativeProcessProtocol.cpp
index fd349cc2915..712c448dc2c 100644
--- a/lldb/source/Host/common/NativeProcessProtocol.cpp
+++ b/lldb/source/Host/common/NativeProcessProtocol.cpp
@@ -682,7 +682,7 @@ NativeProcessProtocol::ReadCStringFromMemory(lldb::addr_t addr, char *buffer,
addr_t cache_line_bytes_left =
cache_line_size - (curr_addr % cache_line_size);
addr_t bytes_to_read = std::min<addr_t>(bytes_left, cache_line_bytes_left);
- status = ReadMemory(curr_addr, reinterpret_cast<void *>(curr_buffer),
+ status = ReadMemory(curr_addr, static_cast<void *>(curr_buffer),
bytes_to_read, bytes_read);
if (bytes_read == 0)
@@ -691,7 +691,7 @@ NativeProcessProtocol::ReadCStringFromMemory(lldb::addr_t addr, char *buffer,
void *str_end = std::memchr(curr_buffer, '\0', bytes_read);
if (str_end != nullptr) {
total_bytes_read =
- (size_t)(reinterpret_cast<char *>(str_end) - buffer + 1);
+ static_cast<size_t>((static_cast<char *>(str_end) - buffer + 1));
status.Clear();
break;
}
diff --git a/lldb/source/Host/macosx/objcxx/Host.mm b/lldb/source/Host/macosx/objcxx/Host.mm
index 03880ff433b..9febb8fb8b2 100644
--- a/lldb/source/Host/macosx/objcxx/Host.mm
+++ b/lldb/source/Host/macosx/objcxx/Host.mm
@@ -1013,7 +1013,7 @@ static bool AddPosixSpawnFileAction(void *_file_actions, const FileAction *info,
return false;
posix_spawn_file_actions_t *file_actions =
- reinterpret_cast<posix_spawn_file_actions_t *>(_file_actions);
+ static_cast<posix_spawn_file_actions_t *>(_file_actions);
switch (info->GetAction()) {
case FileAction::eFileActionNone:
@@ -1447,7 +1447,7 @@ llvm::Expected<HostThread> Host::StartMonitoringChildProcess(
"(callback, pid=%i, monitor_signals=%i) "
"source = %p\n",
static_cast<int>(pid), monitor_signals,
- reinterpret_cast<void *>(source));
+ static_cast<void *>(source));
if (source) {
Host::MonitorChildProcessCallback callback_copy = callback;
diff --git a/lldb/source/Host/posix/PipePosix.cpp b/lldb/source/Host/posix/PipePosix.cpp
index efdc151e376..ce1baf3f12a 100644
--- a/lldb/source/Host/posix/PipePosix.cpp
+++ b/lldb/source/Host/posix/PipePosix.cpp
@@ -270,8 +270,8 @@ Status PipePosix::ReadWithTimeout(void *buf, size_t size,
while (error.Success()) {
error = select_helper.Select();
if (error.Success()) {
- auto result = ::read(fd, reinterpret_cast<char *>(buf) + bytes_read,
- size - bytes_read);
+ auto result =
+ ::read(fd, static_cast<char *>(buf) + bytes_read, size - bytes_read);
if (result != -1) {
bytes_read += result;
if (bytes_read == size || result == 0)
@@ -301,9 +301,8 @@ Status PipePosix::Write(const void *buf, size_t size, size_t &bytes_written) {
while (error.Success()) {
error = select_helper.Select();
if (error.Success()) {
- auto result =
- ::write(fd, reinterpret_cast<const char *>(buf) + bytes_written,
- size - bytes_written);
+ auto result = ::write(fd, static_cast<const char *>(buf) + bytes_written,
+ size - bytes_written);
if (result != -1) {
bytes_written += result;
if (bytes_written == size)
OpenPOWER on IntegriCloud