cpukit/libdebugger: Address clobbered warnings

Move variable assignments after the setjmp() call where possible and
move macros that contain setjmp into an if() clause since assigning the
return value to a variable is undefined.

Updates #5364
This commit is contained in:
Kinsey Moore
2025-11-02 21:26:43 -06:00
parent 9340bf6bad
commit 2179cd2fee
+21 -8
View File
@@ -1632,15 +1632,21 @@ remote_read_memory(uint8_t* buffer, int size)
uintptr_t addr;
DB_UINT length;
int r;
addr = hex_decode_addr(&buffer[1]);
length = hex_decode_uint((const uint8_t*) comma + 1);
remote_packet_out_reset();
r = rtems_debugger_target_start_memory_access();
if (r == 0) {
/*
* This call is actually a macro that contains a setjmp() and the result of
* a setjmp() assigned to a variable is undefined behavior. The result must
* be used directly in a conditional.
*/
if (rtems_debugger_target_start_memory_access() == 0) {
addr = hex_decode_addr(&buffer[1]);
length = hex_decode_uint((const uint8_t*) comma + 1);
/*
* There should be specific target access for 8, 16, 32 and 64 bit reads.
*/
r = remote_packet_out_append_hex((const uint8_t*) addr, length);
} else {
r = 0;
}
rtems_debugger_target_end_memory_access();
if (r < 0)
@@ -1664,15 +1670,22 @@ remote_write_memory(uint8_t* buffer, int size)
uintptr_t addr;
DB_UINT length;
int r;
addr = hex_decode_addr(&buffer[1]);
length = hex_decode_uint((const uint8_t*) comma + 1);
r = rtems_debugger_target_start_memory_access();
if (r == 0) {
/*
* This call is actually a macro that contains a setjmp() and the result of
* a setjmp() assigned to a variable is undefined behavior. The result must
* be used directly in a conditional.
*/
if (rtems_debugger_target_start_memory_access() == 0) {
addr = hex_decode_addr(&buffer[1]);
length = hex_decode_uint((const uint8_t*) comma + 1);
r = rtems_debugger_remote_packet_in_hex((uint8_t*) addr,
colon + 1,
length);
} else {
r = 0;
}
rtems_debugger_target_end_memory_access();
response = r_E01;
if (r == 0)
response = r_OK;
}