commit: 524da715999b0e6ef5203e4e89af83fb06b88db9
parent: fa848ebfa7a0d7ed447cc123d71339c37720416e
author: Chris Noxz <chris@noxz.tech>
date: Tue, 14 Mar 2023 08:05:32 +0100
simplify die function
2 files changed, 7 insertions(+), 11 deletions(-)
diff --git a/browser.c b/browser.c
@@ -38,7 +38,7 @@ client_create(const gchar *uri, WebKitWebView *related_wv, gboolean show,
}
if (!(c = calloc(1, sizeof(struct Client))))
- die("%s: fatal: calloc failed\n", __NAME__);
+ die(__NAME__ ": fatal: calloc failed\n");
if (related_wv == NULL)
c->wv = webkit_web_view_new();
@@ -252,13 +252,9 @@ create_context_menu(struct Client *c, WebKitContextMenu *context_menu,
}
void
-die(const char *fmt, ...)
+die(const char *msg)
{
- va_list ap;
-
- va_start(ap, fmt);
- vfprintf(stderr, fmt, ap);
- va_end(ap);
+ fprintf(stderr, msg);
exit(EXIT_FAILURE);
}
@@ -317,7 +313,7 @@ ipc_setup(void)
/* fail hard if fifo cannot be created */
if (!g_file_test(p, G_FILE_TEST_EXISTS) && mkfifo(p, 0600) == -1)
- die("%s: fatal: mkfifo failed\n", __NAME__);
+ die(__NAME__ ": fatal: mkfifo failed\n");
/* if no one is listening create the ipc host instance */
if ((gl.ipc_pipe_fd = open(p, O_WRONLY | O_NONBLOCK)) == -1) {
@@ -653,7 +649,7 @@ load_state(void)
}
if (!(u = (char *)malloc(l * sizeof(char))))
- die("%s: fatal: malloc failed\n", __NAME__);
+ die(__NAME__ ": fatal: malloc failed\n");
/* load uris into new clients */
while (getline(&u, &l, fp) >= 0)
@@ -1244,7 +1240,7 @@ main(int argc, char **argv)
gl.ipc = IPC_NONE;
break;
default:
- die("Usage: %s [OPTION]... [URI]...\n", __NAME__);
+ die("Usage: " __NAME__ " [-I] [URI ...]\n");
}
ipc_setup();
diff --git a/browser.h b/browser.h
@@ -191,7 +191,7 @@ static void client_destroy(struct Client *);
static gboolean command(struct Client *, const gchar*);
static void create_context_menu(struct Client *, WebKitContextMenu *,
WebKitHitTestResult *);
-static void die(const char *, ...);
+static void die(const char *);
static gboolean ipc_request(GIOChannel *, GIOCondition, gpointer);
static ssize_t ipc_send(char *);
static void ipc_setup(void);