This is an automated email from Gerrit. "zapb <d...@zapb.de>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8638
-- gerrit commit f8bc1923db73da2894ccb89de5ff23172da900a5 Author: Marc Schink <d...@zapb.de> Date: Mon Apr 15 07:48:31 2024 +0200 target/cortex_m: Remove echo of 'reset_config' command Do not echo the selected reset_config to avoid stray and confusing messages in the output of OpenOCD. For example, the "reset_config" line here: Open On-Chip Debugger 0.12.0+dev-00802-gb7f0145fc-dirty Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html cortex_m reset_config sysresetreq Info : Listening on port 6666 for tcl connections Info : Listening on port 4444 for telnet connections While at it, fix some coding style and command handling issues. Change-Id: I3b3d8687af1d23a2dc1764f29b52dc607b80cb59 Signed-off-by: Marc Schink <d...@zapb.de> diff --git a/src/target/cortex_m.c b/src/target/cortex_m.c index fa95fcbc7e..2ed5dd6e1f 100644 --- a/src/target/cortex_m.c +++ b/src/target/cortex_m.c @@ -3080,29 +3080,15 @@ COMMAND_HANDLER(handle_cortex_m_reset_config_command) { struct target *target = get_current_target(CMD_CTX); struct cortex_m_common *cortex_m = target_to_cm(target); - int retval; - char *reset_config; - retval = cortex_m_verify_pointer(CMD, cortex_m); + int retval = cortex_m_verify_pointer(CMD, cortex_m); if (retval != ERROR_OK) return retval; - if (CMD_ARGC > 0) { - if (strcmp(*CMD_ARGV, "sysresetreq") == 0) - cortex_m->soft_reset_config = CORTEX_M_RESET_SYSRESETREQ; - - else if (strcmp(*CMD_ARGV, "vectreset") == 0) { - if (target_was_examined(target) - && !cortex_m->vectreset_supported) - LOG_TARGET_WARNING(target, "VECTRESET is not supported on your Cortex-M core!"); - else - cortex_m->soft_reset_config = CORTEX_M_RESET_VECTRESET; - - } else - return ERROR_COMMAND_SYNTAX_ERROR; - } + if (!CMD_ARGC) { + char *reset_config; - switch (cortex_m->soft_reset_config) { + switch (cortex_m->soft_reset_config) { case CORTEX_M_RESET_SYSRESETREQ: reset_config = "sysresetreq"; break; @@ -3114,9 +3100,26 @@ COMMAND_HANDLER(handle_cortex_m_reset_config_command) default: reset_config = "unknown"; break; + } + + command_print(CMD, "%s", reset_config); + return ERROR_OK; + } else if (CMD_ARGC != 1) { + return ERROR_COMMAND_SYNTAX_ERROR; } - command_print(CMD, "cortex_m reset_config %s", reset_config); + if (!strcmp(CMD_ARGV[0], "sysresetreq")) { + cortex_m->soft_reset_config = CORTEX_M_RESET_SYSRESETREQ; + } else if (!strcmp(CMD_ARGV[0], "vectreset")) { + if (target_was_examined(target) + && !cortex_m->vectreset_supported) + LOG_TARGET_WARNING(target, "VECTRESET is not supported on your Cortex-M core"); + else + cortex_m->soft_reset_config = CORTEX_M_RESET_VECTRESET; + } else { + command_print(CMD, "invalid reset config '%s'", CMD_ARGV[0]); + return ERROR_COMMAND_ARGUMENT_INVALID; + } return ERROR_OK; } --