Browse Source

server: avoid the tcl server crashing when there is no target

Since commit 1d0cf0df37
("server: tcl_notifications command") connecting to the tcl server
would terminate openocd. Fix this.

Change-Id: I36e2a7482f7db3a30ff7e9f969c3b6cda9599382
Signed-off-by: Austin Morton <austinpmorton@gmail.com>
Reviewed-on: http://openocd.zylin.com/2759
Tested-by: jenkins
Reviewed-by: Forest Crossman <cyrozap@gmail.com>
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
tags/v0.9.0
Austin Morton 6 years ago
committed by Paul Fertser
parent
commit
38cb629ddf
3 changed files with 3 additions and 2 deletions
  1. +1
    -1
      src/server/tcl_server.c
  2. +1
    -1
      src/target/target.c
  3. +1
    -0
      src/target/target.h

+ 1
- 1
src/server/tcl_server.c View File

@@ -123,7 +123,7 @@ static int tcl_new_connection(struct connection *connection)
memset(tclc, 0, sizeof(struct tcl_connection));
connection->priv = tclc;

struct target *target = get_current_target(connection->cmd_ctx);
struct target *target = get_target_by_num(connection->cmd_ctx->current_target);
if (target != NULL)
tclc->tc_laststate = target->state;



+ 1
- 1
src/target/target.c View File

@@ -486,7 +486,7 @@ struct target *get_target(const char *id)
}

/* returns a pointer to the n-th configured target */
static struct target *get_target_by_num(int num)
struct target *get_target_by_num(int num)
{
struct target *target = all_targets;



+ 1
- 0
src/target/target.h View File

@@ -356,6 +356,7 @@ int target_call_timer_callbacks(void);
*/
int target_call_timer_callbacks_now(void);

struct target *get_target_by_num(int num);
struct target *get_current_target(struct command_context *cmd_ctx);
struct target *get_target(const char *id);



Loading…
Cancel
Save