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: Bruno Haible
Subject: Re: [PATCH 2/4] ptsname_r-tests: new test module
Date: Thu, 10 Nov 2011 13:57:19 +0100
User-agent: KMail/1.13.6 (Linux/2.6.37.6-0.5-desktop; KDE/4.6.0; x86_64; ; )

> * 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.

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');
         }
@@ -88,7 +87,6 @@
   errno = 0;
   result = ptsname_r (fd, NULL, 0);
   ASSERT (result != 0);
-  ASSERT (result == errno);
   ASSERT (errno == EINVAL);
 }
 
@@ -109,7 +107,6 @@
     errno = 0;
     result = ptsname_r (-1, buffer, sizeof buffer);
     ASSERT (result != 0);
-    ASSERT (result == errno);
     ASSERT (errno == EBADF || errno == ENOTTY);
   }
 
-- 
In memoriam Cornstalk <http://en.wikipedia.org/wiki/Cornstalk>



reply via email to

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