X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Ftransport%2Ftransport.c;h=072a0d38544d59b0c18f0748efe3d10b266753d1;hp=59f49a98c100f9233e8e676c9f28faf875b0a6b0;hb=c7384117c66e8f18896ca09ab8095d6da16bb1e5;hpb=91e054a9eaefcfdb2b4e1afa99494f31481bc777 diff --git a/src/transport/transport.c b/src/transport/transport.c index 59f49a98c1..072a0d3854 100644 --- a/src/transport/transport.c +++ b/src/transport/transport.c @@ -13,7 +13,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifdef HAVE_CONFIG_H @@ -61,7 +61,7 @@ static struct transport *transport_list; * currently selected debug adapter supports. This is declared * by the time that adapter is fully set up. */ -static const char **allowed_transports; +static const char * const *allowed_transports; /** * The transport being used for the current OpenOCD session. */ static struct transport *session; @@ -94,7 +94,7 @@ static int transport_select(struct command_context *ctx, const char *name) * to declare the set of transports supported by an adapter. When * there is only one member of that set, it is automatically selected. */ -int allow_transports(struct command_context *ctx, const char **vector) +int allow_transports(struct command_context *ctx, const char * const *vector) { /* NOTE: caller is required to provide only a list * of *valid* transport names @@ -117,15 +117,9 @@ int allow_transports(struct command_context *ctx, const char **vector) if (!vector[1]) { LOG_INFO("only one transport option; autoselect '%s'", vector[0]); return transport_select(ctx, vector[0]); - } else { - /* guard against user config errors */ - LOG_WARNING("must select a transport."); - while (*vector) { - LOG_DEBUG("allow transport '%s'", *vector); - vector++; - } - return ERROR_OK; } + + return ERROR_OK; } /** @@ -212,7 +206,7 @@ COMMAND_HELPER(transport_list_parse, char ***vector) return ERROR_COMMAND_SYNTAX_ERROR; /* our return vector must be NULL terminated */ - argv = (char **) calloc(n + 1, sizeof(char *)); + argv = calloc(n + 1, sizeof(char *)); if (argv == NULL) return ERROR_FAIL; @@ -246,6 +240,13 @@ COMMAND_HANDLER(handle_transport_init) LOG_DEBUG("%s", __func__); if (!session) { LOG_ERROR("session's transport is not selected."); + + /* no session transport configured, print transports then fail */ + const char * const *vector = allowed_transports; + while (*vector) { + LOG_ERROR("allow transport '%s'", *vector); + vector++; + } return ERROR_FAIL; }