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

Signed-off-by: Guido Günther <[email protected]>
---
 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

_______________________________________________
wayland-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to