Discussion:
[OpenOCD-devel] [PATCH]: 622ddd6 target: use correct target in target-prefixed commands
gerrit
2017-05-10 15:10:36 UTC
Permalink
This is an automated email from Gerrit.

Matthias Welwarsky (***@welwarsky.de) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/4130

-- gerrit

commit 622ddd69b3a9f51136a61b5d357a800212a303b7
Author: Matthias Welwarsky <***@sysgo.com>
Date: Wed May 10 17:10:50 2017 +0200

target: use correct target in target-prefixed commands

get_current_target() must retrieve the target associated to the parent
command if a parent exists. If no parent exists, the current target of
the command context is used as a fallback.

Change-Id: I2fa7899f4251a6b385ca374e98b459ac1a3cabf5
Signed-off-by: Matthias Welwarsky <***@sysgo.com>

diff --git a/src/target/target.c b/src/target/target.c
index e04ecc4..adbaf05 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -512,7 +512,13 @@ struct target *get_target_by_num(int num)

struct target *get_current_target(struct command_context *cmd_ctx)
{
- struct target *target = get_target_by_num(cmd_ctx->current_target);
+ struct command *cmd = cmd_ctx->commands;
+ struct target *target;
+
+ if (cmd->parent != NULL)
+ target = cmd->parent->jim_handler_data;
+ else
+ target = get_target_by_num(cmd_ctx->current_target);

if (target == NULL) {
LOG_ERROR("BUG: current_target out of bounds");

--

Loading...