summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Jansen <mithi@mithi.net>2010-09-25 15:00:43 +0200
committerThomas Jansen <mithi@mithi.net>2010-09-25 15:00:43 +0200
commit28bcb8bdf568875eeea1349e39b7958d77c8fcc1 (patch)
tree17397be16e8067a48fd532a581081f68a1b17700
parent9af9fd140032138894e4781caabee8a5a96edab8 (diff)
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.
-rw-r--r--src/audio.c6
-rw-r--r--src/cmdline.c7
-rw-r--r--src/conf.c28
-rw-r--r--src/daemon.c38
-rw-r--r--src/daemon.h4
-rw-r--r--src/decoder/mikmod_decoder_plugin.c5
-rw-r--r--src/decoder_list.c5
-rw-r--r--src/decoder_thread.c3
-rw-r--r--src/encoder/vorbis_encoder.c3
-rw-r--r--src/event_pipe.c7
-rw-r--r--src/inotify_source.c8
-rw-r--r--src/log.c17
-rw-r--r--src/main.c25
-rw-r--r--src/mpd_error.h36
-rw-r--r--src/output/shout_plugin.c5
-rw-r--r--src/output_all.c11
-rw-r--r--src/output_thread.c3
-rw-r--r--src/path.c3
-rw-r--r--src/pcm_mix.c9
-rw-r--r--src/permission.c5
-rw-r--r--src/player_thread.c3
-rw-r--r--src/playlist_list.c3
-rw-r--r--src/replay_gain_config.c21
-rw-r--r--src/sig_handlers.c3
-rw-r--r--src/tag.c5
-rw-r--r--src/update.c3
-rw-r--r--src/zeroconf-avahi.c3
27 files changed, 166 insertions, 103 deletions
diff --git a/src/audio.c b/src/audio.c
index 8759e255f..f9894cf3c 100644
--- a/src/audio.c
+++ b/src/audio.c
@@ -25,6 +25,7 @@
#include "output_plugin.h"
#include "output_all.h"
#include "conf.h"
+#include "mpd_error.h"
#include <glib.h>
@@ -52,6 +53,7 @@ void initAudioConfig(void)
ret = audio_format_parse(&configured_audio_format, param->value,
true, &error);
if (!ret)
- g_error("error parsing \"%s\" at line %i: %s",
- CONF_AUDIO_OUTPUT_FORMAT, param->line, error->message);
+ MPD_ERROR("error parsing \"%s\" at line %i: %s",
+ CONF_AUDIO_OUTPUT_FORMAT, param->line,
+ error->message);
}
diff --git a/src/cmdline.c b/src/cmdline.c
index 747d7c3bb..2c1db890b 100644
--- a/src/cmdline.c
+++ b/src/cmdline.c
@@ -26,6 +26,7 @@
#include "decoder_plugin.h"
#include "output_list.h"
#include "ls.h"
+#include "mpd_error.h"
#ifdef ENABLE_ENCODER
#include "encoder_list.h"
@@ -155,10 +156,8 @@ parse_cmdline(int argc, char **argv, struct options *options,
ret = g_option_context_parse(context, &argc, &argv, &error);
g_option_context_free(context);
- if (!ret) {
- g_error("option parsing failed: %s\n", error->message);
- exit(1);
- }
+ if (!ret)
+ MPD_ERROR("option parsing failed: %s\n", error->message);
if (option_version)
version();
diff --git a/src/conf.c b/src/conf.c
index 476884dac..705942085 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -23,6 +23,7 @@
#include "tokenizer.h"
#include "path.h"
#include "glib_compat.h"
+#include "mpd_error.h"
#include <glib.h>
@@ -498,8 +499,8 @@ config_get_path(const char *name)
path = parsePath(param->value);
if (path == NULL)
- g_error("error parsing \"%s\" at line %i\n",
- name, param->line);
+ MPD_ERROR("error parsing \"%s\" at line %i\n",
+ name, param->line);
g_free(param->value);
return param->value = path;
@@ -517,7 +518,8 @@ config_get_unsigned(const char *name, unsigned default_value)
value = strtol(param->value, &endptr, 0);
if (*endptr != 0 || value < 0)
- g_error("Not a valid non-negative number in line %i", param->line);
+ MPD_ERROR("Not a valid non-negative number in line %i",
+ param->line);
return (unsigned)value;
}
@@ -534,10 +536,10 @@ config_get_positive(const char *name, unsigned default_value)
value = strtol(param->value, &endptr, 0);
if (*endptr != 0)
- g_error("Not a valid number in line %i", param->line);
+ MPD_ERROR("Not a valid number in line %i", param->line);
if (value <= 0)
- g_error("Not a positive number in line %i", param->line);
+ MPD_ERROR("Not a positive number in line %i", param->line);
return (unsigned)value;
}
@@ -569,9 +571,9 @@ bool config_get_bool(const char *name, bool default_value)
success = get_bool(param->value, &value);
if (!success)
- g_error("%s is not a boolean value (yes, true, 1) or "
- "(no, false, 0) on line %i\n",
- name, param->line);
+ MPD_ERROR("%s is not a boolean value (yes, true, 1) or "
+ "(no, false, 0) on line %i\n",
+ name, param->line);
return value;
}
@@ -601,10 +603,10 @@ config_get_block_unsigned(const struct config_param *param, const char *name,
value = strtol(bp->value, &endptr, 0);
if (*endptr != 0)
- g_error("Not a valid number in line %i", bp->line);
+ MPD_ERROR("Not a valid number in line %i", bp->line);
if (value < 0)
- g_error("Not a positive number in line %i", bp->line);
+ MPD_ERROR("Not a positive number in line %i", bp->line);
return (unsigned)value;
}
@@ -621,9 +623,9 @@ config_get_block_bool(const struct config_param *param, const char *name,
success = get_bool(bp->value, &value);
if (!success)
- g_error("%s is not a boolean value (yes, true, 1) or "
- "(no, false, 0) on line %i\n",
- name, bp->line);
+ MPD_ERROR("%s is not a boolean value (yes, true, 1) or "
+ "(no, false, 0) on line %i\n",
+ name, bp->line);
return value;
}
diff --git a/src/daemon.c b/src/daemon.c
index e08afce4b..852541375 100644
--- a/src/daemon.c
+++ b/src/daemon.c
@@ -65,23 +65,23 @@ daemonize_kill(void)
int pid, ret;
if (pidfile == NULL)
- g_error("no pid_file specified in the config file");
+ MPD_ERROR("no pid_file specified in the config file");
fp = fopen(pidfile, "r");
if (fp == NULL)
- g_error("unable to open pid file \"%s\": %s",
- pidfile, g_strerror(errno));
+ MPD_ERROR("unable to open pid file \"%s\": %s",
+ pidfile, g_strerror(errno));
if (fscanf(fp, "%i", &pid) != 1) {
- g_error("unable to read the pid from file \"%s\"",
- pidfile);
+ MPD_ERROR("unable to read the pid from file \"%s\"",
+ pidfile);
}
fclose(fp);
ret = kill(pid, SIGTERM);
if (ret < 0)
- g_error("unable to kill proccess %i: %s",
- pid, g_strerror(errno));
+ MPD_ERROR("unable to kill proccess %i: %s",
+ pid, g_strerror(errno));
exit(EXIT_SUCCESS);
}
@@ -102,8 +102,8 @@ daemonize_set_user(void)
/* set gid */
if (user_gid != (gid_t)-1 && user_gid != getgid()) {
if (setgid(user_gid) == -1) {
- g_error("cannot setgid to %d: %s",
- (int)user_gid, g_strerror(errno));
+ MPD_ERROR("cannot setgid to %d: %s",
+ (int)user_gid, g_strerror(errno));
}
}
@@ -121,8 +121,8 @@ daemonize_set_user(void)
/* set uid */
if (user_uid != (uid_t)-1 && user_uid != getuid() &&
setuid(user_uid) == -1) {
- g_error("cannot change to uid of user \"%s\": %s",
- user_name, g_strerror(errno));
+ MPD_ERROR("cannot change to uid of user \"%s\": %s",
+ user_name, g_strerror(errno));
}
}
@@ -136,7 +136,7 @@ daemonize_detach(void)
#ifdef HAVE_DAEMON
if (daemon(0, 1))
- g_error("daemon() failed: %s", g_strerror(errno));
+ MPD_ERROR("daemon() failed: %s", g_strerror(errno));
#elif defined(HAVE_FORK)
@@ -144,7 +144,7 @@ daemonize_detach(void)
switch (fork()) {
case -1:
- g_error("fork() failed: %s", g_strerror(errno));
+ MPD_ERROR("fork() failed: %s", g_strerror(errno));
case 0:
break;
default:
@@ -155,14 +155,14 @@ daemonize_detach(void)
/* release the current working directory */
if (chdir("/") < 0)
- g_error("problems changing to root directory");
+ MPD_ERROR("problems changing to root directory");
/* detach from the current session */
setsid();
#else
- g_error("no support for daemonizing");
+ MPD_ERROR("no support for daemonizing");
#endif
g_debug("daemonized!");
@@ -179,8 +179,8 @@ daemonize(bool detach)
g_debug("opening pid file");
fp = fopen(pidfile, "w+");
if (!fp) {
- g_error("could not create pid file \"%s\": %s",
- pidfile, g_strerror(errno));
+ MPD_ERROR("could not create pid file \"%s\": %s",
+ pidfile, g_strerror(errno));
}
}
@@ -200,7 +200,7 @@ daemonize_init(const char *user, const char *group, const char *_pidfile)
if (user) {
struct passwd *pwd = getpwnam(user);
if (!pwd)
- g_error("no such user \"%s\"", user);
+ MPD_ERROR("no such user \"%s\"", user);
user_uid = pwd->pw_uid;
user_gid = pwd->pw_gid;
@@ -214,7 +214,7 @@ daemonize_init(const char *user, const char *group, const char *_pidfile)
if (group) {
struct group *grp = grp = getgrnam(group);
if (!grp)
- g_error("no such group \"%s\"", group);
+ MPD_ERROR("no such group \"%s\"", group);
user_gid = grp->gr_gid;
had_group = true;
}
diff --git a/src/daemon.h b/src/daemon.h
index 4dad7e18d..71039543c 100644
--- a/src/daemon.h
+++ b/src/daemon.h
@@ -20,6 +20,8 @@
#ifndef DAEMON_H
#define DAEMON_H
+#include "mpd_error.h"
+
#include <stdbool.h>
#ifndef WIN32
@@ -51,7 +53,7 @@ daemonize_kill(void);
#include <glib.h>
static inline void
daemonize_kill(void)
-{ g_error("--kill is not available on WIN32"); }
+{ MPD_ERROR("--kill is not available on WIN32"); }
#endif
/**
diff --git a/src/decoder/mikmod_decoder_plugin.c b/src/decoder/mikmod_decoder_plugin.c
index 50b46f2af..91478e86f 100644
--- a/src/decoder/mikmod_decoder_plugin.c
+++ b/src/decoder/mikmod_decoder_plugin.c
@@ -19,6 +19,7 @@
#include "config.h"
#include "decoder_api.h"
+#include "mpd_error.h"
#include <glib.h>
#include <mikmod.h>
@@ -110,8 +111,8 @@ mikmod_decoder_init(const struct config_param *param)
mikmod_sample_rate = config_get_block_unsigned(param, "sample_rate",
44100);
if (!audio_valid_sample_rate(mikmod_sample_rate))
- g_error("Invalid sample rate in line %d: %u",
- param->line, mikmod_sample_rate);
+ MPD_ERROR("Invalid sample rate in line %d: %u",
+ param->line, mikmod_sample_rate);
md_device = 0;
md_reverb = 0;
diff --git a/src/decoder_list.c b/src/decoder_list.c
index f91d635dc..d76050023 100644
--- a/src/decoder_list.c
+++ b/src/decoder_list.c
@@ -22,6 +22,7 @@
#include "decoder_plugin.h"
#include "utils.h"
#include "conf.h"
+#include "mpd_error.h"
#include <glib.h>
@@ -198,8 +199,8 @@ decoder_plugin_config(const char *plugin_name)
const char *name =
config_get_block_string(param, "plugin", NULL);
if (name == NULL)
- g_error("decoder configuration without 'plugin' name in line %d",
- param->line);
+ MPD_ERROR("decoder configuration without 'plugin' name in line %d",
+ param->line);
if (strcmp(name, plugin_name) == 0)
return param;
diff --git a/src/decoder_thread.c b/src/decoder_thread.c
index a75f09d37..1a91b6566 100644
--- a/src/decoder_thread.c
+++ b/src/decoder_thread.c
@@ -32,6 +32,7 @@
#include "mapper.h"
#include "path.h"
#include "uri.h"
+#include "mpd_error.h"
#include <glib.h>
@@ -479,5 +480,5 @@ decoder_thread_start(struct decoder_control *dc)
dc->thread = g_thread_create(decoder_task, dc, true, &e);
if (dc->thread == NULL)
- g_error("Failed to spawn decoder task: %s", e->message);
+ MPD_ERROR("Failed to spawn decoder task: %s", e->message);
}
diff --git a/src/encoder/vorbis_encoder.c b/src/encoder/vorbis_encoder.c
index 0cb8b1b60..986135789 100644
--- a/src/encoder/vorbis_encoder.c
+++ b/src/encoder/vorbis_encoder.c
@@ -22,6 +22,7 @@
#include "encoder_plugin.h"
#include "tag.h"
#include "audio_format.h"
+#include "mpd_error.h"
#include <vorbis/vorbisenc.h>
@@ -374,7 +375,7 @@ vorbis_encoder_read(struct encoder *_encoder, void *_dest, size_t length)
if (nbytes > length)
/* XXX better error handling */
- g_error("buffer too small");
+ MPD_ERROR("buffer too small");
memcpy(dest, page.header, page.header_len);
memcpy(dest + page.header_len, page.body, page.body_len);
diff --git a/src/event_pipe.c b/src/event_pipe.c
index 286256f96..5b519984f 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 <stdbool.h>
#include <assert.h>
@@ -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)
diff --git a/src/inotify_source.c b/src/inotify_source.c
index d4b047fe1..3a986cbad 100644
--- a/src/inotify_source.c
+++ b/src/inotify_source.c
@@ -21,6 +21,7 @@
#include "inotify_source.h"
#include "fifo_buffer.h"
#include "fd_util.h"
+#include "mpd_error.h"
#include <sys/inotify.h>
#include <unistd.h>
@@ -68,13 +69,14 @@ mpd_inotify_in_event(G_GNUC_UNUSED GIOChannel *_source,
dest = fifo_buffer_write(source->buffer, &length);
if (dest == NULL)
- g_error("buffer full");
+ MPD_ERROR("buffer full");
nbytes = read(source->fd, dest, length);
if (nbytes < 0)
- g_error("failed to read from inotify: %s", g_strerror(errno));
+ MPD_ERROR("failed to read from inotify: %s",
+ g_strerror(errno));
if (nbytes == 0)
- g_error("end of file from inotify");
+ MPD_ERROR("end of file from inotify");
fifo_buffer_append(source->buffer, nbytes);
diff --git a/src/log.c b/src/log.c
index dc7628871..556c8b04f 100644
--- a/src/log.c
+++ b/src/log.c
@@ -22,6 +22,7 @@
#include "conf.h"
#include "utils.h"
#include "fd_util.h"
+#include "mpd_error.h"
#include <assert.h>
#include <sys/types.h>
@@ -60,9 +61,9 @@ static void redirect_logs(int fd)
{
assert(fd >= 0);
if (dup2(fd, STDOUT_FILENO) < 0)
- g_error("problems dup2 stdout : %s\n", strerror(errno));
+ MPD_ERROR("problems dup2 stdout : %s\n", strerror(errno));
if (dup2(fd, STDERR_FILENO) < 0)
- g_error("problems dup2 stderr : %s\n", strerror(errno));
+ MPD_ERROR("problems dup2 stderr : %s\n", strerror(errno));
}
static const char *log_date(void)
@@ -138,8 +139,8 @@ log_init_file(const char *path, unsigned line)
out_filename = path;
out_fd = open_log_file();
if (out_fd < 0)
- g_error("problem opening log file \"%s\" (config line %u) for "
- "writing\n", path, line);
+ MPD_ERROR("problem opening log file \"%s\" (config line %u) "
+ "for writing\n", path, line);
g_log_set_default_handler(file_log_func, NULL);
}
@@ -216,8 +217,8 @@ parse_log_level(const char *value, unsigned line)
else if (0 == strcmp(value, "verbose"))
return G_LOG_LEVEL_DEBUG;
else {
- g_error("unknown log level \"%s\" at line %u\n",
- value, line);
+ MPD_ERROR("unknown log level \"%s\" at line %u\n",
+ value, line);
return G_LOG_LEVEL_MESSAGE;
}
}
@@ -252,8 +253,8 @@ void log_init(bool verbose, bool use_stdout)
available) */
log_init_syslog();
#else
- g_error("config parameter \"%s\" not found\n",
- CONF_LOG_FILE);
+ MPD_ERROR("config parameter \"%s\" not found\n",
+ CONF_LOG_FILE);
#endif
#ifdef HAVE_SYSLOG
} else if (strcmp(param->value, "syslog") == 0) {
diff --git a/src/main.c b/src/main.c
index 34310927d..a500e2934 100644
--- a/src/main.c
+++ b/src/main.c
@@ -54,6 +54,7 @@
#include "dirvec.h"
#include "songvec.h"
#include "tag_pool.h"
+#include "mpd_error.h"
#ifdef ENABLE_INOTIFY
#include "inotify_update.h"
@@ -141,7 +142,7 @@ glue_db_init_and_load(void)
}
if (path == NULL)
- g_error(CONF_DB_FILE " setting missing");
+ MPD_ERROR(CONF_DB_FILE " setting missing");
db_init(path);
@@ -175,7 +176,7 @@ glue_sticker_init(void)
success = sticker_global_init(config_get_path(CONF_STICKER_FILE),
&error);
if (!success)
- g_error("%s", error->message);
+ MPD_ERROR("%s", error->message);
#endif
}
@@ -197,14 +198,14 @@ static void winsock_init(void)
retval = WSAStartup(MAKEWORD(2, 2), &sockinfo);
if(retval != 0)
{
- g_error("Attempt to open Winsock2 failed; error code %d\n",
+ MPD_ERROR("Attempt to open Winsock2 failed; error code %d\n",
retval);
}
if (LOBYTE(sockinfo.wVersion) != 2)
{
- g_error("We use Winsock2 but your version is either too new or "
- "old; please install Winsock 2.x\n");
+ MPD_ERROR("We use Winsock2 but your version is either too new "
+ "or old; please install Winsock 2.x\n");
}
#endif
}
@@ -226,8 +227,8 @@ initialize_decoder_and_player(void)
if (param != NULL) {
buffer_size = strtol(param->value, &test, 10);
if (*test != '\0' || buffer_size <= 0)
- g_error("buffer size \"%s\" is not a positive integer, "
- "line %i\n", param->value, param->line);
+ MPD_ERROR("buffer size \"%s\" is not a positive integer, "
+ "line %i\n", param->value, param->line);
} else
buffer_size = DEFAULT_BUFFER_SIZE;
@@ -236,15 +237,15 @@ initialize_decoder_and_player(void)
buffered_chunks = buffer_size / CHUNK_SIZE;
if (buffered_chunks >= 1 << 15)
- g_error("buffer size \"%li\" is too big\n", (long)buffer_size);
+ MPD_ERROR("buffer size \"%li\" is too big\n", (long)buffer_size);
param = config_get_param(CONF_BUFFER_BEFORE_PLAY);
if (param != NULL) {
perc = strtod(param->value, &test);
if (*test != '%' || perc < 0 || perc > 100) {
- g_error("buffered before play \"%s\" is not a positive "
- "percentage and less than 100 percent, line %i",
- param->value, param->line);
+ MPD_ERROR("buffered before play \"%s\" is not a positive "
+ "percentage and less than 100 percent, line %i",
+ param->value, param->line);
}
} else
perc = DEFAULT_BUFFER_BEFORE_PLAY;
@@ -390,7 +391,7 @@ int mpd_main(int argc, char *argv[])
database */
unsigned job = update_enqueue(NULL, true);
if (job == 0)
- g_error("directory update failed");
+ MPD_ERROR("directory update failed");
}
glue_state_file_init();
diff --git a/src/mpd_error.h b/src/mpd_error.h
new file mode 100644
index 000000000..95e120572
--- /dev/null
+++ b/src/mpd_error.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2003-2010 The Music Player Daemon Project
+ * http://www.musicpd.org
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef MPD_ERROR_H
+#define MPD_ERROR_H
+
+#include <stdlib.h>
+
+/* This macro is used as an intermediate step to a proper error handling
+ * using GError in mpd. It is used for unrecoverable error conditions
+ * and exits immediately. The long-term goal is to replace this macro by
+ * proper error handling. */
+
+#define MPD_ERROR(...) \
+ { \
+ g_critical(__VA_ARGS__); \
+ exit(EXIT_FAILURE); \
+ }
+
+#endif
diff --git a/src/output/shout_plugin.c b/src/output/shout_plugin.c
index a8b409be2..d1466eb3a 100644
--- a/src/output/shout_plugin.c
+++ b/src/output/shout_plugin.c
@@ -21,6 +21,7 @@
#include "output_api.h"
#include "encoder_plugin.h"
#include "encoder_list.h"
+#include "mpd_error.h"
#include <shout/shout.h>
#include <glib.h>
@@ -101,8 +102,8 @@ static void free_shout_data(struct shout_data *sd)
#define check_block_param(name) { \
block_param = config_get_block_param(param, name); \
if (!block_param) { \
- g_error("no \"%s\" defined for shout device defined at line " \
- "%i\n", name, param->line); \
+ MPD_ERROR("no \"%s\" defined for shout device defined at line " \
+ "%i\n", name, param->line); \
} \
}
diff --git a/src/output_all.c b/src/output_all.c
index dbd5a6ce6..3f582dcb4 100644
--- a/src/output_all.c
+++ b/src/output_all.c
@@ -26,6 +26,7 @@
#include "pipe.h"
#include "buffer.h"
#include "player_control.h"
+#include "mpd_error.h"
#ifndef NDEBUG
#include "chunk.h"
@@ -122,17 +123,17 @@ audio_output_all_init(void)
if (!audio_output_init(output, param, &error)) {
if (param != NULL)
- g_error("line %i: %s",
- param->line, error->message);
+ MPD_ERROR("line %i: %s",
+ param->line, error->message)
else
- g_error("%s", error->message);
+ MPD_ERROR("%s", error->message);
}
/* require output names to be unique: */
for (j = 0; j < i; j++) {
if (!strcmp(output->name, audio_outputs[j].name)) {
- g_error("output devices with identical "
- "names: %s\n", output->name);
+ MPD_ERROR("output devices with identical "
+ "names: %s\n", output->name);
}
}
}
diff --git a/src/output_thread.c b/src/output_thread.c
index df9d7801b..c10a1552f 100644
--- a/src/output_thread.c
+++ b/src/output_thread.c
@@ -28,6 +28,7 @@
#include "filter_plugin.h"
#include "filter/convert_filter_plugin.h"
#include "filter/replay_gain_filter_plugin.h"
+#include "mpd_error.h"
#include <glib.h>
@@ -629,5 +630,5 @@ void audio_output_thread_start(struct audio_output *ao)
assert(ao->command == AO_COMMAND_NONE);
if (!(ao->thread = g_thread_create(audio_output_task, ao, true, &e)))
- g_error("Failed to spawn output task: %s\n", e->message);
+ MPD_ERROR("Failed to spawn output task: %s\n", e->message);
}
diff --git a/src/path.c b/src/path.c
index 96c429529..5e39c1636 100644
--- a/src/path.c
+++ b/src/path.c
@@ -20,6 +20,7 @@
#include "config.h"
#include "path.h"
#include "conf.h"
+#include "mpd_error.h"
#include <glib.h>
@@ -64,7 +65,7 @@ path_set_fs_charset(const char *charset)
/* convert a space to ensure that the charset is valid */
test = g_convert(" ", 1, charset, "UTF-8", NULL, NULL, NULL);
if (test == NULL)
- g_error("invalid filesystem charset: %s", charset);
+ MPD_ERROR("invalid filesystem charset: %s", charset);
g_free(test);
g_free(fs_charset);
diff --git a/src/pcm_mix.c b/src/pcm_mix.c
index 33815dac2..3145c07be 100644
--- a/src/pcm_mix.c
+++ b/src/pcm_mix.c
@@ -22,6 +22,7 @@
#include "pcm_volume.h"
#include "pcm_utils.h"
#include "audio_format.h"
+#include "mpd_error.h"
#include <glib.h>
@@ -125,8 +126,8 @@ pcm_add_vol(void *buffer1, const void *buffer2, size_t size,
break;
default:
- g_error("format %s not supported by pcm_add_vol",
- sample_format_to_string(format->format));
+ MPD_ERROR("format %s not supported by pcm_add_vol",
+ sample_format_to_string(format->format));
}
}
@@ -208,8 +209,8 @@ pcm_add(void *buffer1, const void *buffer2, size_t size,
break;
default:
- g_error("format %s not supported by pcm_add",
- sample_format_to_string(format->format));
+ MPD_ERROR("format %s not supported by pcm_add",
+ sample_format_to_string(format->format));
}
}
diff --git a/src/permission.c b/src/permission.c
index ce47effe8..17b443e0a 100644
--- a/src/permission.c
+++ b/src/permission.c
@@ -20,6 +20,7 @@
#include "config.h"
#include "permission.h"
#include "conf.h"
+#include "mpd_error.h"
#include <glib.h>
@@ -59,7 +60,7 @@ static unsigned parsePermissions(const char *string)
} else if (strcmp(temp, PERMISSION_ADMIN_STRING) == 0) {
permission |= PERMISSION_ADMIN;
} else {
- g_error("unknown permission \"%s\"", temp);
+ MPD_ERROR("unknown permission \"%s\"", temp);
}
}
@@ -90,7 +91,7 @@ void initPermissions(void)
strchr(param->value, PERMISSION_PASSWORD_CHAR);
if (separator == NULL)
- g_error("\"%c\" not found in password string "
+ MPD_ERROR("\"%c\" not found in password string "
"\"%s\", line %i",
PERMISSION_PASSWORD_CHAR,
param->value, param->line);
diff --git a/src/player_thread.c b/src/player_thread.c
index cf4e61384..13d1c2ebb 100644
--- a/src/player_thread.c
+++ b/src/player_thread.c
@@ -34,6 +34,7 @@
#include "idle.h"
#include "main.h"
#include "buffer.h"
+#include "mpd_error.h"
#include <glib.h>
@@ -1073,5 +1074,5 @@ void player_create(void)
pc.thread = g_thread_create(player_task, NULL, true, &e);
if (pc.thread == NULL)
- g_error("Failed to spawn player task: %s", e->message);
+ MPD_ERROR("Failed to spawn player task: %s", e->message);
}
diff --git a/src/playlist_list.c b/src/playlist_list.c
index 9c40e6dfe..9bd73ea93 100644
--- a/src/playlist_list.c
+++ b/src/playlist_list.c
@@ -33,6 +33,7 @@
#include "utils.h"
#include "conf.h"
#include "glib_compat.h"
+#include "mpd_error.h"
#include <assert.h>
#include <string.h>
@@ -76,7 +77,7 @@ playlist_plugin_config(const char *plugin_name)
const char *name =
config_get_block_string(param, "name", NULL);
if (name == NULL)
- g_error("playlist configuration without 'plugin' name in line %d",
+ MPD_ERROR("playlist configuration without 'plugin' name in line %d",
param->line);
if (strcmp(name, plugin_name) == 0)
diff --git a/src/replay_gain_config.c b/src/replay_gain_config.c
index f82725e90..bbfe127a7 100644
--- a/src/replay_gain_config.c
+++ b/src/replay_gain_config.c
@@ -22,6 +22,7 @@
#include "playlist.h"
#include "conf.h"
#include "idle.h"
+#include "mpd_error.h"
#include <glib.h>
@@ -91,8 +92,8 @@ void replay_gain_global_init(void)
const struct config_param *param = config_get_param(CONF_REPLAYGAIN);
if (param != NULL && !replay_gain_set_mode_string(param->value)) {
- g_error("replaygain value \"%s\" at line %i is invalid\n",
- param->value, param->line);
+ MPD_ERROR("replaygain value \"%s\" at line %i is invalid\n",
+ param->value, param->line);
}
param = config_get_param(CONF_REPLAYGAIN_PREAMP);
@@ -102,13 +103,13 @@ void replay_gain_global_init(void)
float f = strtod(param->value, &test);
if (*test != '\0') {
- g_error("Replaygain preamp \"%s\" is not a number at "
- "line %i\n", param->value, param->line);
+ MPD_ERROR("Replaygain preamp \"%s\" is not a number at "
+ "line %i\n", param->value, param->line);
}
if (f < -15 || f > 15) {
- g_error("Replaygain preamp \"%s\" is not between -15 and"
- "15 at line %i\n", param->value, param->line);
+ MPD_ERROR("Replaygain preamp \"%s\" is not between -15 and"
+ "15 at line %i\n", param->value, param->line);
}
replay_gain_preamp = pow(10, f / 20.0);
@@ -121,13 +122,13 @@ void replay_gain_global_init(void)
float f = strtod(param->value, &test);
if (*test != '\0') {
- g_error("Replaygain missing preamp \"%s\" is not a number at "
- "line %i\n", param->value, param->line);
+ MPD_ERROR("Replaygain missing preamp \"%s\" is not a number at "
+ "line %i\n", param->value, param->line);
}
if (f < -15 || f > 15) {
- g_error("Replaygain missing preamp \"%s\" is not between -15 and"
- "15 at line %i\n", param->value, param->line);
+ MPD_ERROR("Replaygain missing preamp \"%s\" is not between -15 and"
+ "15 at line %i\n", param->value, param->line);
}
replay_gain_missing_preamp = pow(10, f / 20.0);
diff --git a/src/sig_handlers.c b/src/sig_handlers.c
index 99a0b7e06..8aa85cf88 100644
--- a/src/sig_handlers.c
+++ b/src/sig_handlers.c
@@ -25,6 +25,7 @@
#include "log.h"
#include "main.h"
#include "event_pipe.h"
+#include "mpd_error.h"
#include <glib.h>
@@ -46,7 +47,7 @@ static void
x_sigaction(int signum, const struct sigaction *act)
{
if (sigaction(signum, act, NULL) < 0)
- g_error("sigaction() failed: %s", strerror(errno));
+ MPD_ERROR("sigaction() failed: %s", strerror(errno));
}
static void
diff --git a/src/tag.c b/src/tag.c
index aa96a468f..6ce46a831 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -23,6 +23,7 @@
#include "tag_pool.h"
#include "conf.h"
#include "song.h"
+#include "mpd_error.h"
#include <glib.h>
#include <assert.h>
@@ -138,8 +139,8 @@ void tag_lib_init(void)
type = tag_name_parse_i(c);
if (type == TAG_NUM_OF_ITEM_TYPES)
- g_error("error parsing metadata item \"%s\"",
- c);
+ MPD_ERROR("error parsing metadata item \"%s\"",
+ c);
ignore_tag_items[type] = false;
diff --git a/src/update.c b/src/update.c
index 83436612f..d57fb114d 100644
--- a/src/update.c
+++ b/src/update.c
@@ -28,6 +28,7 @@
#include "idle.h"
#include "stats.h"
#include "main.h"
+#include "mpd_error.h"
#include <glib.h>
@@ -93,7 +94,7 @@ spawn_update_task(const char *path)
update_thr = g_thread_create(update_task, g_strdup(path), TRUE, &e);
if (update_thr == NULL)
- g_error("Failed to spawn update task: %s", e->message);
+ MPD_ERROR("Failed to spawn update task: %s", e->message);
if (++update_task_id > update_task_id_max)
update_task_id = 1;
diff --git a/src/zeroconf-avahi.c b/src/zeroconf-avahi.c
index d9b0c22a8..518a7a481 100644
--- a/src/zeroconf-avahi.c
+++ b/src/zeroconf-avahi.c
@@ -20,6 +20,7 @@
#include "config.h"
#include "zeroconf-internal.h"
#include "listen.h"
+#include "mpd_error.h"
#include <glib.h>
@@ -218,7 +219,7 @@ void init_avahi(const char *serviceName)
g_debug("Initializing interface");
if (!avahi_is_valid_service_name(serviceName))
- g_error("Invalid zeroconf_name \"%s\"", serviceName);
+ MPD_ERROR("Invalid zeroconf_name \"%s\"", serviceName);
avahiName = avahi_strdup(serviceName);