target/arm_cti: fix regression from Tcl_return_values series

Since commit 7f260f5009 native OpenOCD
command handlers should not directly use Jim_SetResult functions.
The Tcl result of a native command is built as concatenation of
command_print() strings and Jim_SetResult() is called after return
of the command handler.

Replace "wrong number of args" error messages (now not delivered to user)
by simply return ERROR_COMMAND_SYNTAX_ERROR

Change-Id: I40c1374a13859cefbdef68e0f1c13ab93538bd50
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/5363
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
This commit is contained in:
Tomas Vanek 2019-12-16 13:08:01 +01:00
parent ddbd8dcf91
commit dc95dd036f
1 changed files with 8 additions and 20 deletions

View File

@ -261,14 +261,11 @@ COMMAND_HANDLER(handle_cti_dump)
COMMAND_HANDLER(handle_cti_enable)
{
struct arm_cti_object *obj = CMD_DATA;
Jim_Interp *interp = CMD_CTX->interp;
struct arm_cti *cti = &obj->cti;
bool on_off;
if (CMD_ARGC != 1) {
Jim_SetResultString(interp, "wrong number of args", -1);
return ERROR_FAIL;
}
if (CMD_ARGC != 1)
return ERROR_COMMAND_SYNTAX_ERROR;
COMMAND_PARSE_ON_OFF(CMD_ARGV[0], on_off);
@ -278,14 +275,11 @@ COMMAND_HANDLER(handle_cti_enable)
COMMAND_HANDLER(handle_cti_testmode)
{
struct arm_cti_object *obj = CMD_DATA;
Jim_Interp *interp = CMD_CTX->interp;
struct arm_cti *cti = &obj->cti;
bool on_off;
if (CMD_ARGC != 1) {
Jim_SetResultString(interp, "wrong number of args", -1);
return ERROR_FAIL;
}
if (CMD_ARGC != 1)
return ERROR_COMMAND_SYNTAX_ERROR;
COMMAND_PARSE_ON_OFF(CMD_ARGV[0], on_off);
@ -295,15 +289,12 @@ COMMAND_HANDLER(handle_cti_testmode)
COMMAND_HANDLER(handle_cti_write)
{
struct arm_cti_object *obj = CMD_DATA;
Jim_Interp *interp = CMD_CTX->interp;
struct arm_cti *cti = &obj->cti;
int offset;
uint32_t value;
if (CMD_ARGC != 2) {
Jim_SetResultString(interp, "Wrong number of args", -1);
return ERROR_FAIL;
}
if (CMD_ARGC != 2)
return ERROR_COMMAND_SYNTAX_ERROR;
offset = cti_find_reg_offset(CMD_ARGV[0]);
if (offset < 0)
@ -317,16 +308,13 @@ COMMAND_HANDLER(handle_cti_write)
COMMAND_HANDLER(handle_cti_read)
{
struct arm_cti_object *obj = CMD_DATA;
Jim_Interp *interp = CMD_CTX->interp;
struct arm_cti *cti = &obj->cti;
int offset;
int retval;
uint32_t value;
if (CMD_ARGC != 1) {
Jim_SetResultString(interp, "Wrong number of args", -1);
return ERROR_FAIL;
}
if (CMD_ARGC != 1)
return ERROR_COMMAND_SYNTAX_ERROR;
offset = cti_find_reg_offset(CMD_ARGV[0]);
if (offset < 0)