public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
From: Ken Brown <kbrown@sourceware.org>
To: cygwin-cvs@sourceware.org
Subject: [newlib-cygwin] Cygwin: ptsname_r: always return an error number on failure
Date: Fri, 22 Jan 2021 15:44:36 +0000 (GMT)	[thread overview]
Message-ID: <20210122154436.B035A386EC6C@sourceware.org> (raw)

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);
 }


                 reply	other threads:[~2021-01-22 15:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210122154436.B035A386EC6C@sourceware.org \
    --to=kbrown@sourceware.org \
    --cc=cygwin-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).