Skip to content

Commit

Permalink
n_tty: Eliminate counter in __process_echoes
Browse files Browse the repository at this point in the history
Since neither echo_commit nor echo_tail can change for the duration
of __process_echoes loop, substitute index comparison for the
snapshot counter.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Peter Hurley authored and Greg Kroah-Hartman committed Jul 24, 2013
1 parent bc5b1ec commit 29c7c5c
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions drivers/tty/n_tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -656,8 +656,7 @@ static size_t __process_echoes(struct tty_struct *tty)
old_space = space = tty_write_room(tty);

tail = ldata->echo_tail;
nr = ldata->echo_commit - ldata->echo_tail;
while (nr > 0) {
while (ldata->echo_commit != tail) {
c = echo_buf(ldata, tail);
if (c == ECHO_OP_START) {
unsigned char op;
Expand Down Expand Up @@ -701,20 +700,17 @@ static size_t __process_echoes(struct tty_struct *tty)
ldata->column--;
}
tail += 3;
nr -= 3;
break;

case ECHO_OP_SET_CANON_COL:
ldata->canon_column = ldata->column;
tail += 2;
nr -= 2;
break;

case ECHO_OP_MOVE_BACK_COL:
if (ldata->column > 0)
ldata->column--;
tail += 2;
nr -= 2;
break;

case ECHO_OP_START:
Expand All @@ -727,7 +723,6 @@ static size_t __process_echoes(struct tty_struct *tty)
ldata->column++;
space--;
tail += 2;
nr -= 2;
break;

default:
Expand All @@ -749,7 +744,6 @@ static size_t __process_echoes(struct tty_struct *tty)
ldata->column += 2;
space -= 2;
tail += 2;
nr -= 2;
}

if (no_space_left)
Expand All @@ -767,7 +761,6 @@ static size_t __process_echoes(struct tty_struct *tty)
space -= 1;
}
tail += 1;
nr -= 1;
}
}

Expand Down

0 comments on commit 29c7c5c

Please sign in to comment.