From: openocd-gerrit <ope...@us...> - 2024-07-28 13:27:38
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 5b7b77349c11e0a8f4b0967f31d65dde6ee01457 (commit) from 052a4a69b5098e23efaf4ef993a3f0c44d605943 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 5b7b77349c11e0a8f4b0967f31d65dde6ee01457 Author: Antonio Borneo <bor...@gm...> Date: Sat Jul 13 19:14:39 2024 +0200 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 <bor...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/8391 Tested-by: jenkins Reviewed-by: Tomas Vanek <va...@fb...> diff --git a/src/target/cortex_m.c b/src/target/cortex_m.c index 791a43242..3b95b648e 100644 --- a/src/target/cortex_m.c +++ b/src/target/cortex_m.c @@ -279,7 +279,8 @@ static int cortex_m_fast_read_all_regs(struct target *target) /* because the DCB_DCRDR is used for the emulated dcc channel * we have to save/restore the DCB_DCRDR when used */ - if (target->dbg_msg_enabled) { + bool dbg_msg_enabled = target->dbg_msg_enabled; + if (dbg_msg_enabled) { retval = mem_ap_read_u32(armv7m->debug_ap, DCB_DCRDR, &dcrdr); if (retval != ERROR_OK) return retval; @@ -332,7 +333,7 @@ static int cortex_m_fast_read_all_regs(struct target *target) if (retval != ERROR_OK) return retval; - if (target->dbg_msg_enabled) { + if (dbg_msg_enabled) { /* restore DCB_DCRDR - this needs to be in a separate * transaction otherwise the emulated DCC channel breaks */ retval = mem_ap_write_atomic_u32(armv7m->debug_ap, DCB_DCRDR, dcrdr); diff --git a/src/target/target.c b/src/target/target.c index 8ff665f47..bd2638f2d 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -5813,7 +5813,7 @@ static int target_create(struct jim_getopt_info *goi) } target->dbgmsg = NULL; - target->dbg_msg_enabled = 0; + target->dbg_msg_enabled = false; target->endianness = TARGET_ENDIAN_UNKNOWN; diff --git a/src/target/target.h b/src/target/target.h index 03db3950c..d3077f571 100644 --- a/src/target/target.h +++ b/src/target/target.h @@ -160,7 +160,7 @@ struct target { struct watchpoint *watchpoints; /* list of watchpoints */ struct trace *trace_info; /* generic trace information */ struct debug_msg_receiver *dbgmsg; /* list of debug message receivers */ - uint32_t dbg_msg_enabled; /* debug message status */ + bool dbg_msg_enabled; /* debug message status */ void *arch_info; /* architecture specific information */ void *private_config; /* pointer to target specific config data (for jim_configure hook) */ struct target *next; /* next target in list */ diff --git a/src/target/target_request.c b/src/target/target_request.c index 72c84216f..bccae07b4 100644 --- a/src/target/target_request.c +++ b/src/target/target_request.c @@ -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 ----------------------------------------------------------------------- Summary of changes: src/target/cortex_m.c | 5 +++-- src/target/target.c | 2 +- src/target/target.h | 2 +- src/target/target_request.c | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) hooks/post-receive -- Main OpenOCD repository |