From 425efd1c0dd271d779154819ff1c6e081418201b Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Mon, 29 Oct 2007 09:56:30 +0000 Subject: [PATCH] Added a shorter implementation for the serial_set_status function. --- serial_posix.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/serial_posix.c b/serial_posix.c index e320a74..982bc24 100644 --- a/serial_posix.c +++ b/serial_posix.c @@ -564,18 +564,9 @@ serial_send_break (serial *device) static int serial_set_status (int fd, int value, int level) { - int bits; - if (ioctl (fd, TIOCMGET, &bits)) { - TRACE ("ioctl"); - return -1; - } + int action = (level ? TIOCMBIS : TIOCMBIC); - if (level) - bits |= value; - else - bits &= value; - - if (ioctl (fd, TIOCMSET, &bits)) { + if (ioctl (fd, action, &value) != 0) { TRACE ("ioctl"); return -1; }