From 90ddac12e38ab21b1d3934235e0d1242e0f13616 Mon Sep 17 00:00:00 2001 From: Antonio Borneo Date: Mon, 19 Dec 2022 20:56:40 +0100 Subject: 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 Reviewed-on: https://review.openocd.org/c/openocd/+/7501 Tested-by: jenkins --- src/target/arm_tpiu_swo.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'src/target') diff --git a/src/target/arm_tpiu_swo.c b/src/target/arm_tpiu_swo.c index 3cf3063..55201e6 100644 --- a/src/target/arm_tpiu_swo.c +++ b/src/target/arm_tpiu_swo.c @@ -981,20 +981,17 @@ err_exit: 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; - if (argc != 1) { - Jim_WrongNumArgs(interp, 1, argv, "Too many parameters"); - return JIM_ERR; - } - Jim_SetResult(interp, Jim_NewListObj(interp, NULL, 0)); - list_for_each_entry(obj, &all_tpiu_swo, lh) { - Jim_ListAppendElement(interp, Jim_GetResult(interp), - Jim_NewStringObj(interp, obj->name, -1)); - } - return JIM_OK; + if (CMD_ARGC != 0) + return ERROR_COMMAND_SYNTAX_ERROR; + + list_for_each_entry(obj, &all_tpiu_swo, lh) + command_print(CMD, "%s", obj->name); + + return ERROR_OK; } 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", .mode = COMMAND_ANY, - .jim_handler = jim_arm_tpiu_swo_names, + .handler = handle_arm_tpiu_swo_names, .usage = "", .help = "Lists all registered TPIU and SWO objects by name", }, -- cgit v1.1