Gracefully handle errors in initialization

This commit is contained in:
Juhani Krekelä 2021-11-28 02:00:46 +02:00
parent 81aa5f8071
commit f966c188a7
1 changed files with 6 additions and 7 deletions

View File

@ -10,7 +10,6 @@
#include <sys/keycodes.h>
#include <err.h> //debg
#include <errno.h>
#include <stdint.h>
@ -135,10 +134,13 @@ static unsigned char *sortix_init_driver(unsigned char *param, unsigned char *di
connection = display_connect_default();
if (!connection && errno == ECONNREFUSED)
return "TODO: display_spawn";
display_spawn(g_argc, g_argv);
if (!connection)
return "TODO: Proper error reporting";
if (!connection) {
char err[256];
snprintf(err, sizeof(err), "Error connecting to display: %s\n", strerror(errno));
return stracpy(err);
}
sortix_driver.get_color = get_color_fn(sortix_driver.depth);
@ -153,9 +155,6 @@ static unsigned char *sortix_init_driver(unsigned char *param, unsigned char *di
static struct graphics_device *sortix_init_device(void)
{
if (current_dev)
errx(1, "Attempting to create second window");
struct graphics_device *dev = mem_calloc(sizeof(struct graphics_device));
dev->size.x1 = 0;