changeset 37807:334792ad96b8

accept4-tests: fix to avoid non portable flags * tests/test-accept4.c (main): Pass only SOCK_* flags to accept4(), as they are the only documented ones, and passing others may trigger EINVAL (seen on FreeBSD 10.1-RELEASE). * doc/glibc-functions/accept4.texi: Mention that we don't provide the SOCK_CLOEXEC or SOCK_NONBLOCK defines.
author Pino Toscano <ptoscano@redhat.com>
date Mon, 12 Oct 2015 12:27:10 +0100
parents d8cbd54dd078
children 9033a7d86828
files ChangeLog doc/glibc-functions/accept4.texi tests/test-accept4.c
diffstat 3 files changed, 18 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Oct 10 08:16:48 2015 -0700
+++ b/ChangeLog	Mon Oct 12 12:27:10 2015 +0100
@@ -1,3 +1,12 @@
+2015-10-12  Pino Toscano  <ptoscano@redhat.com>
+
+	accept4-tests: fix to avoid non portable flags
+	* tests/test-accept4.c (main): Pass only SOCK_* flags to accept4(),
+	as they are the only documented ones, and passing others may trigger
+	EINVAL (seen on FreeBSD 10.1-RELEASE).
+	* doc/glibc-functions/accept4.texi: Mention that we don't provide
+	the SOCK_CLOEXEC or SOCK_NONBLOCK defines.
+
 2015-10-06  Pavel Raiskup  <praiskup@redhat.com>
 
 	gnulib-tool: fix tests of 'extensions' module
--- a/doc/glibc-functions/accept4.texi	Sat Oct 10 08:16:48 2015 -0700
+++ b/doc/glibc-functions/accept4.texi	Mon Oct 12 12:27:10 2015 +0100
@@ -16,4 +16,7 @@
 
 Portability problems not fixed by Gnulib:
 @itemize
+@item
+SOCK_CLOEXEC and SOCK_NONBLOCK may not be defined
+as they're also significant to the socket() function.
 @end itemize
--- a/tests/test-accept4.c	Sat Oct 10 08:16:48 2015 -0700
+++ b/tests/test-accept4.c	Mon Oct 12 12:27:10 2015 +0100
@@ -31,6 +31,10 @@
 
 #include "macros.h"
 
+#ifndef SOCK_CLOEXEC
+# define SOCK_CLOEXEC 0
+#endif
+
 int
 main (void)
 {
@@ -43,7 +47,7 @@
 
     errno = 0;
     ASSERT (accept4 (-1, (struct sockaddr *) &addr, &addrlen,
-                     O_CLOEXEC | O_BINARY)
+                     SOCK_CLOEXEC)
             == -1);
     ASSERT (errno == EBADF);
   }
@@ -54,7 +58,7 @@
     close (99);
     errno = 0;
     ASSERT (accept4 (99, (struct sockaddr *) &addr, &addrlen,
-                     O_CLOEXEC | O_BINARY)
+                     SOCK_CLOEXEC)
             == -1);
     ASSERT (errno == EBADF);
   }