Compare commits

...

2 Commits

Author SHA1 Message Date
Juhani Krekelä dea1e15e75 Gracefully handle errors in initialization 2021-11-28 02:00:46 +02:00
Juhani Krekelä 25a52b7327 Handle -mode 2021-11-28 02:00:34 +02:00
1 changed files with 11 additions and 11 deletions

View File

@ -10,7 +10,6 @@
#include <sys/keycodes.h>
#include <err.h> //debg
#include <errno.h>
#include <stdint.h>
@ -127,17 +126,21 @@ static void sortix_process_events(void *data)
static unsigned char *sortix_init_driver(unsigned char *param, unsigned char *display)
{
if (param && *param)
errx(1, "param %s", param);
if (display && *display)
errx(1, "display %s", display);
if (param) {
if (sscanf(param, "%ix%i", &default_window_width, &default_window_height) != 2)
return stracpy("-mode syntax is WIDTHxHEIGHT\n");
}
(void) display; // Only used by the X11 driver
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);
@ -152,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;