* 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
* 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;
* 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
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;
}
/**
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;
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;
}
break;
case 2: /* assign */
if (session) {
- /* can't change session's transport after-the-fact */
- LOG_ERROR("session's transport is already selected.");
- return JIM_ERR;
+ if (!strcmp(session->name, argv[1]->bytes)) {
+ LOG_WARNING("Transport \"%s\" was already selected", session->name);
+ return JIM_OK;
+ } else {
+ LOG_ERROR("Can't change session's transport after the initial selection was made");
+ return JIM_ERR;
+ }
}
/* Is this transport supported by our debug adapter?