diff options
Diffstat (limited to 'src/core/gdbstub/gdbstub.cpp')
| -rw-r--r-- | src/core/gdbstub/gdbstub.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/core/gdbstub/gdbstub.cpp b/src/core/gdbstub/gdbstub.cpp index 79f22a403..97ee65464 100644 --- a/src/core/gdbstub/gdbstub.cpp +++ b/src/core/gdbstub/gdbstub.cpp | |||
| @@ -291,11 +291,11 @@ static void FpuWrite(std::size_t id, u128 val, Kernel::Thread* thread = nullptr) | |||
| 291 | */ | 291 | */ |
| 292 | static u8 HexCharToValue(u8 hex) { | 292 | static u8 HexCharToValue(u8 hex) { |
| 293 | if (hex >= '0' && hex <= '9') { | 293 | if (hex >= '0' && hex <= '9') { |
| 294 | return hex - '0'; | 294 | return static_cast<u8>(hex - '0'); |
| 295 | } else if (hex >= 'a' && hex <= 'f') { | 295 | } else if (hex >= 'a' && hex <= 'f') { |
| 296 | return hex - 'a' + 0xA; | 296 | return static_cast<u8>(hex - 'a' + 0xA); |
| 297 | } else if (hex >= 'A' && hex <= 'F') { | 297 | } else if (hex >= 'A' && hex <= 'F') { |
| 298 | return hex - 'A' + 0xA; | 298 | return static_cast<u8>(hex - 'A' + 0xA); |
| 299 | } | 299 | } |
| 300 | 300 | ||
| 301 | LOG_ERROR(Debug_GDBStub, "Invalid nibble: {} ({:02X})", hex, hex); | 301 | LOG_ERROR(Debug_GDBStub, "Invalid nibble: {} ({:02X})", hex, hex); |
| @@ -310,9 +310,9 @@ static u8 HexCharToValue(u8 hex) { | |||
| 310 | static u8 NibbleToHex(u8 n) { | 310 | static u8 NibbleToHex(u8 n) { |
| 311 | n &= 0xF; | 311 | n &= 0xF; |
| 312 | if (n < 0xA) { | 312 | if (n < 0xA) { |
| 313 | return '0' + n; | 313 | return static_cast<u8>('0' + n); |
| 314 | } else { | 314 | } else { |
| 315 | return 'a' + n - 0xA; | 315 | return static_cast<u8>('a' + n - 0xA); |
| 316 | } | 316 | } |
| 317 | } | 317 | } |
| 318 | 318 | ||
| @@ -355,8 +355,8 @@ static u64 HexToLong(const u8* src, std::size_t len) { | |||
| 355 | */ | 355 | */ |
| 356 | static void MemToGdbHex(u8* dest, const u8* src, std::size_t len) { | 356 | static void MemToGdbHex(u8* dest, const u8* src, std::size_t len) { |
| 357 | while (len-- > 0) { | 357 | while (len-- > 0) { |
| 358 | u8 tmp = *src++; | 358 | const u8 tmp = *src++; |
| 359 | *dest++ = NibbleToHex(tmp >> 4); | 359 | *dest++ = NibbleToHex(static_cast<u8>(tmp >> 4)); |
| 360 | *dest++ = NibbleToHex(tmp); | 360 | *dest++ = NibbleToHex(tmp); |
| 361 | } | 361 | } |
| 362 | } | 362 | } |
| @@ -370,7 +370,7 @@ static void MemToGdbHex(u8* dest, const u8* src, std::size_t len) { | |||
| 370 | */ | 370 | */ |
| 371 | static void GdbHexToMem(u8* dest, const u8* src, std::size_t len) { | 371 | static void GdbHexToMem(u8* dest, const u8* src, std::size_t len) { |
| 372 | while (len-- > 0) { | 372 | while (len-- > 0) { |
| 373 | *dest++ = (HexCharToValue(src[0]) << 4) | HexCharToValue(src[1]); | 373 | *dest++ = static_cast<u8>((HexCharToValue(src[0]) << 4) | HexCharToValue(src[1])); |
| 374 | src += 2; | 374 | src += 2; |
| 375 | } | 375 | } |
| 376 | } | 376 | } |
| @@ -602,22 +602,22 @@ static void SendReply(const char* reply) { | |||
| 602 | 602 | ||
| 603 | memcpy(command_buffer + 1, reply, command_length); | 603 | memcpy(command_buffer + 1, reply, command_length); |
| 604 | 604 | ||
| 605 | u8 checksum = CalculateChecksum(command_buffer, command_length + 1); | 605 | const u8 checksum = CalculateChecksum(command_buffer, command_length + 1); |
| 606 | command_buffer[0] = GDB_STUB_START; | 606 | command_buffer[0] = GDB_STUB_START; |
| 607 | command_buffer[command_length + 1] = GDB_STUB_END; | 607 | command_buffer[command_length + 1] = GDB_STUB_END; |
| 608 | command_buffer[command_length + 2] = NibbleToHex(checksum >> 4); | 608 | command_buffer[command_length + 2] = NibbleToHex(static_cast<u8>(checksum >> 4)); |
| 609 | command_buffer[command_length + 3] = NibbleToHex(checksum); | 609 | command_buffer[command_length + 3] = NibbleToHex(checksum); |
| 610 | 610 | ||
| 611 | u8* ptr = command_buffer; | 611 | u8* ptr = command_buffer; |
| 612 | u32 left = command_length + 4; | 612 | u32 left = command_length + 4; |
| 613 | while (left > 0) { | 613 | while (left > 0) { |
| 614 | int sent_size = send(gdbserver_socket, reinterpret_cast<char*>(ptr), left, 0); | 614 | const auto sent_size = send(gdbserver_socket, reinterpret_cast<char*>(ptr), left, 0); |
| 615 | if (sent_size < 0) { | 615 | if (sent_size < 0) { |
| 616 | LOG_ERROR(Debug_GDBStub, "gdb: send failed"); | 616 | LOG_ERROR(Debug_GDBStub, "gdb: send failed"); |
| 617 | return Shutdown(); | 617 | return Shutdown(); |
| 618 | } | 618 | } |
| 619 | 619 | ||
| 620 | left -= sent_size; | 620 | left -= static_cast<u32>(sent_size); |
| 621 | ptr += sent_size; | 621 | ptr += sent_size; |
| 622 | } | 622 | } |
| 623 | } | 623 | } |
| @@ -777,10 +777,10 @@ static void ReadCommand() { | |||
| 777 | command_buffer[command_length++] = c; | 777 | command_buffer[command_length++] = c; |
| 778 | } | 778 | } |
| 779 | 779 | ||
| 780 | u8 checksum_received = HexCharToValue(ReadByte()) << 4; | 780 | auto checksum_received = static_cast<u32>(HexCharToValue(ReadByte()) << 4); |
| 781 | checksum_received |= HexCharToValue(ReadByte()); | 781 | checksum_received |= static_cast<u32>(HexCharToValue(ReadByte())); |
| 782 | 782 | ||
| 783 | u8 checksum_calculated = CalculateChecksum(command_buffer, command_length); | 783 | const u32 checksum_calculated = CalculateChecksum(command_buffer, command_length); |
| 784 | 784 | ||
| 785 | if (checksum_received != checksum_calculated) { | 785 | if (checksum_received != checksum_calculated) { |
| 786 | LOG_ERROR(Debug_GDBStub, | 786 | LOG_ERROR(Debug_GDBStub, |