[rtems commit] termios: Simplify some calculations

Sebastian Huber sebh at rtems.org
Tue Feb 28 08:44:05 UTC 2017


Module:    rtems
Branch:    master
Commit:    f71ccc345e7347b5913d198a147af281351f9db1
Changeset: http://git.rtems.org/rtems/commit/?id=f71ccc345e7347b5913d198a147af281351f9db1

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Tue Feb 28 09:12:13 2017 +0100

termios: Simplify some calculations

Use the modular arithmetic addition rule.

---

 cpukit/libcsupport/src/termios.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/cpukit/libcsupport/src/termios.c b/cpukit/libcsupport/src/termios.c
index d105899..9eace2e 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))




More information about the vc mailing list