struct tcl_connection *tclc;
tclc = calloc(1, sizeof(struct tcl_connection));
- if (tclc == NULL)
+ if (!tclc)
return ERROR_CONNECTION_REJECTED;
tclc->tc_line_size = TCL_LINE_INITIAL;
tclc->tc_line = malloc(tclc->tc_line_size);
- if (tclc->tc_line == NULL) {
+ if (!tclc->tc_line) {
free(tclc);
return ERROR_CONNECTION_REJECTED;
}
connection->priv = tclc;
struct target *target = get_current_target_or_null(connection->cmd_ctx);
- if (target != NULL)
+ if (target)
tclc->tc_laststate = target->state;
/* store the connection object on cmd_ctx so we can access it from command handlers */
}
tclc = connection->priv;
- if (tclc == NULL)
+ if (!tclc)
return ERROR_CONNECTION_REJECTED;
/* push as much data into the line as possible */
for (i = 0; i < rlen; i++) {
/* buffer the data */
tclc->tc_line[tclc->tc_lineoffset] = in[i];
- if (tclc->tc_lineoffset < tclc->tc_line_size) {
+ if (tclc->tc_lineoffset + 1 < tclc->tc_line_size) {
tclc->tc_lineoffset++;
} else if (tclc->tc_line_size >= TCL_LINE_MAX) {
/* maximum line size reached, drop line */
tc_line_size_new = TCL_LINE_MAX;
tc_line_new = realloc(tclc->tc_line, tc_line_size_new);
- if (tc_line_new == NULL) {
+ if (!tc_line_new) {
tclc->tc_linedrop = 1;
} else {
tclc->tc_line = tc_line_new;
retval = tcl_output(connection, result, reslen);
if (retval != ERROR_OK)
return retval;
- /* Always output ctrl-d as end of line to allow multiline results */
+ /* Always output ctrl-z as end of line to allow multiline results */
tcl_output(connection, "\x1a", 1);
}
struct connection *connection = NULL;
struct tcl_connection *tclc = NULL;
- if (CMD_CTX->output_handler_priv != NULL)
+ if (CMD_CTX->output_handler_priv)
connection = CMD_CTX->output_handler_priv;
- if (connection != NULL && !strcmp(connection->service->name, "tcl")) {
+ if (connection && !strcmp(connection->service->name, "tcl")) {
tclc = connection->priv;
return CALL_COMMAND_HANDLER(handle_command_parse_bool, &tclc->tc_notify, "Target Notification output ");
} else {
struct connection *connection = NULL;
struct tcl_connection *tclc = NULL;
- if (CMD_CTX->output_handler_priv != NULL)
+ if (CMD_CTX->output_handler_priv)
connection = CMD_CTX->output_handler_priv;
- if (connection != NULL && !strcmp(connection->service->name, "tcl")) {
+ if (connection && !strcmp(connection->service->name, "tcl")) {
tclc = connection->priv;
return CALL_COMMAND_HANDLER(handle_command_parse_bool, &tclc->tc_trace, "Target trace output ");
} else {
{
.name = "tcl_port",
.handler = handle_tcl_port_command,
- .mode = COMMAND_ANY,
+ .mode = COMMAND_CONFIG,
.help = "Specify port on which to listen "
"for incoming Tcl syntax. "
"Read help on 'gdb_port'.",