[RFC wayland 02/18] os-compatability: Allow creation of 0 byte anonymous files

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


posix_fallocate will fail if passed a 0 size, but we don't actually need
to call it if we have a 0 size, so return early.

Signed-off-by: Derek Foreman <derekf at osg.samsung.com>
---
 cursor/os-compatibility.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/cursor/os-compatibility.c b/cursor/os-compatibility.c
index d7d4b33..9791f97 100644
--- a/cursor/os-compatibility.c
+++ b/cursor/os-compatibility.c
@@ -129,6 +129,9 @@ os_create_anonymous_file(off_t size)
 	if (fd < 0)
 		return -1;
 
+	if (!size)
+		return fd;
+
 #ifdef HAVE_POSIX_FALLOCATE
 	ret = posix_fallocate(fd, 0, size);
 	if (ret != 0) {
-- 
2.7.0



More information about the wayland-devel mailing list