public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] Cygwin: ptsname_r: always return an error number on failure
@ 2021-01-22 15:44 Ken Brown
  0 siblings, 0 replies; only message in thread
From: Ken Brown @ 2021-01-22 15:44 UTC (permalink / raw)
  To: cygwin-cvs

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=a60a4501b77dca8f30e01327b96171ee89c278f7

commit a60a4501b77dca8f30e01327b96171ee89c278f7
Author: Ken Brown <kbrown@cornell.edu>
Date:   Wed Jan 20 12:01:13 2021 -0500

    Cygwin: ptsname_r: always return an error number on failure
    
    Return EBADF on a bad file descriptor.  Previously 0 was returned, in
    violation of the requirement in
    https://man7.org/linux/man-pages/man3/ptsname_r.3.html that an error
    number should be returned on failure.
    
    We are intentionally deviating from Linux, on which ENOTTY is
    returned.
    
    Addresses: https://lists.gnu.org/archive/html/bug-gnulib/2021-01/msg00245.html

Diff:
---
 winsup/cygwin/release/3.2.0 | 3 +++
 winsup/cygwin/syscalls.cc   | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/winsup/cygwin/release/3.2.0 b/winsup/cygwin/release/3.2.0
index 43725cec2..f748a9bc8 100644
--- a/winsup/cygwin/release/3.2.0
+++ b/winsup/cygwin/release/3.2.0
@@ -52,3 +52,6 @@ Bug Fixes
 - Fix the errno when a path contains .. and the prefix exists but is
   not a directory.
   Addresses: https://lists.gnu.org/archive/html/bug-gnulib/2021-01/msg00214.html
+
+- Fix the return value when ptsname_r(3) is called with a bad file descriptor
+  Addresses: https://lists.gnu.org/archive/html/bug-gnulib/2021-01/msg00245.html
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 7044ea903..c985142eb 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -3392,7 +3392,7 @@ ptsname_r (int fd, char *buf, size_t buflen)
 
   cygheap_fdget cfd (fd);
   if (cfd < 0)
-    return 0;
+    return EBADF;
   return cfd->ptsname_r (buf, buflen);
 }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-01-22 15:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-22 15:44 [newlib-cygwin] Cygwin: ptsname_r: always return an error number on failure Ken Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).