diff options
author | Thomas Jansen <mithi@mithi.net> | 2010-09-25 15:00:43 +0200 |
---|---|---|
committer | Thomas Jansen <mithi@mithi.net> | 2010-09-25 15:00:43 +0200 |
commit | 28bcb8bdf568875eeea1349e39b7958d77c8fcc1 (patch) | |
tree | 17397be16e8067a48fd532a581081f68a1b17700 /src/main.c | |
parent | 9af9fd140032138894e4781caabee8a5a96edab8 (diff) | |
download | mpd-28bcb8bdf568875eeea1349e39b7958d77c8fcc1.tar.gz mpd-28bcb8bdf568875eeea1349e39b7958d77c8fcc1.tar.xz mpd-28bcb8bdf568875eeea1349e39b7958d77c8fcc1.zip |
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.
Diffstat (limited to '')
-rw-r--r-- | src/main.c | 25 |
1 files changed, 13 insertions, 12 deletions
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(); |