diff options
author | Oxore <oxore@protonmail.com> | 2022-09-25 16:37:27 +0300 |
---|---|---|
committer | Oxore <oxore@protonmail.com> | 2022-09-25 16:40:52 +0300 |
commit | 3cd8c083c736cd95be8e575fa70535f9c8eab924 (patch) | |
tree | e0c2b5f98618e434b85af8f87043a31f6c8b57f4 /emulator.cpp | |
parent | ee4f20d8627063f7310aac4625f18421c3799a77 (diff) |
Tidy some scopes, add some consts
Diffstat (limited to 'emulator.cpp')
-rw-r--r-- | emulator.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/emulator.cpp b/emulator.cpp index 7e0d1b3..945a104 100644 --- a/emulator.cpp +++ b/emulator.cpp @@ -33,14 +33,14 @@ static constexpr struct timespec kOneMillisecond{0, 1000000}; char msg_buf[MESSAGE_BUFFER_SIZE]; M68KDebuggingControl g_m68k_debug{}; -static int set_socket_reuseaddr(int socket_fd) +static int set_socket_reuseaddr(const int socket_fd) { const int val = 1; const socklen_t len = sizeof(val); return setsockopt(socket_fd, SOL_SOCKET, SO_REUSEADDR, (void*)&val, len); } -static inline struct sockaddr_in sockaddr_in_any_ip_with_port(uint16_t port) +static inline struct sockaddr_in sockaddr_in_any_ip_with_port(const uint16_t port) { struct sockaddr_in server{}; server.sin_family = AF_INET; @@ -49,7 +49,7 @@ static inline struct sockaddr_in sockaddr_in_any_ip_with_port(uint16_t port) return server; } -static inline int SetNonblock(int fd) +static inline int SetNonblock(const int fd) { const int flags = fcntl(fd, F_GETFL); if (flags == -1) { @@ -62,7 +62,7 @@ static inline int SetNonblock(int fd) return 0; } -static int setup_socket(uint16_t port) +static int setup_socket(const uint16_t port) { // This creates the socket - or quits const int socket_fd = socket(AF_INET, SOCK_STREAM, 0); @@ -262,7 +262,7 @@ static void make_hex(char* buff, unsigned int pc, unsigned int length) // TODO m68k_set_illg_instr_callback for true software breakpoint "4e4f" -int m68k_instr_callback(int pc) +int m68k_instr_callback(const int pc) { const auto it = std::find_if( code_bkpts.begin(), @@ -277,7 +277,7 @@ int m68k_instr_callback(int pc) } if (DEBUG_TRACE_INSTRUCTIONS) { char buff[100]; - unsigned int instr_size = + const unsigned int instr_size = m68k_disassemble(buff, pc, M68K_CPU_TYPE_68000); char buff2[100]; make_hex(buff2, pc, instr_size); @@ -347,11 +347,11 @@ void m68k_write_callback(const uint32_t address, const uint32_t size) } void ParseAndReact( - int conn_fd, + const int conn_fd, GDBRemote::ExchangeContext& exchange_ctx, M68KDebuggingControl& m68k_debug, - const char* msg_data, - size_t msg_data_len) + const char* const msg_data, + const size_t msg_data_len) { for (size_t i = 0; i < static_cast<size_t>(msg_data_len); i++) { const auto res = exchange_ctx.Consume(msg_data[i]); @@ -392,9 +392,9 @@ int emulator(M68KDebuggingControl& m68k_debug) return EXIT_FAILURE; } printf("Listening TCP 0.0.0.0:%u\n", port); - struct sockaddr client_address{}; - socklen_t address_len{}; while (1) { + struct sockaddr client_address{}; + socklen_t address_len{}; const int conn_fd = accept(socket_fd, &client_address, &address_len); if (conn_fd == -1 ) { if (errno == EWOULDBLOCK) { |