From 295034a03637e81e83a7f7a8773011c48ef0e486 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 10 Sep 2009 17:52:32 +0200 Subject: [PATCH] mpdclient: moved code to mpdclient_handle_error() --- src/mpdclient.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/mpdclient.c b/src/mpdclient.c index a4224a6..42cc576 100644 --- a/src/mpdclient.c +++ b/src/mpdclient.c @@ -120,27 +120,31 @@ error_cb(mpdclient_t *c, gint error, const gchar *msg) /*** mpdclient functions ****************************************************/ /****************************************************************************/ -gint -mpdclient_finish_command(mpdclient_t *c) +static gint +mpdclient_handle_error(mpdclient_t *c) { - mpd_finishCommand(c->connection); + enum mpd_error error = c->connection->error; - if (c->connection->error) { - gint error = c->connection->error; + if (error == MPD_ERROR_SUCCESS) + return 0; - if (error == MPD_ERROR_ACK && - c->connection->errorCode == MPD_ACK_ERROR_PERMISSION && - screen_auth(c) == 0) - return 0; + if (error == MPD_ERROR_ACK && + c->connection->errorCode == MPD_ACK_ERROR_PERMISSION && + screen_auth(c) == 0) + return 0; - if (error == MPD_ERROR_ACK) - error = error | (c->connection->errorCode << 8); + if (error == MPD_ERROR_ACK) + error = error | (c->connection->errorCode << 8); - error_cb(c, error, c->connection->errorStr); - return error; - } + error_cb(c, error, c->connection->errorStr); + return error; +} - return 0; +gint +mpdclient_finish_command(mpdclient_t *c) +{ + mpd_finishCommand(c->connection); + return mpdclient_handle_error(c); } mpdclient_t * -- 2.30.2