From fbb7a50cbd5b9cda29698b3192e2a4596b3a6371 Mon Sep 17 00:00:00 2001 From: Antonio Borneo Date: Mon, 19 Dec 2022 18:29:08 +0100 Subject: jtag: rewrite command 'flush_count' as COMMAND_HANDLER While there: - check the number of command parameters; - add the mandatory 'usage' field. Change-Id: I7cd16f049753caedf19f313f7dc84be98efdba42 Signed-off-by: Antonio Borneo Reviewed-on: https://review.openocd.org/c/openocd/+/7497 Tested-by: jenkins --- src/jtag/tcl.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/jtag/tcl.c b/src/jtag/tcl.c index c6ca048..b3cbc48 100644 --- a/src/jtag/tcl.c +++ b/src/jtag/tcl.c @@ -249,12 +249,15 @@ static int jim_command_pathmove(Jim_Interp *interp, int argc, Jim_Obj * const *a return JIM_OK; } - -static int jim_command_flush_count(Jim_Interp *interp, int argc, Jim_Obj * const *args) +COMMAND_HANDLER(handle_jtag_flush_count) { - Jim_SetResult(interp, Jim_NewIntObj(interp, jtag_get_flush_queue_count())); + if (CMD_ARGC != 0) + return ERROR_COMMAND_SYNTAX_ERROR; - return JIM_OK; + int count = jtag_get_flush_queue_count(); + command_print_sameline(CMD, "%d", count); + + return ERROR_OK; } /* REVISIT Just what about these should "move" ... ? @@ -279,9 +282,10 @@ static const struct command_registration jtag_command_handlers_to_move[] = { { .name = "flush_count", .mode = COMMAND_EXEC, - .jim_handler = jim_command_flush_count, + .handler = handle_jtag_flush_count, .help = "Returns the number of times the JTAG queue " "has been flushed.", + .usage = "", }, { .name = "pathmove", -- cgit v1.1