[RFC wayland 03/18] os: make set_cloexec_or_close private instead of static

Derek Foreman derekf at osg.samsung.com
Tue Feb 9 16:55:50 UTC 2016


the cursor stuff has a copy of this, so let's share it.

Signed-off-by: Derek Foreman <derekf at osg.samsung.com>
---
 src/wayland-os.c | 14 +++++++-------
 src/wayland-os.h |  3 +++
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/src/wayland-os.c b/src/wayland-os.c
index 93b6f5f..2cc87a1 100644
--- a/src/wayland-os.c
+++ b/src/wayland-os.c
@@ -35,8 +35,8 @@
 #include "../config.h"
 #include "wayland-os.h"
 
-static int
-set_cloexec_or_close(int fd)
+int
+wl_os_set_cloexec_or_close(int fd)
 {
 	long flags;
 
@@ -69,7 +69,7 @@ wl_os_socket_cloexec(int domain, int type, int protocol)
 		return -1;
 
 	fd = socket(domain, type, protocol);
-	return set_cloexec_or_close(fd);
+	return wl_os_set_cloexec_or_close(fd);
 }
 
 int
@@ -84,7 +84,7 @@ wl_os_dupfd_cloexec(int fd, long minfd)
 		return -1;
 
 	newfd = fcntl(fd, F_DUPFD, minfd);
-	return set_cloexec_or_close(newfd);
+	return wl_os_set_cloexec_or_close(newfd);
 }
 
 static ssize_t
@@ -112,7 +112,7 @@ recvmsg_cloexec_fallback(int sockfd, struct msghdr *msg, int flags)
 		data = CMSG_DATA(cmsg);
 		end = (int *)(data + cmsg->cmsg_len - CMSG_LEN(0));
 		for (fd = (int *)data; fd < end; ++fd)
-			*fd = set_cloexec_or_close(*fd);
+			*fd = wl_os_set_cloexec_or_close(*fd);
 	}
 
 	return len;
@@ -146,7 +146,7 @@ wl_os_epoll_create_cloexec(void)
 #endif
 
 	fd = epoll_create(1);
-	return set_cloexec_or_close(fd);
+	return wl_os_set_cloexec_or_close(fd);
 }
 
 int
@@ -163,5 +163,5 @@ wl_os_accept_cloexec(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
 #endif
 
 	fd = accept(sockfd, addr, addrlen);
-	return set_cloexec_or_close(fd);
+	return wl_os_set_cloexec_or_close(fd);
 }
diff --git a/src/wayland-os.h b/src/wayland-os.h
index f51efaa..e756841 100644
--- a/src/wayland-os.h
+++ b/src/wayland-os.h
@@ -27,6 +27,9 @@
 #define WAYLAND_OS_H
 
 int
+wl_os_set_cloexec_or_close(int fd);
+
+int
 wl_os_socket_cloexec(int domain, int type, int protocol);
 
 int
-- 
2.7.0



More information about the wayland-devel mailing list