[PATCH:shmfd 1/2] Bail if make_shm fails

Alan Coopersmith alan.coopersmith at oracle.com
Thu Nov 7 20:55:43 PST 2013


For instance, if the specified path doesn't exist.

Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 shmfd.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/shmfd.c b/shmfd.c
index 45b9067..4dee9de 100644
--- a/shmfd.c
+++ b/shmfd.c
@@ -95,6 +95,10 @@ main (int argc, char **argv)
 	uint32_t		size = WIDTH * HEIGHT * 4;
 
 	fd = make_shm(size, &addr);	/* some memory */
+	if (fd < 0) {
+		perror("make_shm");
+		exit(1);
+	}
 	paint(addr, WIDTH, HEIGHT, 0);
 	printf ("painted\n");
 	c = xcb_connect(NULL, &screen_num);
-- 
1.7.9.2



More information about the xorg-devel mailing list