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
This commit is contained in:
Stefano Ceccherini
2004-04-16 08:39:12 +00:00
parent 2e90a0fca0
commit 7d60c514f8
+9 -8
View File
@@ -74,7 +74,7 @@ BSerialPort::BSerialPort()
*/ */
BSerialPort::~BSerialPort() BSerialPort::~BSerialPort()
{ {
if (ffd > 0) if (ffd >= 0)
close(ffd); close(ffd);
for (int32 count = _fDevices->CountItems() - 1; count >= 0; count--) 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 // to some issues. I added this flag having read some comments
// by Marco Nelissen on the annotated BeBook. // by Marco Nelissen on the annotated BeBook.
// I think BeOS uses O_RDWR|O_NONBLOCK here. // 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 //Setup the port
int ret = fcntl(ffd, F_GETFL); int ret = fcntl(ffd, F_GETFL);
fcntl(ffd, F_SETFL, ret & 0x7F); 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, // TODO: I wonder why the return type is a status_t,
// since we (as BeOS does) return the descriptor number for the device... // 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 void
BSerialPort::Close(void) BSerialPort::Close(void)
{ {
if (ffd > 0) if (ffd >= 0)
close(ffd); close(ffd);
ffd = -1; 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 void
BSerialPort::SetDataBits(data_bits numBits) BSerialPort::SetDataBits(data_bits numBits)
{ {
@@ -361,7 +362,7 @@ BSerialPort::SetDTR(bool asserted)
{ {
status_t status = ioctl(ffd, TCSETDTR, &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); status_t status = ioctl(ffd, TCSETRTS, &asserted);
return (status > 0) ? status : errno; return (status >= 0) ? status : errno;
} }