From e070b646af6b948c462f5287a58d03fe98f89989 Mon Sep 17 00:00:00 2001 From: Sergey Prokhorov Date: Fri, 4 Oct 2024 11:47:50 +0200 Subject: [PATCH] Shutdown gradually if not able to initialize display (#11) --- src/drm.c | 2 +- src/main.cpp | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/drm.c b/src/drm.c index d0b8909..6e49c1d 100644 --- a/src/drm.c +++ b/src/drm.c @@ -539,7 +539,7 @@ int modeset_prepare(int fd, struct modeset_output *output_list, uint16_t mode_wi *output_list = *out; } - if (!output_list) { + if (!out) { fprintf(stderr, "couldn't create any outputs\n"); return -1; } diff --git a/src/main.cpp b/src/main.cpp index 599fcb8..0507a42 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -685,7 +685,11 @@ int main(int argc, char **argv) assert(drm_fd >= 0); output_list = (struct modeset_output *)malloc(sizeof(struct modeset_output)); ret = modeset_prepare(drm_fd, output_list, mode_width, mode_height, mode_vrefresh); - assert(!ret); + if (ret) { + fprintf(stderr, + "cannot initialize display. Is display connected? Is --screen-mode correct?\n"); + return -2; + } ////////////////////////////////// MPI SETUP MppPacket packet;