* 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
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.");
+ LOG_ERROR("session transport was not selected. Use 'transport select <transport>'");
/* no session transport configured, print transports then fail */
- const char **vector = allowed_transports;
+ LOG_ERROR("Transports available:");
+ const char * const *vector = allowed_transports;
while (*vector) {
- LOG_ERROR("allow transport '%s'", *vector);
+ LOG_ERROR("%s", *vector);
vector++;
}
return ERROR_FAIL;
switch (argc) {
case 1: /* return/display */
if (!session) {
- LOG_ERROR("session's transport is not selected.");
+ LOG_ERROR("session transport was not selected. Use 'transport select <transport>'");
return JIM_ERR;
} else {
Jim_SetResultString(interp, session->name, -1);
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?