tests/exynos: improve error handling
authorTobias Jakobi <tjakobi@math.uni-bielefeld.de>
Tue, 24 Feb 2015 14:20:48 +0000 (15:20 +0100)
committerEmil Velikov <emil.l.velikov@gmail.com>
Tue, 10 Mar 2015 19:21:52 +0000 (19:21 +0000)
Check for a useable connector and also if the resolution is sane
(width and height are both non-zero).

Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Tested-by: Joonyoung Shim <jy0922.shim@samsung.com>
tests/exynos/exynos_fimg2d_test.c

index d89fc23..14b38a9 100644 (file)
@@ -616,10 +616,22 @@ int main(int argc, char **argv)
        connector_find_mode(dev->fd, &con, resources);
        drmModeFreeResources(resources);
 
+       if (!con.mode) {
+               fprintf(stderr, "failed to find usable connector\n");
+               ret = -EFAULT;
+               goto err_drm_close;
+       }
+
        screen_width = con.mode->hdisplay;
        screen_height = con.mode->vdisplay;
 
-       printf("screen width  = %d, screen height = %d\n", screen_width,
+       if (screen_width == 0 || screen_height == 0) {
+               fprintf(stderr, "failed to find sane resolution on connector\n");
+               ret = -EFAULT;
+               goto err_drm_close;
+       }
+
+       printf("screen width = %d, screen height = %d\n", screen_width,
                        screen_height);
 
        bo = exynos_create_buffer(dev, screen_width * screen_height * 4, 0);