]> sourceware.org Git - newlib-cygwin.git/commitdiff
Cygwin: ptsname_r: always return an error number on failure
authorKen Brown <kbrown@cornell.edu>
Wed, 20 Jan 2021 17:01:13 +0000 (12:01 -0500)
committerKen Brown <kbrown@cornell.edu>
Fri, 22 Jan 2021 15:36:43 +0000 (10:36 -0500)
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

winsup/cygwin/release/3.2.0
winsup/cygwin/syscalls.cc

index 43725cec2f8be80909b20fe8d13a3401da201e87..f748a9bc8a6e110105c1b06cdd3687a40725978c 100644 (file)
@@ -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
index 7044ea903d71a4bd6409e95d7c90fddfdd04e2f1..c985142ebeb6e25c9497b4be294ad1c85bd45a36 100644 (file)
@@ -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);
 }
 
This page took 0.036342 seconds and 5 git commands to generate.