helper/command: fix check on value returned by jim API
Either Jim_CreateCommand() and register_command_handler() return the jim error code JIM_OK/JIM_ERR. Fix the check and the initialization of retval. Change-Id: I3073c66764670128706ad979a43bb3edbbeb0ab0 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5661 Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com> Tested-by: jenkins
This commit is contained in:
parent
3008756604
commit
80e8b019b0
|
@ -380,14 +380,14 @@ struct command *register_command(struct command_context *context,
|
||||||
if (NULL == c)
|
if (NULL == c)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
int retval = ERROR_OK;
|
int retval = JIM_OK;
|
||||||
if (NULL != cr->jim_handler && NULL == parent) {
|
if (NULL != cr->jim_handler && NULL == parent) {
|
||||||
retval = Jim_CreateCommand(context->interp, cr->name,
|
retval = Jim_CreateCommand(context->interp, cr->name,
|
||||||
cr->jim_handler, NULL, NULL);
|
cr->jim_handler, NULL, NULL);
|
||||||
} else if (NULL != cr->handler || NULL != parent)
|
} else if (NULL != cr->handler || NULL != parent)
|
||||||
retval = register_command_handler(context, command_root(c));
|
retval = register_command_handler(context, command_root(c));
|
||||||
|
|
||||||
if (ERROR_OK != retval) {
|
if (retval != JIM_OK) {
|
||||||
unregister_command(context, parent, name);
|
unregister_command(context, parent, name);
|
||||||
c = NULL;
|
c = NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue