[libxshmfence PATCH] Check return value from ftruncate

Julien Cristau jcristau at debian.org
Tue Dec 3 11:14:38 PST 2013


Silences compiler warning:

xshmfence_alloc.c: In function 'xshmfence_alloc_shm':
xshmfence_alloc.c:54:11: warning: ignoring return value of 'ftruncate', declared with attribute warn_unused_result [-Wunused-result]
  ftruncate(fd, sizeof (struct xshmfence));
           ^

Signed-off-by: Julien Cristau <jcristau at debian.org>
---
 src/xshmfence_alloc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/xshmfence_alloc.c b/src/xshmfence_alloc.c
index d8d4a40..58416cd 100644
--- a/src/xshmfence_alloc.c
+++ b/src/xshmfence_alloc.c
@@ -51,7 +51,10 @@ xshmfence_alloc_shm(void)
 		return fd;
             unlink(template);
         }
-	ftruncate(fd, sizeof (struct xshmfence));
+	if (ftruncate(fd, sizeof (struct xshmfence)) < 0) {
+            close(fd);
+            return -1;
+        }
         xshmfence_init(fd);
 	return fd;
 }
-- 
1.8.4.3



More information about the xorg-devel mailing list