Eric Blake wrote:
> +  result = ptsname_r (fd, NULL, 0);

On glibc 2.11, with CPPFLAGS=-Wall, this code gives a warning:

test-ptsname_r.c: In function 'test_errors':
test-ptsname_r.c:88:3: warning: null argument where non-null required (argument 
2)

I'm copying the trick from test-memmem.c:


2011-11-10  Bruno Haible  <br...@clisp.org>

        ptsname_r test: Avoid gcc warning on glibc systems.
        * tests/test-ptsname_r.c (null_ptr): New function.
        (test_errors): Use it.

--- tests/test-ptsname_r.c.orig Thu Nov 10 13:55:45 2011
+++ tests/test-ptsname_r.c      Thu Nov 10 13:54:31 2011
@@ -53,6 +53,12 @@
               && SAME_INODE (statbuf1, statbuf2)));
 }
 
+static char *
+null_ptr (void)
+{
+  return NULL;
+}
+
 static void
 test_errors (int fd, const char *slave)
 {
@@ -86,7 +92,7 @@
     }
 
   errno = 0;
-  result = ptsname_r (fd, NULL, 0);
+  result = ptsname_r (fd, null_ptr (), 0);
   ASSERT (result != 0);
   ASSERT (result == errno);
   ASSERT (errno == EINVAL);

-- 
In memoriam Cornstalk <http://en.wikipedia.org/wiki/Cornstalk>

Reply via email to