Gracefully handle errors in initialization
This commit is contained in:
parent
81aa5f8071
commit
f966c188a7
1 changed files with 6 additions and 7 deletions
13
sortix.c
13
sortix.c
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
#include <sys/keycodes.h>
|
#include <sys/keycodes.h>
|
||||||
|
|
||||||
#include <err.h> //debg
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
@ -135,10 +134,13 @@ static unsigned char *sortix_init_driver(unsigned char *param, unsigned char *di
|
||||||
|
|
||||||
connection = display_connect_default();
|
connection = display_connect_default();
|
||||||
if (!connection && errno == ECONNREFUSED)
|
if (!connection && errno == ECONNREFUSED)
|
||||||
return "TODO: display_spawn";
|
display_spawn(g_argc, g_argv);
|
||||||
|
|
||||||
if (!connection)
|
if (!connection) {
|
||||||
return "TODO: Proper error reporting";
|
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);
|
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)
|
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));
|
struct graphics_device *dev = mem_calloc(sizeof(struct graphics_device));
|
||||||
|
|
||||||
dev->size.x1 = 0;
|
dev->size.x1 = 0;
|
||||||
|
|
Loading…
Reference in a new issue