The global_cmd_ctx variable is never used in-tree, but rather serves the eCos build. As such, it does not seem safe remove directly; however, it represents an architectural blemish and needs to be removed.
Adds comments and ouputs warnings regarding this feature's deprecation. Signed-off-by: Zachary T Welch <z...@superlucidity.net> --- src/helper/command.c | 12 ++++++++---- src/openocd.c | 5 ++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/helper/command.c b/src/helper/command.c index 9b9c5ec..1cbedae 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -106,8 +106,6 @@ static int command_retval_set(Jim_Interp *interp, int retval) return (retval == ERROR_OK) ? JIM_OK : JIM_ERR; } -extern struct command_context *global_cmd_ctx; - void script_debug(Jim_Interp *interp, const char *name, unsigned argc, Jim_Obj *const *argv) { @@ -164,9 +162,15 @@ static struct command_context *current_command_context(Jim_Interp *interp) struct command_context *cmd_ctx = Jim_GetAssocData(interp, "context"); if (NULL == cmd_ctx) { - /* Tcl can invoke commands directly instead of via command_run_line(). This would - * happen when the Jim Tcl interpreter is provided by eCos. + /** + * Tcl can invoke commands directly instead of via + * command_run_line(). This would happen when the Jim Tcl + * interpreter is provided by eCos. + * NOTE: THIS IS A FUNDAMENTAL DESIGN FLAW. IT MUST DIE!!! */ + LOG_WARNING("You are using a global command context!!!"); + LOG_WARNING("This support will be removed in the future!"); + extern struct command_context *global_cmd_ctx; cmd_ctx = global_cmd_ctx; } return cmd_ctx; diff --git a/src/openocd.c b/src/openocd.c index 1be209a..73a24dd 100644 --- a/src/openocd.c +++ b/src/openocd.c @@ -191,6 +191,7 @@ static const struct command_registration openocd_command_handlers[] = { COMMAND_REGISTRATION_DONE }; +/// @todo Remove the global_cmd_ctx pointer; it has been deprecated. struct command_context *global_cmd_ctx; /* NB! this fn can be invoked outside this file for non PC hosted builds */ @@ -201,7 +202,9 @@ struct command_context *setup_command_handler(void) struct command_context *cmd_ctx; - global_cmd_ctx = cmd_ctx = command_init(openocd_startup_tcl); + cmd_ctx = command_init(openocd_startup_tcl); + // global that needs to be removed (see definition above) + global_cmd_ctx = cmd_ctx; register_commands(cmd_ctx, NULL, openocd_command_handlers); /* register subsystem commands */ -- 1.6.4.4 _______________________________________________ Openocd-development mailing list Openocd-development@lists.berlios.de https://lists.berlios.de/mailman/listinfo/openocd-development