Skip to content

Commit

Permalink
gdb_main: use static char arrays in tandem with ARRAY_LENGTH
Browse files Browse the repository at this point in the history
This removes the need for strlen
  • Loading branch information
perigoso committed Dec 11, 2024
1 parent 90190cf commit f16ec17
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/gdb_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,8 @@ static void exec_q_rcmd(const char *packet, const size_t length)
else if (result == 0)
gdb_put_packet_ok();
else {
const char *const response = "Failed\n";
gdb_put_packet_hex(response, strlen(response));
static const char response[] = "Failed\n";
gdb_put_packet_hex(response, ARRAY_LENGTH(response));
}
}

Expand Down Expand Up @@ -863,8 +863,8 @@ static void handle_v_packet(const gdb_packet_s *const packet)
* The vMustReplyEmpty is used as a feature test to check how gdbserver handles
* unknown packets, don't print an error message for it.
*/
static const char *const must_reply_empty = "vMustReplyEmpty";
if (strncmp(packet->data, must_reply_empty, strlen(must_reply_empty)) != 0)
static const char must_reply_empty[] = "vMustReplyEmpty";
if (strncmp(packet->data, must_reply_empty, ARRAY_LENGTH(must_reply_empty) - 1U) != 0)
DEBUG_GDB("*** Unsupported packet: %s\n", packet->data);
#endif
gdb_put_packet_empty();
Expand Down

0 comments on commit f16ec17

Please sign in to comment.