From be1954e04cb5a0c3a526f78ed5490a5e65310280 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 15 Oct 2020 14:49:45 -0400 Subject: core: Fix clang build Recent changes to the build system that made more warnings be flagged as errors caused building via clang to break. Fixes #4795 --- src/core/gdbstub/gdbstub.cpp | 47 +++++++++++++++++++++++++++++++++++--------- src/core/gdbstub/gdbstub.h | 2 +- 2 files changed, 39 insertions(+), 10 deletions(-) (limited to 'src/core/gdbstub') diff --git a/src/core/gdbstub/gdbstub.cpp b/src/core/gdbstub/gdbstub.cpp index 97ee65464..28a8a0f49 100644 --- a/src/core/gdbstub/gdbstub.cpp +++ b/src/core/gdbstub/gdbstub.cpp @@ -205,7 +205,7 @@ static Kernel::Thread* FindThreadById(s64 id) { const auto& threads = Core::System::GetInstance().GlobalScheduler().GetThreadList(); for (auto& thread : threads) { if (thread->GetThreadID() == static_cast(id)) { - current_core = thread->GetProcessorID(); + current_core = static_cast(thread->GetProcessorID()); return thread.get(); } } @@ -457,7 +457,14 @@ static u128 GdbHexToU128(const u8* src) { /// Read a byte from the gdb client. static u8 ReadByte() { u8 c; - std::size_t received_size = recv(gdbserver_socket, reinterpret_cast(&c), 1, MSG_WAITALL); + +#ifdef WIN32 + const auto socket_id = static_cast(gdbserver_socket); +#else + const auto socket_id = gdbserver_socket; +#endif + + const auto received_size = recv(socket_id, reinterpret_cast(&c), 1, MSG_WAITALL); if (received_size != 1) { LOG_ERROR(Debug_GDBStub, "recv failed: {}", received_size); Shutdown(); @@ -574,7 +581,13 @@ bool CheckBreakpoint(VAddr addr, BreakpointType type) { * @param packet Packet to be sent to client. */ static void SendPacket(const char packet) { - std::size_t sent_size = send(gdbserver_socket, &packet, 1, 0); +#ifdef WIN32 + const auto socket_id = static_cast(gdbserver_socket); +#else + const auto socket_id = gdbserver_socket; +#endif + + const auto sent_size = send(socket_id, &packet, 1, 0); if (sent_size != 1) { LOG_ERROR(Debug_GDBStub, "send failed"); } @@ -611,7 +624,13 @@ static void SendReply(const char* reply) { u8* ptr = command_buffer; u32 left = command_length + 4; while (left > 0) { - const auto sent_size = send(gdbserver_socket, reinterpret_cast(ptr), left, 0); +#ifdef WIN32 + const auto socket_id = static_cast(gdbserver_socket); +#else + const auto socket_id = gdbserver_socket; +#endif + const auto sent_size = + send(socket_id, reinterpret_cast(ptr), static_cast(left), 0); if (sent_size < 0) { LOG_ERROR(Debug_GDBStub, "gdb: send failed"); return Shutdown(); @@ -1294,8 +1313,13 @@ static void Init(u16 port) { WSAStartup(MAKEWORD(2, 2), &InitData); #endif - int tmpsock = static_cast(socket(PF_INET, SOCK_STREAM, 0)); - if (tmpsock == -1) { +#ifdef WIN32 + using socket_type = SOCKET; +#else + using socket_type = int; +#endif + const auto tmpsock = static_cast(socket(PF_INET, SOCK_STREAM, 0)); + if (tmpsock == static_cast(-1)) { LOG_ERROR(Debug_GDBStub, "Failed to create gdb socket"); } @@ -1335,7 +1359,7 @@ static void Init(u16 port) { } // Clean up temporary socket if it's still alive at this point. - if (tmpsock != -1) { + if (tmpsock != static_cast(-1)) { shutdown(tmpsock, SHUT_RDWR); } } @@ -1352,7 +1376,12 @@ void Shutdown() { LOG_INFO(Debug_GDBStub, "Stopping GDB ..."); if (gdbserver_socket != -1) { - shutdown(gdbserver_socket, SHUT_RDWR); +#ifdef WIN32 + const auto tmpsock = static_cast(socket(PF_INET, SOCK_STREAM, 0)); +#else + const auto tmpsock = static_cast(socket(PF_INET, SOCK_STREAM, 0)); +#endif + shutdown(tmpsock, SHUT_RDWR); gdbserver_socket = -1; } @@ -1383,7 +1412,7 @@ void SetCpuStepFlag(bool is_step) { step_loop = is_step; } -void SendTrap(Kernel::Thread* thread, int trap) { +void SendTrap(Kernel::Thread* thread, u32 trap) { if (!send_trap) { return; } diff --git a/src/core/gdbstub/gdbstub.h b/src/core/gdbstub/gdbstub.h index 8fe3c320b..23d80f367 100644 --- a/src/core/gdbstub/gdbstub.h +++ b/src/core/gdbstub/gdbstub.h @@ -110,5 +110,5 @@ void SetCpuStepFlag(bool is_step); * @param thread Sending thread. * @param trap Trap no. */ -void SendTrap(Kernel::Thread* thread, int trap); +void SendTrap(Kernel::Thread* thread, u32 trap); } // namespace GDBStub -- cgit v1.2.3