diff options
-rw-r--r-- | src/command.c | 20 | ||||
-rw-r--r-- | src/playlist_print.c | 12 | ||||
-rw-r--r-- | src/playlist_print.h | 6 |
3 files changed, 22 insertions, 16 deletions
diff --git a/src/command.c b/src/command.c index 14991740e..36c070f0e 100644 --- a/src/command.c +++ b/src/command.c @@ -686,26 +686,30 @@ handle_load(struct client *client, G_GNUC_UNUSED int argc, char *argv[]) static enum command_return handle_listplaylist(struct client *client, G_GNUC_UNUSED int argc, char *argv[]) { - int ret; + bool ret; - ret = spl_print(client, argv[1], 0); - if (ret == -1) + ret = spl_print(client, argv[1], false); + if (!ret) { command_error(client, ACK_ERROR_NO_EXIST, "No such playlist"); + return COMMAND_RETURN_ERROR; + } - return ret; + return COMMAND_RETURN_OK; } static enum command_return handle_listplaylistinfo(struct client *client, G_GNUC_UNUSED int argc, char *argv[]) { - int ret; + bool ret; - ret = spl_print(client, argv[1], 1); - if (ret == -1) + ret = spl_print(client, argv[1], true); + if (!ret) { command_error(client, ACK_ERROR_NO_EXIST, "No such playlist"); + return COMMAND_RETURN_ERROR; + } - return ret; + return COMMAND_RETURN_OK; } static enum command_return diff --git a/src/playlist_print.c b/src/playlist_print.c index 60696b772..c4a9c4f34 100644 --- a/src/playlist_print.c +++ b/src/playlist_print.c @@ -23,24 +23,24 @@ #include "database.h" #include "client.h" -int -spl_print(struct client *client, const char *name_utf8, int detail) +bool +spl_print(struct client *client, const char *name_utf8, bool detail) { GPtrArray *list; list = spl_load(name_utf8); if (list == NULL) - return -1; + return false; for (unsigned i = 0; i < list->len; ++i) { const char *temp = g_ptr_array_index(list, i); - int wrote = 0; + bool wrote = false; if (detail) { struct song *song = db_get_song(temp); if (song) { song_print_info(client, song); - wrote = 1; + wrote = true; } } @@ -50,5 +50,5 @@ spl_print(struct client *client, const char *name_utf8, int detail) } spl_free(list); - return 0; + return true; } diff --git a/src/playlist_print.h b/src/playlist_print.h index cf92bfdbb..68ffb2032 100644 --- a/src/playlist_print.h +++ b/src/playlist_print.h @@ -19,9 +19,11 @@ #ifndef PLAYLIST_PRINT_H #define PLAYLIST_PRINT_H +#include <stdbool.h> + struct client; -int -spl_print(struct client *client, const char *name_utf8, int detail); +bool +spl_print(struct client *client, const char *name_utf8, bool detail); #endif |