[PATCH weston 2/3] simple-dmabuf-drm: don't exit from create_display

Guido Günther agx at sigxcpu.org
Tue Mar 20 10:36:37 UTC 2018


Only exit from main so control flow is in one place.

Signed-off-by: Guido Günther <agx at sigxcpu.org>
---
 clients/simple-dmabuf-drm.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/clients/simple-dmabuf-drm.c b/clients/simple-dmabuf-drm.c
index 1c062fad..b9681ca4 100644
--- a/clients/simple-dmabuf-drm.c
+++ b/clients/simple-dmabuf-drm.c
@@ -767,7 +767,7 @@ create_display(int opts, int format)
 	display = malloc(sizeof *display);
 	if (display == NULL) {
 		fprintf(stderr, "out of memory\n");
-		exit(1);
+		return NULL;
 	}
 	display->display = wl_display_connect(NULL);
 	assert(display->display);
@@ -790,7 +790,7 @@ create_display(int opts, int format)
 	wl_display_roundtrip(display->display);
 	if (display->dmabuf == NULL) {
 		fprintf(stderr, "No zwp_linux_dmabuf global\n");
-		exit(1);
+		return NULL;
 	}
 
 	wl_display_roundtrip(display->display);
@@ -799,7 +799,7 @@ create_display(int opts, int format)
 		(format == DRM_FORMAT_NV12 && (!display->nv12_format_found ||
 			!display->nv12_modifier_found))) {
 		fprintf(stderr, "requested format is not available\n");
-		exit(1);
+		return NULL;
 	}
 
 	return display;
@@ -909,6 +909,8 @@ main(int argc, char **argv)
 	}
 
 	display = create_display(opts, import_format);
+	if (!display)
+		return 1;
 	window = create_window(display, 256, 256, import_format, opts);
 	if (!window)
 		return 1;
-- 
2.16.1



More information about the wayland-devel mailing list