From 7d60c514f8d138b3c8d34275fb063737e6a0a343 Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Fri, 16 Apr 2004 08:39:12 +0000 Subject: [PATCH] Last famous words... Corrected some issues pointed out by Axel git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7221 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/device/SerialPort.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/kits/device/SerialPort.cpp b/src/kits/device/SerialPort.cpp index bfc7245432..6cb74dda37 100644 --- a/src/kits/device/SerialPort.cpp +++ b/src/kits/device/SerialPort.cpp @@ -74,7 +74,7 @@ BSerialPort::BSerialPort() */ BSerialPort::~BSerialPort() { - if (ffd > 0) + if (ffd >= 0) close(ffd); for (int32 count = _fDevices->CountItems() - 1; count >= 0; count--) @@ -112,9 +112,9 @@ BSerialPort::Open(const char *portName) // to some issues. I added this flag having read some comments // by Marco Nelissen on the annotated BeBook. // I think BeOS uses O_RDWR|O_NONBLOCK here. - ffd = open(buf, O_RDWR|O_NONBLOCK|O_EXCL); + ffd = open(buf, O_RDWR | O_NONBLOCK | O_EXCL); - if (ffd > 0) { + if (ffd >= 0) { //Setup the port int ret = fcntl(ffd, F_GETFL); fcntl(ffd, F_SETFL, ret & 0x7F); @@ -123,7 +123,7 @@ BSerialPort::Open(const char *portName) } // TODO: I wonder why the return type is a status_t, // since we (as BeOS does) return the descriptor number for the device... - return (ffd > 0) ? ffd : errno; + return (ffd >= 0) ? ffd : errno; } @@ -132,7 +132,7 @@ BSerialPort::Open(const char *portName) void BSerialPort::Close(void) { - if (ffd > 0) + if (ffd >= 0) close(ffd); ffd = -1; } @@ -244,7 +244,8 @@ BSerialPort::DataRate(void) } -/* Set the data bits (7 or 8) */ +/*! \brief Set the data bits (7 or 8) +*/ void BSerialPort::SetDataBits(data_bits numBits) { @@ -361,7 +362,7 @@ BSerialPort::SetDTR(bool asserted) { status_t status = ioctl(ffd, TCSETDTR, &asserted); - return (status > 0) ? status : errno; + return (status >= 0) ? status : errno; } @@ -371,7 +372,7 @@ BSerialPort::SetRTS(bool asserted) { status_t status = ioctl(ffd, TCSETRTS, &asserted); - return (status > 0) ? status : errno; + return (status >= 0) ? status : errno; }