From f71ccc345e7347b5913d198a147af281351f9db1 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Tue, 28 Feb 2017 09:12:13 +0100 Subject: termios: Simplify some calculations Use the modular arithmetic addition rule. --- cpukit/libcsupport/src/termios.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'cpukit/libcsupport') diff --git a/cpukit/libcsupport/src/termios.c b/cpukit/libcsupport/src/termios.c index d1058997f8..9eace2eeea 100644 --- a/cpukit/libcsupport/src/termios.c +++ b/cpukit/libcsupport/src/termios.c @@ -1533,8 +1533,7 @@ fillBufferQueue (struct rtems_termios_tty *tty) c = tty->rawInBuf.theBuf[newHead]; tty->rawInBuf.Head = newHead; - if(((tty->rawInBuf.Tail-newHead+tty->rawInBuf.Size) - % tty->rawInBuf.Size) + if(((tty->rawInBuf.Tail - newHead) % tty->rawInBuf.Size) < tty->lowwater) { tty->flow_ctrl &= ~FL_IREQXOF; /* if tx stopped and XON should be sent... */ @@ -1756,8 +1755,8 @@ rtems_termios_enqueue_raw_characters (void *ttyp, const char *buf, int len) newTail = (oldTail + 1) % tty->rawInBuf.Size; /* if chars_in_buffer > highwater */ - if ((tty->flow_ctrl & FL_IREQXOF) != 0 && (((newTail - head - + tty->rawInBuf.Size) % tty->rawInBuf.Size) > tty->highwater)) { + if ((tty->flow_ctrl & FL_IREQXOF) != 0 && (((newTail - head) % + tty->rawInBuf.Size) > tty->highwater)) { /* incoming data stream should be stopped */ tty->flow_ctrl |= FL_IREQXOF; if ((tty->flow_ctrl & (FL_MDXOF | FL_ISNTXOF)) -- cgit v1.2.3