From: OpenOCD-Gerrit <ope...@us...> - 2021-11-20 14:46:19
|
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 bb78fa10c77411bbdf665c17eac954b7741f2040 (commit) from 81afe6e3fdb1253659d7d5a1be9f4f444c2c18d5 (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 bb78fa10c77411bbdf665c17eac954b7741f2040 Author: Tomas Vanek <va...@fb...> Date: Mon Nov 15 15:32:39 2021 +0100 target/arm_dap: clean up dap_configure code dap_configure() contained first time init related tasks, as the call to dap_init_instance() and the check for configured tap. Move all first time init related stuff to dap_create() to make dap_configure() usable in eventual stand-alone 'dap configure' command. Change-Id: Ia86eadb4e960ce54e8581630d01af75720d2318d Signed-off-by: Tomas Vanek <va...@fb...> Reviewed-on: https://review.openocd.org/c/openocd/+/6702 Tested-by: jenkins Reviewed-by: Antonio Borneo <bor...@gm...> Reviewed-by: Matthias Welwarsky <mat...@we...> diff --git a/src/target/arm_dap.c b/src/target/arm_dap.c index 18e77b50f..0eb55a9cb 100644 --- a/src/target/arm_dap.c +++ b/src/target/arm_dap.c @@ -165,11 +165,10 @@ static const struct jim_nvp nvp_config_opts[] = { static int dap_configure(struct jim_getopt_info *goi, struct arm_dap_object *dap) { - struct jtag_tap *tap = NULL; struct jim_nvp *n; int e; - /* parse config or cget options ... */ + /* parse config ... */ while (goi->argc > 0) { Jim_SetEmptyResult(goi->interp); @@ -184,11 +183,14 @@ static int dap_configure(struct jim_getopt_info *goi, struct arm_dap_object *dap e = jim_getopt_obj(goi, &o_t); if (e != JIM_OK) return e; + + struct jtag_tap *tap; tap = jtag_tap_by_jim_obj(goi->interp, o_t); if (!tap) { Jim_SetResultString(goi->interp, "-chain-position is invalid", -1); return JIM_ERR; } + dap->dap.tap = tap; /* loop for more */ break; } @@ -200,14 +202,6 @@ static int dap_configure(struct jim_getopt_info *goi, struct arm_dap_object *dap } } - if (!tap) { - Jim_SetResultString(goi->interp, "-chain-position required when creating DAP", -1); - return JIM_ERR; - } - - dap_instance_init(&dap->dap); - dap->dap.tap = tap; - return JIM_OK; } @@ -242,15 +236,21 @@ static int dap_create(struct jim_getopt_info *goi) if (!dap) return JIM_ERR; - e = dap_configure(goi, dap); - if (e != JIM_OK) { - free(dap); - return e; - } + dap_instance_init(&dap->dap); cp = Jim_GetString(new_cmd, NULL); dap->name = strdup(cp); + e = dap_configure(goi, dap); + if (e != JIM_OK) + goto err; + + if (!dap->dap.tap) { + Jim_SetResultString(goi->interp, "-chain-position required when creating DAP", -1); + e = JIM_ERR; + goto err; + } + struct command_registration dap_commands[] = { { .name = cp, @@ -268,14 +268,18 @@ static int dap_create(struct jim_getopt_info *goi) e = register_commands_with_data(cmd_ctx, NULL, dap_commands, dap); if (e != ERROR_OK) { - free(dap->name); - free(dap); - return JIM_ERR; + e = JIM_ERR; + goto err; } list_add_tail(&dap->lh, &all_dap); return JIM_OK; + +err: + free(dap->name); + free(dap); + return e; } static int jim_dap_create(Jim_Interp *interp, int argc, Jim_Obj *const *argv) ----------------------------------------------------------------------- Summary of changes: src/target/arm_dap.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) hooks/post-receive -- Main OpenOCD repository |