From e1c4c3fcab76ad6c8faf06e2c257795d005e0a58 Mon Sep 17 00:00:00 2001 From: Sergey Prokhorov Date: Fri, 4 Oct 2024 01:36:24 +0200 Subject: [PATCH] Shutdown gradually if not able to initialize display --- 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 7d57d7d..21d322b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -679,7 +679,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;