From f8ed713de8ccb48dd235a26553f5a823431fb849 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sun, 5 Apr 2015 00:58:35 +0000 Subject: [PATCH] com_select() callback: Return negative on errors. --- afs.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/afs.c b/afs.c index 4bc7871c..a5ec7b2f 100644 --- a/afs.c +++ b/afs.c @@ -501,6 +501,7 @@ static int activate_mood_or_playlist(char *arg, int *num_admissible) enum play_mode mode; int ret; + PARA_INFO_LOG("new playlist: %s\n", arg); if (!arg) { ret = change_current_mood(NULL); /* always successful */ mode = PLAY_MODE_MOOD; @@ -602,31 +603,32 @@ static int com_select_callback(int fd, const struct osl_object *query) ret = clear_score_table(); if (ret < 0) { - para_printf(&pb, "%s\n", para_strerror(-ret)); - goto out; + para_printf(&pb, "could not clear score table: %s\n", + para_strerror(-ret)); + return ret; } if (current_play_mode == PLAY_MODE_MOOD) close_current_mood(); else playlist_close(); ret = activate_mood_or_playlist(arg, &num_admissible); - if (ret < 0) { - para_printf(&pb, "%s\nswitching back to %s\n", - para_strerror(-ret), current_mop? - current_mop : "dummy"); - ret = activate_mood_or_playlist(current_mop, &num_admissible); - if (ret < 0) { - para_printf(&pb, "failed (%s), switching to dummy\n", - para_strerror(-ret)); - activate_mood_or_playlist(NULL, &num_admissible); - } - } else - para_printf(&pb, "activated %s (%d admissible files)\n", - current_mop? current_mop : "dummy mood", - num_admissible); + if (ret >= 0) + goto out; + para_printf(&pb, "could not activate %s: %s\n" + "switching back to %s\n", + arg, para_strerror(-ret), current_mop? current_mop : "dummy"); + /* ignore subsequent errors (but log them) */ + ret = activate_mood_or_playlist(current_mop, &num_admissible); + if (ret >= 0) + goto out; + para_printf(&pb, "could not activate %s: %s\nswitching to dummy\n", + current_mop, para_strerror(-ret)); + activate_mood_or_playlist(NULL, &num_admissible); out: + para_printf(&pb, "activated %s (%d admissible files)\n", + current_mop? current_mop : "dummy mood", num_admissible); flush_and_free_pb(&pb); - return 0; + return ret; } int com_select(struct command_context *cc) -- 2.39.5