From 28bcb8bdf568875eeea1349e39b7958d77c8fcc1 Mon Sep 17 00:00:00 2001 From: Thomas Jansen Date: Sat, 25 Sep 2010 15:00:43 +0200 Subject: eliminate g_error() usage Replaced all occurrences of g_error() with MPD_ERROR() located in a new header file 'mpd_error.h'. This macro uses g_critical() to print the error message and then exits gracefully in contrast to g_error() which would internally call abort() to produce a core dump. The macro name is distinctive and allows to find all places with dubious error handling. The long-term goal is to get rid of MPD_ERROR() altogether. To facilitate the eventual removal of this macro it was added in a new header file rather than to an existing header file. This fixes #2995 and #3007. --- src/event_pipe.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/event_pipe.c') diff --git a/src/event_pipe.c b/src/event_pipe.c index 286256f9..5b519984 100644 --- a/src/event_pipe.c +++ b/src/event_pipe.c @@ -20,6 +20,7 @@ #include "config.h" #include "event_pipe.h" #include "fd_util.h" +#include "mpd_error.h" #include #include @@ -68,7 +69,7 @@ main_notify_event(G_GNUC_UNUSED GIOChannel *source, buffer, sizeof(buffer), &bytes_read, &error); if (status == G_IO_STATUS_ERROR) - g_error("error reading from pipe: %s", error->message); + MPD_ERROR("error reading from pipe: %s", error->message); bool events[PIPE_EVENT_MAX]; g_mutex_lock(event_pipe_mutex); @@ -91,7 +92,7 @@ void event_pipe_init(void) ret = pipe_cloexec_nonblock(event_pipe); if (ret < 0) - g_error("Couldn't open pipe: %s", strerror(errno)); + MPD_ERROR("Couldn't open pipe: %s", strerror(errno)); #ifndef G_OS_WIN32 channel = g_io_channel_unix_new(event_pipe[0]); @@ -150,7 +151,7 @@ void event_pipe_emit(enum pipe_event event) w = write(event_pipe[1], "", 1); if (w < 0 && errno != EAGAIN && errno != EINTR) - g_error("error writing to pipe: %s", strerror(errno)); + MPD_ERROR("error writing to pipe: %s", strerror(errno)); } void event_pipe_emit_fast(enum pipe_event event) -- cgit v1.2.3