forked from auracaster/openocd
cortex_m: fix scan-build false positive
Scan-build is unable to detect that 'target->dbg_msg_enabled' does not change across the function cortex_m_fast_read_all_regs(). It incorrectly assumes that it can be false at the first check (so 'dcrdr' get not assigned) and it is true later on (when 'dcrdr' get used). This triggers a false positive: src/target/cortex_m.c:338:12: warning: 3rd function call argument is an uninitialized value [core.CallAndMessage] retval = mem_ap_write_atomic_u32(armv7m->debug_ap, DCB_DCRDR, dcrdr); Use a local variable for 'target->dbg_msg_enabled' so scan-build can track it as not modified. While there, change the type of 'target->dbg_msg_enabled' to boolean as there is no reason to use uint32_t. Change-Id: Icaf1a1b2dea8bc55108182ea440708ab76396cd7 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8391 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
This commit is contained in:
@@ -164,7 +164,7 @@ static int add_debug_msg_receiver(struct command_context *cmd_ctx, struct target
|
||||
(*p)->next = NULL;
|
||||
|
||||
/* enable callback */
|
||||
target->dbg_msg_enabled = 1;
|
||||
target->dbg_msg_enabled = true;
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
@@ -225,7 +225,7 @@ int delete_debug_msg_receiver(struct command_context *cmd_ctx, struct target *ta
|
||||
free(c);
|
||||
if (!*p) {
|
||||
/* disable callback */
|
||||
target->dbg_msg_enabled = 0;
|
||||
target->dbg_msg_enabled = false;
|
||||
}
|
||||
return ERROR_OK;
|
||||
} else
|
||||
|
||||
Reference in New Issue
Block a user