aboutsummaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
authorTarek BOCHKATI <tarek.bouchkati@gmail.com>2021-08-17 13:24:56 +0100
committerAntonio Borneo <borneo.antonio@gmail.com>2021-08-30 13:53:32 +0000
commitefe944dfc9fa9041ec2e006b702e9830f60f04bc (patch)
treeeb0096d2e89af6e093c13fef3e3abc30bb0c69b8 /src/server
parent12e2dfd31ff07d9d13c7f66b799fad90a2698428 (diff)
downloadriscv-openocd-efe944dfc9fa9041ec2e006b702e9830f60f04bc.zip
riscv-openocd-efe944dfc9fa9041ec2e006b702e9830f60f04bc.tar.gz
riscv-openocd-efe944dfc9fa9041ec2e006b702e9830f60f04bc.tar.bz2
server/telnet: cleanup the if statement mixed style
Change-Id: Ie5f67288511d46fa196bc9f41e6af5504244adaa Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6438 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
Diffstat (limited to 'src/server')
-rw-r--r--src/server/telnet_server.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/server/telnet_server.c b/src/server/telnet_server.c
index 697efa1..253591e 100644
--- a/src/server/telnet_server.c
+++ b/src/server/telnet_server.c
@@ -602,16 +602,16 @@ static int telnet_input(struct connection *connection)
while (bytes_read) {
switch (t_con->state) {
case TELNET_STATE_DATA:
- if (*buf_p == 0xff)
+ if (*buf_p == 0xff) {
t_con->state = TELNET_STATE_IAC;
- else {
+ } else {
if (isprint(*buf_p)) { /* printable character */
telnet_insert(connection, buf_p, 1);
- } else { /* non-printable */
+ } else { /* non-printable */
if (*buf_p == 0x1b) { /* escape */
t_con->state = TELNET_STATE_ESCAPE;
t_con->last_escape = '\x00';
- } else if ((*buf_p == 0xd) || (*buf_p == 0xa)) { /* CR/LF */
+ } else if ((*buf_p == 0xd) || (*buf_p == 0xa)) { /* CR/LF */
int retval;
/* skip over combinations with CR/LF and NUL characters */
@@ -710,9 +710,9 @@ static int telnet_input(struct connection *connection)
telnet_write(connection, "\b \b", 3);
}
}
- } else if (*buf_p == 0x15) /* clear line */
+ } else if (*buf_p == 0x15) { /* clear line */
telnet_clear_line(connection, t_con);
- else if (*buf_p == CTRL('B')) { /* cursor left */
+ } else if (*buf_p == CTRL('B')) { /* cursor left */
if (t_con->line_cursor > 0) {
telnet_write(connection, "\b", 1);
t_con->line_cursor--;
@@ -722,15 +722,15 @@ static int telnet_input(struct connection *connection)
if (t_con->line_cursor < t_con->line_size)
telnet_write(connection, t_con->line + t_con->line_cursor++, 1);
t_con->state = TELNET_STATE_DATA;
- } else if (*buf_p == CTRL('P')) /* cursor up */
+ } else if (*buf_p == CTRL('P')) { /* cursor up */
telnet_history_up(connection);
- else if (*buf_p == CTRL('N')) /* cursor down */
+ } else if (*buf_p == CTRL('N')) { /* cursor down */
telnet_history_down(connection);
- else if (*buf_p == CTRL('A'))
+ } else if (*buf_p == CTRL('A')) { /* move the cursor to the beginning of the line */
telnet_move_cursor(connection, 0);
- else if (*buf_p == CTRL('E'))
+ } else if (*buf_p == CTRL('E')) { /* move the cursor to the end of the line */
telnet_move_cursor(connection, t_con->line_size);
- else if (*buf_p == CTRL('K')) { /* kill line to end */
+ } else if (*buf_p == CTRL('K')) { /* kill line to end */
if (t_con->line_cursor < t_con->line_size) {
/* overwrite with space, until end of line, move back */
for (size_t i = t_con->line_cursor; i < t_con->line_size; i++)
@@ -740,10 +740,11 @@ static int telnet_input(struct connection *connection)
t_con->line[t_con->line_cursor] = '\0';
t_con->line_size = t_con->line_cursor;
}
- } else if (*buf_p == '\t')
+ } else if (*buf_p == '\t') {
telnet_auto_complete(connection);
- else
+ } else {
LOG_DEBUG("unhandled nonprintable: %2.2x", *buf_p);
+ }
}
}
break;
@@ -796,10 +797,11 @@ static int telnet_input(struct connection *connection)
} else if (*buf_p == 'H') { /* home key */
telnet_move_cursor(connection, 0);
t_con->state = TELNET_STATE_DATA;
- } else if (*buf_p == '3')
+ } else if (*buf_p == '3') {
t_con->last_escape = *buf_p;
- else
+ } else {
t_con->state = TELNET_STATE_DATA;
+ }
} else if (t_con->last_escape == '3') {
/* Remove character */
if (*buf_p == '~') {