[adb] generic "cast_handle_to_int" function
Now one can use it without platform #ifdefs
Bug: 150183149
Test: compiles
Change-Id: I6280dcdd2faaff33014f11237d9d04231ac16b82
diff --git a/adb/client/incremental.cpp b/adb/client/incremental.cpp
index a9e65dc..33a1a37 100644
--- a/adb/client/incremental.cpp
+++ b/adb/client/incremental.cpp
@@ -188,12 +188,8 @@
std::string adb_path = android::base::GetExecutablePath();
- auto osh = adb_get_os_handle(connection_fd.get());
-#ifdef _WIN32
- auto fd_param = std::to_string(reinterpret_cast<intptr_t>(osh));
-#else /* !_WIN32 a.k.a. Unix */
+ auto osh = cast_handle_to_int(adb_get_os_handle(connection_fd.get()));
auto fd_param = std::to_string(osh);
-#endif
// pipe for child process to write output
int print_fds[2];
@@ -202,7 +198,7 @@
return {};
}
auto [pipe_read_fd, pipe_write_fd] = print_fds;
- auto pipe_write_fd_param = std::to_string(intptr_t(adb_get_os_handle(pipe_write_fd)));
+ auto pipe_write_fd_param = std::to_string(cast_handle_to_int(adb_get_os_handle(pipe_write_fd)));
close_on_exec(pipe_read_fd);
std::vector<std::string> args(std::move(files));