This is an automated email from Gerrit.

Matthias Welwarsky ([email protected]) just uploaded a new patch set to 
Gerrit, which you can find at http://openocd.zylin.com/4130

-- gerrit

commit 622ddd69b3a9f51136a61b5d357a800212a303b7
Author: Matthias Welwarsky <[email protected]>
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 <[email protected]>

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");

-- 

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to