From 06d5d4b03ec446b9eb7a7351c32ef2fdca29d3c8 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 24 Sep 2009 21:40:07 +0200 Subject: conf: handle fatal errors with GError Don't call g_error(), which will abort the process and dump core. This patch does not affect all the config_get_X() functions. These need some more refactoring. --- test/read_conf.c | 9 ++++++++- test/run_encoder.c | 2 +- test/run_filter.c | 7 ++++++- test/run_output.c | 7 ++++++- 4 files changed, 21 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/read_conf.c b/test/read_conf.c index 286ec2c77..92fcbba99 100644 --- a/test/read_conf.c +++ b/test/read_conf.c @@ -37,6 +37,8 @@ my_log_func(G_GNUC_UNUSED const gchar *log_domain, int main(int argc, char **argv) { const char *path, *name, *value; + GError *error = NULL; + bool success; int ret; if (argc != 3) { @@ -50,7 +52,12 @@ int main(int argc, char **argv) g_log_set_default_handler(my_log_func, NULL); config_global_init(); - config_read_file(path); + success = config_read_file(path, &error); + if (!success) { + g_printerr("%s:", error->message); + g_error_free(error); + return 1; + } value = config_get_string(name, NULL); if (value != NULL) { diff --git a/test/run_encoder.c b/test/run_encoder.c index a9b00e95e..787fb03cf 100644 --- a/test/run_encoder.c +++ b/test/run_encoder.c @@ -73,7 +73,7 @@ int main(int argc, char **argv) } param = config_new_param(NULL, -1); - config_add_block_param(param, "quality", "5.0", -1); + config_add_block_param(param, "quality", "5.0", -1, NULL); encoder = encoder_init(plugin, param, &error); if (encoder == NULL) { diff --git a/test/run_filter.c b/test/run_filter.c index 3c98491ab..ed2b904cf 100644 --- a/test/run_filter.c +++ b/test/run_filter.c @@ -90,7 +90,12 @@ int main(int argc, char **argv) /* read configuration file (mpd.conf) */ config_global_init(); - config_read_file(argv[1]); + success = config_read_file(argv[1], &error); + if (!success) { + g_printerr("%s:", error->message); + g_error_free(error); + return 1; + } /* parse the audio format */ diff --git a/test/run_output.c b/test/run_output.c index 594c4cd64..5ab9625e8 100644 --- a/test/run_output.c +++ b/test/run_output.c @@ -122,7 +122,12 @@ int main(int argc, char **argv) /* read configuration file (mpd.conf) */ config_global_init(); - config_read_file(argv[1]); + success = config_read_file(argv[1], &error); + if (!success) { + g_printerr("%s:", error->message); + g_error_free(error); + return 1; + } /* initialize the audio output */ -- cgit v1.2.3