This is an automated email from Gerrit. "Evgeniy Naydanov <evgeniy.nayda...@syntacore.com>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8434
-- gerrit commit cc4f43864c59eb318aeada48d4ab4247ec40e150 Author: Evgeniy Naydanov <evgeniy.nayda...@syntacore.com> Date: Fri Aug 2 16:49:42 2024 +0300 target/target: call `target_type->target_create` before `configure` The motivation is twofold: 1. It seems reasonable to assume that `target_type->target_create` is the first `target_type`-specific function being called. However, `conigure` calls `target_type->target_jim_configure` which used to make this assumption erroneous. 2. The result of `target_type->target_create` should not depend on options configurable via `configure`, since `configure` can be called after `target create` in any order a user may see fit. Change-Id: I88ae8ed631a6812e2a27562e644cc101fa168b16 Signed-off-by: Evgeniy Naydanov <evgeniy.nayda...@syntacore.com> diff --git a/src/target/target.c b/src/target/target.c index b6159c72b7..a2203a4403 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -5823,6 +5823,15 @@ static int target_create(struct jim_getopt_info *goi) target->gdb_port_override = NULL; target->gdb_max_connections = 1; + if (target->type->target_create) { + e = (*(target->type->target_create))(target, goi->interp); + if (e != ERROR_OK) { + LOG_DEBUG("target_create failed"); + free(target->type); + free(target); + return JIM_ERR; + } + } /* Do the rest as "configure" options */ goi->isconfigure = 1; e = target_configure(goi, target); @@ -5870,20 +5879,6 @@ static int target_create(struct jim_getopt_info *goi) return JIM_ERR; } - if (target->type->target_create) { - e = (*(target->type->target_create))(target, goi->interp); - if (e != ERROR_OK) { - LOG_DEBUG("target_create failed"); - free(target->cmd_name); - rtos_destroy(target); - free(target->gdb_port_override); - free(target->trace_info); - free(target->type); - free(target); - return JIM_ERR; - } - } - /* create the target specific commands */ if (target->type->commands) { e = register_commands(cmd_ctx, NULL, target->type->commands); --