From 5761d2c1bf8e9824a04883b42d2b6ee41da206ad Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Tue, 13 Dec 2011 17:56:40 +0100 Subject: Add goto based error-path cleanup to main --- src/interface.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/interface.c') diff --git a/src/interface.c b/src/interface.c index 43b38b8..905ffa3 100644 --- a/src/interface.c +++ b/src/interface.c @@ -241,7 +241,7 @@ resize_gio(GIOChannel *source, GIOCondition condition, gpointer data) } #endif -void +int interface_init(struct context *ctx) { GIOChannel *input_channel; @@ -279,7 +279,7 @@ interface_init(struct context *ctx) sigaddset(&mask, SIGWINCH); if (sigprocmask(SIG_BLOCK, &mask, NULL) == -1) - exit(EXIT_FAILURE); + return -1; ctx->signal_fd = signalfd(-1, &mask, 0); channel = g_io_channel_unix_new(ctx->signal_fd); ctx->resize_source_id = @@ -293,10 +293,12 @@ interface_init(struct context *ctx) #endif input_channel = g_io_channel_unix_new(STDIN_FILENO); if (!input_channel) - exit(EXIT_FAILURE); + return -1; ctx->input_source_id = g_io_add_watch(input_channel, G_IO_IN, interface_get_input, ctx); g_io_channel_unref(input_channel); refresh(); + + return 0; } -- cgit