On 11/10/2011 05:57 AM, Bruno Haible wrote:
* tests/test-ptsname_r.c: New file.

You are testing that the return value in case of failure is == errno.
This is not documented, neither in the glibc documentation, nor in the
Linux man page. Why should people write

     if (result == EINVAL)

when they can just as well write

     if (errno == EINVAL)

? The latter code is more future-proof.

Not necessarily. On many of the existing standardized *_r functions, and more particularly on ptsname_r, POSIX requires that the function returns an error value, and leaves errno unspecified or requires errno to be unchanged..


Here's a suggested patch:


--- tests/test-ptsname_r.c.orig Thu Nov 10 13:52:13 2011
+++ tests/test-ptsname_r.c      Thu Nov 10 12:38:25 2011
@@ -79,7 +79,6 @@
        else
          {
            ASSERT (result != 0);
-          ASSERT (result == errno);
            ASSERT (errno == ERANGE);
            ASSERT (buffer[0] == 'X');

That's backwards compared to POSIX conventions. If anything, I'd expect a POSIX standardization of ptsname_r to require the return value to be ERANGE, and leave errno unspecified.

--
Eric Blake   ebl...@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Reply via email to