Skip to content

Commit

Permalink
gdb_main: Convert exec_v_flash_erase to read_hex32
Browse files Browse the repository at this point in the history
Replace sscanf with read_hex32, follow character check is used for
checking the ',' is present.
  • Loading branch information
OmniTechnoMancer authored and OmniTechnoMancer committed Apr 8, 2024
1 parent 2616686 commit 7e715ad
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/gdb_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -761,10 +761,11 @@ static void exec_v_cont(const char *packet, const size_t length)
static void exec_v_flash_erase(const char *packet, const size_t length)
{
(void)length;
uint32_t addr = 0;
uint32_t len = 0;
uint32_t addr;
uint32_t len;
const char *rest = NULL;

if (sscanf(packet, "%08" PRIx32 ",%08" PRIx32, &addr, &len) == 2) {
if (read_hex32(packet, &rest, &addr, ',') && read_hex32(rest, NULL, &len, READ_HEX_NO_FOLLOW)) {
/* Erase Flash Memory */
DEBUG_GDB("Flash Erase %08" PRIX32 " %08" PRIX32 "\n", addr, len);
if (!cur_target) {
Expand All @@ -778,7 +779,8 @@ static void exec_v_flash_erase(const char *packet, const size_t length)
target_flash_complete(cur_target);
gdb_putpacketz("EFF");
}
}
} else
gdb_putpacketz("EFF");
}

static void exec_v_flash_write(const char *packet, const size_t length)
Expand Down

0 comments on commit 7e715ad

Please sign in to comment.