From: Max Kellermann Date: Thu, 10 Sep 2009 15:52:32 +0000 (+0200) Subject: mpdclient: moved code to mpdclient_handle_error() X-Git-Tag: release-0.15~23 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=295034a03637e81e83a7f7a8773011c48ef0e486;p=ncmpc.git mpdclient: moved code to mpdclient_handle_error() --- 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 *