helper/command: fix check on value returned by jim API
authorAntonio Borneo <borneo.antonio@gmail.com>
Tue, 12 May 2020 22:47:17 +0000 (00:47 +0200)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sun, 24 May 2020 20:36:38 +0000 (21:36 +0100)
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
src/helper/command.c

index 14746a0958c3d7fd4b8b78b964e9a014b3a2963c..193867fe8c5eb5bc06e3f81e3be6e00859a9b9bd 100644 (file)
@@ -380,14 +380,14 @@ struct command *register_command(struct command_context *context,
        if (NULL == c)
                return NULL;
 
-       int retval = ERROR_OK;
+       int retval = JIM_OK;
        if (NULL != cr->jim_handler && NULL == parent) {
                retval = Jim_CreateCommand(context->interp, cr->name,
                                cr->jim_handler, NULL, NULL);
        } else if (NULL != cr->handler || NULL != parent)
                retval = register_command_handler(context, command_root(c));
 
-       if (ERROR_OK != retval) {
+       if (retval != JIM_OK) {
                unregister_command(context, parent, name);
                c = NULL;
        }