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:01 +0100
User-agent: KMail/1.13.6 (Linux/2.6.37.6-0.5-desktop; KDE/4.6.0; x86_64; ; )

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  <address@hidden>

        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

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