Skip to content

Commit a6b0221

Browse files
committed
target: cortex_a: fix clang error core.CallAndMessage
Clang complains about the variable 'orig_dfsr' that can be used uninitialized both in cortex_a_read_cpu_memory() and in cortex_a_write_cpu_memory(). The issue is caused by an incorrect error path that used to jump through 'goto out'. The code after the label 'out' is specific to handle the case of an error during memory R/W; it is incorrect to jump there to handle an error during the initialization that precedes the memory R/W. Replace the 'goto out' with 'return retval'. Remove the label 'out' that is now unused. Change-Id: Ib4b140221d1c1b63419de109579bde8b63fc2e8c Signed-off-by: Antonio Borneo <[email protected]> Reviewed-on: https://review.openocd.org/c/openocd/+/7393 Tested-by: jenkins
1 parent c6fe10d commit a6b0221

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/target/cortex_a.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2246,24 +2246,24 @@ static int cortex_a_write_cpu_memory(struct target *target,
22462246
/* Switch to non-blocking mode if not already in that mode. */
22472247
retval = cortex_a_set_dcc_mode(target, DSCR_EXT_DCC_NON_BLOCKING, &dscr);
22482248
if (retval != ERROR_OK)
2249-
goto out;
2249+
return retval;
22502250

22512251
/* Mark R0 as dirty. */
22522252
arm_reg_current(arm, 0)->dirty = true;
22532253

22542254
/* Read DFAR and DFSR, as they will be modified in the event of a fault. */
22552255
retval = cortex_a_read_dfar_dfsr(target, &orig_dfar, &orig_dfsr, &dscr);
22562256
if (retval != ERROR_OK)
2257-
goto out;
2257+
return retval;
22582258

22592259
/* Get the memory address into R0. */
22602260
retval = mem_ap_write_atomic_u32(armv7a->debug_ap,
22612261
armv7a->debug_base + CPUDBG_DTRRX, address);
22622262
if (retval != ERROR_OK)
2263-
goto out;
2263+
return retval;
22642264
retval = cortex_a_exec_opcode(target, ARMV4_5_MRC(14, 0, 0, 0, 5, 0), &dscr);
22652265
if (retval != ERROR_OK)
2266-
goto out;
2266+
return retval;
22672267

22682268
if (size == 4 && (address % 4) == 0) {
22692269
/* We are doing a word-aligned transfer, so use fast mode. */
@@ -2288,7 +2288,6 @@ static int cortex_a_write_cpu_memory(struct target *target,
22882288
retval = cortex_a_write_cpu_memory_slow(target, size, count, buffer, &dscr);
22892289
}
22902290

2291-
out:
22922291
final_retval = retval;
22932292

22942293
/* Switch to non-blocking mode if not already in that mode. */
@@ -2564,24 +2563,24 @@ static int cortex_a_read_cpu_memory(struct target *target,
25642563
/* Switch to non-blocking mode if not already in that mode. */
25652564
retval = cortex_a_set_dcc_mode(target, DSCR_EXT_DCC_NON_BLOCKING, &dscr);
25662565
if (retval != ERROR_OK)
2567-
goto out;
2566+
return retval;
25682567

25692568
/* Mark R0 as dirty. */
25702569
arm_reg_current(arm, 0)->dirty = true;
25712570

25722571
/* Read DFAR and DFSR, as they will be modified in the event of a fault. */
25732572
retval = cortex_a_read_dfar_dfsr(target, &orig_dfar, &orig_dfsr, &dscr);
25742573
if (retval != ERROR_OK)
2575-
goto out;
2574+
return retval;
25762575

25772576
/* Get the memory address into R0. */
25782577
retval = mem_ap_write_atomic_u32(armv7a->debug_ap,
25792578
armv7a->debug_base + CPUDBG_DTRRX, address);
25802579
if (retval != ERROR_OK)
2581-
goto out;
2580+
return retval;
25822581
retval = cortex_a_exec_opcode(target, ARMV4_5_MRC(14, 0, 0, 0, 5, 0), &dscr);
25832582
if (retval != ERROR_OK)
2584-
goto out;
2583+
return retval;
25852584

25862585
if (size == 4 && (address % 4) == 0) {
25872586
/* We are doing a word-aligned transfer, so use fast mode. */
@@ -2607,7 +2606,6 @@ static int cortex_a_read_cpu_memory(struct target *target,
26072606
retval = cortex_a_read_cpu_memory_slow(target, size, count, buffer, &dscr);
26082607
}
26092608

2610-
out:
26112609
final_retval = retval;
26122610

26132611
/* Switch to non-blocking mode if not already in that mode. */

0 commit comments

Comments
 (0)