This is an automated email from Gerrit.

"Antonio Borneo <borneo.anto...@gmail.com>" just uploaded a new patch set to 
Gerrit, which you can find at https://review.openocd.org/c/openocd/+/7508

-- gerrit

commit 8d044a97a2e3c0ac12b87b45daa64bfa05d85f6b
Author: Antonio Borneo <borneo.anto...@gmail.com>
Date:   Mon Dec 19 23:50:23 2022 +0100

    target: rewrite command 'target current' as COMMAND_HANDLER
    
    While there add the mandatory 'usage' field.
    
    Change-Id: I3e5b826ca58f7ade30a443ada0cb4a9cd9ea35c2
    Signed-off-by: Antonio Borneo <borneo.anto...@gmail.com>

diff --git a/src/target/target.c b/src/target/target.c
index 4e29146482..ae5f74cbf7 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -6365,19 +6365,16 @@ static int target_create(struct jim_getopt_info *goi)
        return JIM_OK;
 }
 
-static int jim_target_current(Jim_Interp *interp, int argc, Jim_Obj *const 
*argv)
+COMMAND_HANDLER(handle_target_current)
 {
-       if (argc != 1) {
-               Jim_WrongNumArgs(interp, 1, argv, "Too many parameters");
-               return JIM_ERR;
-       }
-       struct command_context *cmd_ctx = current_command_context(interp);
-       assert(cmd_ctx);
+       if (CMD_ARGC != 0)
+               return ERROR_COMMAND_SYNTAX_ERROR;
 
-       struct target *target = get_current_target_or_null(cmd_ctx);
+       struct target *target = get_current_target_or_null(CMD_CTX);
        if (target)
-               Jim_SetResultString(interp, target_name(target), -1);
-       return JIM_OK;
+               command_print(CMD, "%s", target_name(target));
+
+       return ERROR_OK;
 }
 
 static int jim_target_types(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
@@ -6522,8 +6519,9 @@ static const struct command_registration 
target_subcommand_handlers[] = {
        {
                .name = "current",
                .mode = COMMAND_ANY,
-               .jim_handler = jim_target_current,
+               .handler = handle_target_current,
                .help = "Returns the currently selected target",
+               .usage = "",
        },
        {
                .name = "types",

-- 

Reply via email to