This is an automated email from Gerrit. "Antonio Borneo <borneo.anto...@gmail.com>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8692
-- gerrit commit 0b1dacab007ee1732cf2182d2cb15730736b8ba4 Author: Antonio Borneo <borneo.anto...@gmail.com> Date: Sat Jan 4 16:54:14 2025 +0100 transport: deprecate auto-selection of transport Historically, if the user does not specify a transport, OpenOCD select automatically the first transport listed in the adapter driver. This auto-selection can behave differently by changing adapter, so the transport should be enforced in the configuration file. Deprecate the auto-selection and print a warning message when a transport gets auto-selected. There are two cases: - adapter offers one transport only. The code early auto-selects the transport but does not print anything. If later the user selects the transport then no deprecation will be printed during 'transport init'; - user runs 'transport select', e.g. in 'swj-dp' script, and this triggers the auto-selection and the deprecated message. Change-Id: I2e55b9dcc6da77ca937978fbfb36bc365b803f0d Signed-off-by: Antonio Borneo <borneo.anto...@gmail.com> diff --git a/src/transport/transport.c b/src/transport/transport.c index 0af1360369..18c0217da4 100644 --- a/src/transport/transport.c +++ b/src/transport/transport.c @@ -52,6 +52,11 @@ static struct transport *transport_list; */ static const char * const *allowed_transports; +/** + * Adapter supports a single transport; it has been auto-selected + */ +static bool transport_single_is_autoselected; + /** * The transport being used for the current OpenOCD session. */ static struct transport *session; @@ -104,7 +109,8 @@ int allow_transports(struct command_context *ctx, const char * const *vector) /* autoselect if there's no choice ... */ if (!vector[1]) { - LOG_INFO("only one transport option; autoselecting '%s'", vector[0]); + LOG_DEBUG("only one transport option; autoselecting '%s'", vector[0]); + transport_single_is_autoselected = true; return transport_select(ctx, vector[0]); } @@ -182,6 +188,11 @@ COMMAND_HANDLER(handle_transport_init) return ERROR_FAIL; } + if (transport_single_is_autoselected) + LOG_WARNING("DEPRECATED: auto-selecting adapter preferred session transport \"%s\". " + "Use 'transport select <transport>'.", + session->name); + return session->init(CMD_CTX); } @@ -216,8 +227,8 @@ COMMAND_HANDLER(handle_transport_select) command_print(CMD, "Debug adapter does not support any transports? Check config file order."); return ERROR_FAIL; } - LOG_INFO("auto-selecting first available session transport \"%s\". " - "To override use 'transport select <transport>'.", allowed_transports[0]); + LOG_WARNING("DEPRECATED: auto-selecting first available session transport \"%s\". " + "Use 'transport select <transport>'.", allowed_transports[0]); int retval = transport_select(CMD_CTX, allowed_transports[0]); if (retval != ERROR_OK) return retval; @@ -229,6 +240,11 @@ COMMAND_HANDLER(handle_transport_select) /* assign transport */ if (session) { if (!strcmp(session->name, CMD_ARGV[0])) { + if (transport_single_is_autoselected) { + /* Nothing to do, but also nothing to complain */ + transport_single_is_autoselected = false; + return ERROR_OK; + } LOG_WARNING("Transport \"%s\" was already selected", session->name); return ERROR_OK; } --