vfs:aio_fork: simplify checking of MSG_CONTROL and MSG_ACCTRIGHTS
authorMichael Adam <obnox@samba.org>
Sat, 31 May 2014 09:58:01 +0000 (11:58 +0200)
committerMichael Adam <obnox@samba.org>
Mon, 2 Jun 2014 20:48:12 +0000 (22:48 +0200)
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source3/modules/vfs_aio_fork.c

index dc33031d677eadd5bfcb61ed9c34324178e5f07a..c3dc188ec983271aff5ca8ae7ef388a2128b7586 100644 (file)
 #include "lib/async_req/async_sock.h"
 #include "lib/util/tevent_unix.h"
 
+#if !defined(HAVE_MSGHDR_MSG_CONTROL) && !defined(HAVE_MSGHDR_MSG_ACCTRIGHTS)
+# error Can not pass file descriptors
+#endif
+
 #undef recvmsg
 
 #ifndef MAP_FILE
@@ -152,9 +156,11 @@ static ssize_t read_fd(int fd, void *ptr, size_t nbytes, int *recvfd)
        ssize_t n;
 #ifndef HAVE_MSGHDR_MSG_CONTROL
        int newfd;
-#endif
 
-#ifdef HAVE_MSGHDR_MSG_CONTROL
+       msg.msg_accrights = (caddr_t) &newfd;
+       msg.msg_accrightslen = sizeof(int);
+#else
+
        union {
          struct cmsghdr        cm;
          char                          control[CMSG_SPACE(sizeof(int))];
@@ -163,13 +169,6 @@ static ssize_t read_fd(int fd, void *ptr, size_t nbytes, int *recvfd)
 
        msg.msg_control = control_un.control;
        msg.msg_controllen = sizeof(control_un.control);
-#else
-#if HAVE_MSGHDR_MSG_ACCTRIGHTS
-       msg.msg_accrights = (caddr_t) &newfd;
-       msg.msg_accrightslen = sizeof(int);
-#else
-#error Can not pass file descriptors
-#endif
 #endif
 
        msg.msg_name = NULL;