bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/4] ptsname_r-tests: new test module


From: Eric Blake
Subject: Re: [PATCH 2/4] ptsname_r-tests: new test module
Date: Thu, 10 Nov 2011 06:02:24 -0700
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.23) Gecko/20110928 Fedora/3.1.15-1.fc14 Lightning/1.0b3pre Mnenhy/0.8.4 Thunderbird/3.1.15

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   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org



reply via email to

[Prev in Thread] Current Thread [Next in Thread]