Revise usage of print_{error,fatal}()
Let's limit print_fatal() to unexpected conditions. Also added exit_fatal() to save a few lines of code.
This commit is contained in:
@@ -420,10 +420,7 @@ static void
|
||||
setup_signal_handlers (void)
|
||||
{
|
||||
if (pipe (g_signal_pipe) == -1)
|
||||
{
|
||||
print_fatal ("pipe: %s", strerror (errno));
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
exit_fatal ("%s: %s", "pipe", strerror (errno));
|
||||
|
||||
set_cloexec (g_signal_pipe[0]);
|
||||
set_cloexec (g_signal_pipe[1]);
|
||||
@@ -440,17 +437,14 @@ setup_signal_handlers (void)
|
||||
sigemptyset (&sa.sa_mask);
|
||||
|
||||
if (sigaction (SIGCHLD, &sa, NULL) == -1)
|
||||
{
|
||||
print_fatal ("sigaction: %s", strerror (errno));
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
exit_fatal ("sigaction: %s", strerror (errno));
|
||||
|
||||
signal (SIGPIPE, SIG_IGN);
|
||||
|
||||
sa.sa_handler = sigterm_handler;
|
||||
if (sigaction (SIGINT, &sa, NULL) == -1
|
||||
|| sigaction (SIGTERM, &sa, NULL) == -1)
|
||||
print_error ("sigaction: %s", strerror (errno));
|
||||
exit_fatal ("sigaction: %s", strerror (errno));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -587,7 +581,7 @@ setup_recovery_handler (struct bot_context *ctx)
|
||||
bool recover;
|
||||
if (!set_boolean_if_valid (&recover, recover_str))
|
||||
{
|
||||
print_fatal ("invalid configuration value for `%s'", "recover");
|
||||
print_error ("invalid configuration value for `%s'", "recover");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
if (!recover)
|
||||
@@ -968,7 +962,7 @@ plugin_load (struct bot_context *ctx, const char *name, struct error **e)
|
||||
execve (argv[0], argv, environ);
|
||||
|
||||
// We will collect the failure later via SIGCHLD
|
||||
print_fatal ("%s: %s: %s",
|
||||
print_error ("%s: %s: %s",
|
||||
"failed to load the plugin", "exec", strerror (errno));
|
||||
_exit (EXIT_FAILURE);
|
||||
}
|
||||
@@ -1495,7 +1489,7 @@ on_irc_readable (const struct pollfd *fd, struct bot_context *ctx)
|
||||
|
||||
if (buf->len >= (1 << 20))
|
||||
{
|
||||
print_fatal ("the IRC server seems to spew out data frantically");
|
||||
print_error ("the IRC server seems to spew out data frantically");
|
||||
irc_shutdown (ctx);
|
||||
goto end;
|
||||
}
|
||||
@@ -1703,7 +1697,7 @@ main (int argc, char *argv[])
|
||||
call_write_default_config (optarg, g_config_table);
|
||||
exit (EXIT_SUCCESS);
|
||||
default:
|
||||
print_fatal ("error in options");
|
||||
print_error ("wrong options");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
@@ -1723,7 +1717,7 @@ main (int argc, char *argv[])
|
||||
struct error *e = NULL;
|
||||
if (!read_config_file (&ctx.config, &e))
|
||||
{
|
||||
print_fatal ("error loading configuration: %s", e->message);
|
||||
print_error ("error loading configuration: %s", e->message);
|
||||
error_free (e);
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user