target: arm_tpiu_swo: rewrite command 'tpiu names' as COMMAND_HANDLER

While there, format in a human readable way the output list by
using one line per tpiu name.

Change-Id: I937c92b6c1e92509cf8aa96be1517a51bc363600
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7501
Tested-by: jenkins
This commit is contained in:
Antonio Borneo 2022-12-19 20:56:40 +01:00
parent 5d39a8852a
commit 90ddac12e3
1 changed files with 9 additions and 12 deletions

View File

@ -981,20 +981,17 @@ err_exit:
return JIM_ERR; return JIM_ERR;
} }
static int jim_arm_tpiu_swo_names(Jim_Interp *interp, int argc, Jim_Obj *const *argv) COMMAND_HANDLER(handle_arm_tpiu_swo_names)
{ {
struct arm_tpiu_swo_object *obj; struct arm_tpiu_swo_object *obj;
if (argc != 1) { if (CMD_ARGC != 0)
Jim_WrongNumArgs(interp, 1, argv, "Too many parameters"); return ERROR_COMMAND_SYNTAX_ERROR;
return JIM_ERR;
} list_for_each_entry(obj, &all_tpiu_swo, lh)
Jim_SetResult(interp, Jim_NewListObj(interp, NULL, 0)); command_print(CMD, "%s", obj->name);
list_for_each_entry(obj, &all_tpiu_swo, lh) {
Jim_ListAppendElement(interp, Jim_GetResult(interp), return ERROR_OK;
Jim_NewStringObj(interp, obj->name, -1));
}
return JIM_OK;
} }
static int jim_arm_tpiu_swo_init(Jim_Interp *interp, int argc, Jim_Obj *const *argv) static int jim_arm_tpiu_swo_init(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
@ -1185,7 +1182,7 @@ static const struct command_registration arm_tpiu_swo_subcommand_handlers[] = {
{ {
.name = "names", .name = "names",
.mode = COMMAND_ANY, .mode = COMMAND_ANY,
.jim_handler = jim_arm_tpiu_swo_names, .handler = handle_arm_tpiu_swo_names,
.usage = "", .usage = "",
.help = "Lists all registered TPIU and SWO objects by name", .help = "Lists all registered TPIU and SWO objects by name",
}, },