Reorder sanity checks in jtag3_paged_load() and jtag3_paged_load_tpi()

This commit is contained in:
stefanrueger
2026-08-16 07:08:03 +02:00
parent ba6662d226
commit ff9cf35e8b

View File

@@ -2096,15 +2096,15 @@ static int jtag3_paged_load(const PROGRAMMER *pgm, const AVRPART *p, const AVRME
if((status = jtag3_command(pgm, cmd, 12, &resp, "read memory")) < 0)
return -1;
if((resp && resp[1] != RSP3_DATA) || status < (int) block_size + 4) {
pmsg_error("wrong/short reply to read memory command\n");
serial_recv_timeout = otimeout;
if(status < 4) {
pmsg_error("unexpected response from read memory jtag3_command()\n");
mmt_free(resp);
return -1;
}
if(status < 4) {
pmsg_error("unexpected response from read memory jtag3_command()\n");
if((resp && resp[1] != RSP3_DATA) || status < (int) block_size + 4) {
pmsg_error("wrong/short reply to read memory command\n");
serial_recv_timeout = otimeout;
mmt_free(resp);
return -1;
}
@@ -3166,15 +3166,15 @@ static int jtag3_paged_load_tpi(const PROGRAMMER *pgm, const AVRPART *p,
if((status = jtag3_command_tpi(pgm, cmd, 8, &resp, "Read Memory")) < 0)
return -1;
if((resp && resp[1] != XPRG_ERR_OK) || status < (int) block_size + 2) {
pmsg_error("wrong/short reply to read memory command\n");
serial_recv_timeout = otimeout;
if(status < 2) {
pmsg_error("unexpected return value %d from jtag3_paged_load_tpi()\n", status);
mmt_free(resp);
return -1;
}
if(status < 2) {
pmsg_error("unexpected return value %d from jtag3_paged_load_tpi()\n", status);
if((resp && resp[1] != XPRG_ERR_OK) || status < (int) block_size + 2) {
pmsg_error("wrong/short reply to read memory command\n");
serial_recv_timeout = otimeout;
mmt_free(resp);
return -1;
}