X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Fserver%2Ftelnet_server.c;fp=src%2Fserver%2Ftelnet_server.c;h=0243c6328eb8205236eaaea6dbb7d3ee3edc4911;hp=d0583a9b3e22f36bd2a8007e689491f0c3a2409a;hb=4e98d44fd1dc67f763f06eeecc0453d65b1290dc;hpb=62329444abc89ad3b37fbb4ebc2edfd1dee23351 diff --git a/src/server/telnet_server.c b/src/server/telnet_server.c index d0583a9b3e..0243c6328e 100644 --- a/src/server/telnet_server.c +++ b/src/server/telnet_server.c @@ -451,8 +451,7 @@ static int telnet_input(struct connection *connection) if (*t_con->line && (prev_line == NULL || strcmp(t_con->line, prev_line))) { /* if the history slot is already taken, free it */ - if (t_con->history[t_con->next_history]) - free(t_con->history[t_con->next_history]); + free(t_con->history[t_con->next_history]); /* add line to history */ t_con->history[t_con->next_history] = strdup(t_con->line); @@ -465,8 +464,7 @@ static int telnet_input(struct connection *connection) t_con->current_history = t_con->next_history; - if (t_con->history[t_con->current_history]) - free(t_con->history[t_con->current_history]); + free(t_con->history[t_con->current_history]); t_con->history[t_con->current_history] = strdup(""); } @@ -647,29 +645,22 @@ static int telnet_connection_closed(struct connection *connection) log_remove_callback(telnet_log_callback, connection); - if (t_con->prompt) { - free(t_con->prompt); - t_con->prompt = NULL; - } + free(t_con->prompt); + t_con->prompt = NULL; /* save telnet history */ telnet_save_history(t_con); for (i = 0; i < TELNET_LINE_HISTORY_SIZE; i++) { - if (t_con->history[i]) { - free(t_con->history[i]); - t_con->history[i] = NULL; - } + free(t_con->history[i]); + t_con->history[i] = NULL; } /* if this connection registered a debug-message receiver delete it */ delete_debug_msg_receiver(connection->cmd_ctx, NULL); - if (connection->priv) { - free(connection->priv); - connection->priv = NULL; - } else - LOG_ERROR("BUG: connection->priv == NULL"); + free(connection->priv); + connection->priv = NULL; return ERROR_OK; }