aboutsummaryrefslogtreecommitdiffstats
path: root/src/playlist.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-10 17:39:49 +0100
committerMax Kellermann <max@duempel.org>2009-01-10 17:39:49 +0100
commit8ebe7bfb250f2b1048d6e7f6c2477717daaad8e9 (patch)
tree51dfa41888a76bdd992eb729df7740adb84f42fb /src/playlist.c
parentb7c4b78846cf2eba35517a1a0c435a3a056636f5 (diff)
downloadmpd-8ebe7bfb250f2b1048d6e7f6c2477717daaad8e9.tar.gz
mpd-8ebe7bfb250f2b1048d6e7f6c2477717daaad8e9.tar.xz
mpd-8ebe7bfb250f2b1048d6e7f6c2477717daaad8e9.zip
playlist: pass unsigned integers to playlistInfo()
A song index cannot be negative. Also require the second parameter to be valid.
Diffstat (limited to 'src/playlist.c')
-rw-r--r--src/playlist.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/src/playlist.c b/src/playlist.c
index f2cbf161f..8cffefc5e 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -413,24 +413,16 @@ int playlistChangesPosId(struct client *client, uint32_t version)
return 0;
}
-enum playlist_result playlistInfo(struct client *client, int song, int max)
+enum playlist_result
+playlistInfo(struct client *client, unsigned start, unsigned end)
{
- unsigned begin = 0;
- unsigned end = playlist.length;
+ if (end > playlist.length)
+ end = playlist.length;
- if (song >= 0) {
- begin = song;
- end = song + 1;
- }
- if (song >= (int)playlist.length)
+ if (start > end)
return PLAYLIST_RESULT_BAD_RANGE;
- if (max > 0) {
- end = MIN((unsigned)max, playlist.length);
- if (end <= begin)
- return PLAYLIST_RESULT_BAD_RANGE;
- }
- for (unsigned i = begin; i < end; i++)
+ for (unsigned i = start; i < end; i++)
printPlaylistSongInfo(client, i);
return PLAYLIST_RESULT_SUCCESS;