Skip to content

Commit 29c7c5c

Browse files
peterhurleygregkh
authored andcommitted
n_tty: Eliminate counter in __process_echoes
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>
1 parent bc5b1ec commit 29c7c5c

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

drivers/tty/n_tty.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -656,8 +656,7 @@ static size_t __process_echoes(struct tty_struct *tty)
656656
old_space = space = tty_write_room(tty);
657657

658658
tail = ldata->echo_tail;
659-
nr = ldata->echo_commit - ldata->echo_tail;
660-
while (nr > 0) {
659+
while (ldata->echo_commit != tail) {
661660
c = echo_buf(ldata, tail);
662661
if (c == ECHO_OP_START) {
663662
unsigned char op;
@@ -701,20 +700,17 @@ static size_t __process_echoes(struct tty_struct *tty)
701700
ldata->column--;
702701
}
703702
tail += 3;
704-
nr -= 3;
705703
break;
706704

707705
case ECHO_OP_SET_CANON_COL:
708706
ldata->canon_column = ldata->column;
709707
tail += 2;
710-
nr -= 2;
711708
break;
712709

713710
case ECHO_OP_MOVE_BACK_COL:
714711
if (ldata->column > 0)
715712
ldata->column--;
716713
tail += 2;
717-
nr -= 2;
718714
break;
719715

720716
case ECHO_OP_START:
@@ -727,7 +723,6 @@ static size_t __process_echoes(struct tty_struct *tty)
727723
ldata->column++;
728724
space--;
729725
tail += 2;
730-
nr -= 2;
731726
break;
732727

733728
default:
@@ -749,7 +744,6 @@ static size_t __process_echoes(struct tty_struct *tty)
749744
ldata->column += 2;
750745
space -= 2;
751746
tail += 2;
752-
nr -= 2;
753747
}
754748

755749
if (no_space_left)
@@ -767,7 +761,6 @@ static size_t __process_echoes(struct tty_struct *tty)
767761
space -= 1;
768762
}
769763
tail += 1;
770-
nr -= 1;
771764
}
772765
}
773766

0 commit comments

Comments
 (0)