From 29030b54c98b0aee65fbc10ebf7ba36bed98c02c Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 10 Aug 2013 18:02:44 +0200 Subject: util/Error: new error passing library Replaces GLib's GError. --- src/playlist/AsxPlaylistPlugin.cxx | 9 ++++---- src/playlist/LastFMPlaylistPlugin.cxx | 35 ++++++++++++++----------------- src/playlist/PlsPlaylistPlugin.cxx | 9 ++++---- src/playlist/RssPlaylistPlugin.cxx | 9 ++++---- src/playlist/SoundCloudPlaylistPlugin.cxx | 25 +++++++++++----------- src/playlist/XspfPlaylistPlugin.cxx | 9 ++++---- 6 files changed, 48 insertions(+), 48 deletions(-) (limited to 'src/playlist') diff --git a/src/playlist/AsxPlaylistPlugin.cxx b/src/playlist/AsxPlaylistPlugin.cxx index c0a47b8e3..16b187402 100644 --- a/src/playlist/AsxPlaylistPlugin.cxx +++ b/src/playlist/AsxPlaylistPlugin.cxx @@ -23,6 +23,7 @@ #include "InputLegacy.hxx" #include "Song.hxx" #include "Tag.hxx" +#include "util/Error.hxx" #include @@ -208,6 +209,7 @@ asx_open_stream(struct input_stream *is) char buffer[1024]; size_t nbytes; bool success; + Error error2; GError *error = NULL; /* parse the ASX XML file */ @@ -218,12 +220,11 @@ asx_open_stream(struct input_stream *is) while (true) { nbytes = input_stream_lock_read(is, buffer, sizeof(buffer), - &error); + error2); if (nbytes == 0) { - if (error != NULL) { + if (error2.IsDefined()) { g_markup_parse_context_free(context); - g_warning("%s", error->message); - g_error_free(error); + g_warning("%s", error2.GetMessage()); return NULL; } diff --git a/src/playlist/LastFMPlaylistPlugin.cxx b/src/playlist/LastFMPlaylistPlugin.cxx index a6071e092..5b168ee83 100644 --- a/src/playlist/LastFMPlaylistPlugin.cxx +++ b/src/playlist/LastFMPlaylistPlugin.cxx @@ -24,6 +24,7 @@ #include "conf.h" #include "Song.hxx" #include "InputLegacy.hxx" +#include "util/Error.hxx" #include @@ -92,16 +93,14 @@ static char * lastfm_get(const char *url, Mutex &mutex, Cond &cond) { struct input_stream *input_stream; - GError *error = NULL; + Error error; char buffer[4096]; - size_t length = 0, nbytes; + size_t length = 0; - input_stream = input_stream_open(url, mutex, cond, &error); + input_stream = input_stream_open(url, mutex, cond, error); if (input_stream == NULL) { - if (error != NULL) { - g_warning("%s", error->message); - g_error_free(error); - } + if (error.IsDefined()) + g_warning("%s", error.GetMessage()); return NULL; } @@ -111,13 +110,12 @@ lastfm_get(const char *url, Mutex &mutex, Cond &cond) input_stream_wait_ready(input_stream); do { - nbytes = input_stream_read(input_stream, buffer + length, - sizeof(buffer) - length, &error); + size_t nbytes = + input_stream_read(input_stream, buffer + length, + sizeof(buffer) - length, error); if (nbytes == 0) { - if (error != NULL) { - g_warning("%s", error->message); - g_error_free(error); - } + if (error.IsDefined()) + g_warning("%s", error.GetMessage()); if (input_stream_eof(input_stream)) break; @@ -166,7 +164,6 @@ lastfm_find(const char *response, const char *name) static struct playlist_provider * lastfm_open_uri(const char *uri, Mutex &mutex, Cond &cond) { - GError *error = NULL; char *p, *q, *response, *session; /* handshake */ @@ -225,15 +222,15 @@ lastfm_open_uri(const char *uri, Mutex &mutex, Cond &cond) NULL); g_free(session); - const auto is = input_stream_open(p, mutex, cond, &error); + Error error; + const auto is = input_stream_open(p, mutex, cond, error); g_free(p); if (is == nullptr) { - if (error != NULL) { + if (error.IsDefined()) g_warning("Failed to load XSPF playlist: %s", - error->message); - g_error_free(error); - } else + error.GetMessage()); + else g_warning("Failed to load XSPF playlist"); return NULL; } diff --git a/src/playlist/PlsPlaylistPlugin.cxx b/src/playlist/PlsPlaylistPlugin.cxx index 9ef302388..ab8f93bef 100644 --- a/src/playlist/PlsPlaylistPlugin.cxx +++ b/src/playlist/PlsPlaylistPlugin.cxx @@ -23,6 +23,7 @@ #include "InputLegacy.hxx" #include "Song.hxx" #include "Tag.hxx" +#include "util/Error.hxx" #include @@ -104,6 +105,7 @@ static struct playlist_provider * pls_open_stream(struct input_stream *is) { GError *error = NULL; + Error error2; size_t nbytes; char buffer[1024]; bool success; @@ -113,11 +115,10 @@ pls_open_stream(struct input_stream *is) do { nbytes = input_stream_lock_read(is, buffer, sizeof(buffer), - &error); + error2); if (nbytes == 0) { - if (error != NULL) { - g_warning("%s", error->message); - g_error_free(error); + if (error2.IsDefined()) { + g_warning("%s", error2.GetMessage()); return NULL; } diff --git a/src/playlist/RssPlaylistPlugin.cxx b/src/playlist/RssPlaylistPlugin.cxx index 16dcd5fe5..98f323e66 100644 --- a/src/playlist/RssPlaylistPlugin.cxx +++ b/src/playlist/RssPlaylistPlugin.cxx @@ -23,6 +23,7 @@ #include "InputLegacy.hxx" #include "Song.hxx" #include "Tag.hxx" +#include "util/Error.hxx" #include @@ -205,6 +206,7 @@ rss_open_stream(struct input_stream *is) char buffer[1024]; size_t nbytes; bool success; + Error error2; GError *error = NULL; /* parse the RSS XML file */ @@ -215,12 +217,11 @@ rss_open_stream(struct input_stream *is) while (true) { nbytes = input_stream_lock_read(is, buffer, sizeof(buffer), - &error); + error2); if (nbytes == 0) { - if (error != NULL) { + if (error2.IsDefined()) { g_markup_parse_context_free(context); - g_warning("%s", error->message); - g_error_free(error); + g_warning("%s", error2.GetMessage()); return NULL; } diff --git a/src/playlist/SoundCloudPlaylistPlugin.cxx b/src/playlist/SoundCloudPlaylistPlugin.cxx index b60635049..b6be4fd30 100644 --- a/src/playlist/SoundCloudPlaylistPlugin.cxx +++ b/src/playlist/SoundCloudPlaylistPlugin.cxx @@ -24,6 +24,7 @@ #include "InputLegacy.hxx" #include "Song.hxx" #include "Tag.hxx" +#include "util/Error.hxx" #include #include @@ -244,18 +245,15 @@ static int soundcloud_parse_json(const char *url, yajl_handle hand, Mutex &mutex, Cond &cond) { - struct input_stream *input_stream; - GError *error = NULL; char buffer[4096]; unsigned char *ubuffer = (unsigned char *)buffer; - size_t nbytes; - input_stream = input_stream_open(url, mutex, cond, &error); + Error error; + input_stream *input_stream = input_stream_open(url, mutex, cond, + error); if (input_stream == NULL) { - if (error != NULL) { - g_warning("%s", error->message); - g_error_free(error); - } + if (error.IsDefined()) + g_warning("%s", error.GetMessage()); return -1; } @@ -266,12 +264,13 @@ soundcloud_parse_json(const char *url, yajl_handle hand, int done = 0; while (!done) { - nbytes = input_stream_read(input_stream, buffer, sizeof(buffer), &error); + const size_t nbytes = + input_stream_read(input_stream, buffer, sizeof(buffer), + error); if (nbytes == 0) { - if (error != NULL) { - g_warning("%s", error->message); - g_error_free(error); - } + if (error.IsDefined()) + g_warning("%s", error.GetMessage()); + if (input_stream_eof(input_stream)) { done = true; } else { diff --git a/src/playlist/XspfPlaylistPlugin.cxx b/src/playlist/XspfPlaylistPlugin.cxx index c8a067da4..f2412897b 100644 --- a/src/playlist/XspfPlaylistPlugin.cxx +++ b/src/playlist/XspfPlaylistPlugin.cxx @@ -22,6 +22,7 @@ #include "MemoryPlaylistProvider.hxx" #include "InputLegacy.hxx" #include "Tag.hxx" +#include "util/Error.hxx" #include @@ -224,6 +225,7 @@ xspf_open_stream(struct input_stream *is) char buffer[1024]; size_t nbytes; bool success; + Error error2; GError *error = NULL; /* parse the XSPF XML file */ @@ -234,12 +236,11 @@ xspf_open_stream(struct input_stream *is) while (true) { nbytes = input_stream_lock_read(is, buffer, sizeof(buffer), - &error); + error2); if (nbytes == 0) { - if (error != NULL) { + if (error2.IsDefined()) { g_markup_parse_context_free(context); - g_warning("%s", error->message); - g_error_free(error); + g_warning("%s", error2.GetMessage()); return NULL; } -- cgit v1.2.3