Date: Wed, 12 Sep 2012 14:00:12 GMT From: Ed Maste <emaste@freebsd.org> To: freebsd-standards@FreeBSD.org Subject: Re: standards/171572: ptsname(-1) returns errno 0 Message-ID: <201209121400.q8CE0CKJ039092@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR standards/171572; it has been noted by GNATS. From: Ed Maste <emaste@freebsd.org> To: Sergey Kandaurov <pluknet@gmail.com> Cc: bug-followup@freebsd.org Subject: Re: standards/171572: ptsname(-1) returns errno 0 Date: Wed, 12 Sep 2012 09:53:45 -0400 On 12 September 2012 09:40, Sergey Kandaurov <pluknet@gmail.com> wrote: > This is regression (or was it an intended change?) from 8.x's MPSAFE TTY: > > in 8.x ptsname() was changed so that: > /* Make sure ptsname() does not overwrite errno. */ It looks like it was intentional, probably based on: http://pubs.opengroup.org/onlinepubs/007904975/functions/ptsname.html: ERRORS No errors are defined I guess this was interpreted as "shall not set errno." However - http://austingroupbugs.net/view.php?id=503: At line 54750, after "shall return a null pointer", add ", and may set errno". At line 54754, replace "No errors are defined." with: The ptsname( ) function may fail if: [EBADF] The fildes argument is not a valid file descriptor. [ENOTTY] The file associated with the fildes argument is not a master pseudo-terminal device.. There's some further discussion on ENOTTY vs EINVAL there. It looks like we should at least set errno though: Index: stdlib/ptsname.c =================================================================== --- stdlib/ptsname.c (revision 240164) +++ stdlib/ptsname.c (working copy) @@ -77,7 +77,6 @@ { static char pt_slave[sizeof _PATH_DEV + SPECNAMELEN] = _PATH_DEV; char *ret = NULL; - int sverrno = errno; /* Make sure fildes points to a master device. */ if (__isptmaster(fildes) != 0) @@ -87,7 +86,6 @@ sizeof pt_slave - (sizeof _PATH_DEV - 1)) != NULL) ret = pt_slave; -done: /* Make sure ptsname() does not overwrite errno. */ - errno = sverrno; +done: return (ret); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201209121400.q8CE0CKJ039092>