aboutsummaryrefslogtreecommitdiffstats
path: root/test/dump_text_file.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-08-10 18:02:44 +0200
committerMax Kellermann <max@duempel.org>2013-09-04 18:14:22 +0200
commit29030b54c98b0aee65fbc10ebf7ba36bed98c02c (patch)
tree79766830b55ebca38ddbce84d8d548227eedb69e /test/dump_text_file.cxx
parentc9fcc7f14860777458153eb2d13c773ccfa1daa2 (diff)
downloadmpd-29030b54c98b0aee65fbc10ebf7ba36bed98c02c.tar.gz
mpd-29030b54c98b0aee65fbc10ebf7ba36bed98c02c.tar.xz
mpd-29030b54c98b0aee65fbc10ebf7ba36bed98c02c.zip
util/Error: new error passing library
Replaces GLib's GError.
Diffstat (limited to 'test/dump_text_file.cxx')
-rw-r--r--test/dump_text_file.cxx31
1 files changed, 14 insertions, 17 deletions
diff --git a/test/dump_text_file.cxx b/test/dump_text_file.cxx
index 165a6493c..a9f8c95a2 100644
--- a/test/dump_text_file.cxx
+++ b/test/dump_text_file.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -24,6 +24,7 @@
#include "conf.h"
#include "stdbin.h"
#include "TextInputStream.hxx"
+#include "util/Error.hxx"
#ifdef ENABLE_ARCHIVE
#include "ArchiveList.hxx"
@@ -56,7 +57,7 @@ dump_text_file(TextInputStream &is)
static int
dump_input_stream(struct input_stream *is)
{
- GError *error = NULL;
+ Error error;
input_stream_lock(is);
@@ -64,9 +65,8 @@ dump_input_stream(struct input_stream *is)
input_stream_wait_ready(is);
- if (!input_stream_check(is, &error)) {
- g_warning("%s", error->message);
- g_error_free(error);
+ if (!input_stream_check(is, error)) {
+ g_warning("%s", error.GetMessage());
input_stream_unlock(is);
return EXIT_FAILURE;
}
@@ -80,9 +80,8 @@ dump_input_stream(struct input_stream *is)
}
input_stream_lock(is);
- if (!input_stream_check(is, &error)) {
- g_warning("%s", error->message);
- g_error_free(error);
+ if (!input_stream_check(is, error)) {
+ g_warning("%s", error.GetMessage());
input_stream_unlock(is);
return EXIT_FAILURE;
}
@@ -94,7 +93,6 @@ dump_input_stream(struct input_stream *is)
int main(int argc, char **argv)
{
- GError *error = NULL;
struct input_stream *is;
int ret;
@@ -122,9 +120,9 @@ int main(int argc, char **argv)
archive_plugin_init_all();
#endif
- if (!input_stream_global_init(&error)) {
- g_warning("%s", error->message);
- g_error_free(error);
+ Error error;
+ if (!input_stream_global_init(error)) {
+ g_warning("%s", error.GetMessage());
return 2;
}
@@ -133,15 +131,14 @@ int main(int argc, char **argv)
Mutex mutex;
Cond cond;
- is = input_stream_open(argv[1], mutex, cond, &error);
+ is = input_stream_open(argv[1], mutex, cond, error);
if (is != NULL) {
ret = dump_input_stream(is);
input_stream_close(is);
} else {
- if (error != NULL) {
- g_warning("%s", error->message);
- g_error_free(error);
- } else
+ if (error.IsDefined())
+ g_warning("%s", error.GetMessage());
+ else
g_printerr("input_stream_open() failed\n");
ret = 2;
}