termios.cc: Restore setting of EBADF appropriately throughout
Brian Ford
ford@vss.fsi.com
Fri Dec 12 19:14:00 GMT 2003
I noticed this while digging through other serial port problems. It
appears to have been lost in version 1.16, although there did not appear
to be a reason for the loss in that change. Please let me know if it was
intentional for some reason that I do not understand. Thanks.
2003-12-12 Brian Ford <ford@vss.fsi.com>
* termios.cc: Restore setting of EBADF appropriately throughout.
Lost in version 1.16.
--
Brian Ford
Senior Realtime Software Engineer
VITAL - Visual Simulation Systems
FlightSafety International
Phone: 314-551-8460
Fax: 314-551-8444
-------------- next part --------------
Index: termios.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/termios.cc,v
retrieving revision 1.26
diff -u -p -r1.26 termios.cc
--- termios.cc 28 Nov 2003 20:55:58 -0000 1.26
+++ termios.cc 12 Dec 2003 19:04:37 -0000
@@ -33,14 +33,12 @@ tcsendbreak (int fd, int duration)
cygheap_fdget cfd (fd);
if (cfd < 0)
- goto out;
-
- if (!cfd->is_tty ())
+ set_errno (EBADF);
+ else if (!cfd->is_tty ())
set_errno (ENOTTY);
else if ((res = cfd->bg_check (-SIGTTOU)) > bg_eof)
res = cfd->tcsendbreak (duration);
-out:
syscall_printf ("%d = tcsendbreak (%d, %d)", res, fd, duration);
return res;
}
@@ -55,14 +53,12 @@ tcdrain (int fd)
cygheap_fdget cfd (fd);
if (cfd < 0)
- goto out;
-
- if (!cfd->is_tty ())
+ set_errno (EBADF);
+ else if (!cfd->is_tty ())
set_errno (ENOTTY);
else if ((res = cfd->bg_check (-SIGTTOU)) > bg_eof)
res = cfd->tcdrain ();
-out:
syscall_printf ("%d = tcdrain (%d)", res, fd);
return res;
}
@@ -75,16 +71,14 @@ tcflush (int fd, int queue)
cygheap_fdget cfd (fd);
if (cfd < 0)
- goto out;
-
- if (!cfd->is_tty ())
+ set_errno (EBADF);
+ else if (!cfd->is_tty ())
set_errno (ENOTTY);
else if (queue != TCIFLUSH && queue != TCOFLUSH && queue != TCIOFLUSH)
- set_errno (EINVAL);
+ set_errno (EINVAL);
else if ((res = cfd->bg_check (-SIGTTOU)) > bg_eof)
res = cfd->tcflush (queue);
-out:
termios_printf ("%d = tcflush (%d, %d)", res, fd, queue);
return res;
}
@@ -97,14 +91,12 @@ tcflow (int fd, int action)
cygheap_fdget cfd (fd);
if (cfd < 0)
- goto out;
-
- if (!cfd->is_tty ())
+ set_errno (EBADF);
+ else if (!cfd->is_tty ())
set_errno (ENOTTY);
else if ((res = cfd->bg_check (-SIGTTOU)) > bg_eof)
res = cfd->tcflow (action);
-out:
syscall_printf ("%d = tcflow (%d, %d)", res, fd, action);
return res;
}
More information about the Cygwin-patches
mailing list