From 75a4759d3348a7faa7bade670dab96fd5e37edf7 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Mon, 13 Jun 2011 23:58:26 +0000 Subject: [PATCH] Since the c_ispeed and c_ospeed fields are marked unused, and since I don't see how one could actually apply different speeds, make cf{set|get}{i|o}speed() use the c_cflag field with the CBAUD mask instead. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42160 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/libroot/posix/termios.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/system/libroot/posix/termios.c b/src/system/libroot/posix/termios.c index 25c7b472cb..77d3e8dd46 100644 --- a/src/system/libroot/posix/termios.c +++ b/src/system/libroot/posix/termios.c @@ -103,7 +103,7 @@ tcsendbreak(int fd, int duration) speed_t cfgetispeed(const struct termios *termios) { - return termios->c_ispeed; + return termios->c_cflag & CBAUD; } @@ -115,12 +115,13 @@ cfsetispeed(struct termios *termios, speed_t speed) the maximum value defined in termios.h Note that errors from hardware device are detected only until the tcsetattr() function is called */ - if (speed > B230400) { + if (speed > B230400 || (speed & CBAUD) != speed) { errno = EINVAL; return -1; } - termios->c_ispeed = speed; + termios->c_cflag &= ~CBAUD; + termios->c_cflag |= speed; return 0; } @@ -128,7 +129,7 @@ cfsetispeed(struct termios *termios, speed_t speed) speed_t cfgetospeed(const struct termios *termios) { - return termios->c_ospeed; + return termios->c_cflag & CBAUD; } @@ -136,11 +137,12 @@ int cfsetospeed(struct termios *termios, speed_t speed) { /* Check for unaccepted speed values (see above) */ - if (speed > B230400) { + if (speed > B230400 || (speed & CBAUD) != speed) { errno = EINVAL; return -1; } - termios->c_ospeed = speed; + termios->c_cflag &= ~CBAUD; + termios->c_cflag |= speed; return 0; }