playlist: pass unsigned integers to playlistInfo()

A song index cannot be negative.  Also require the second parameter to
be valid.
This commit is contained in:
Max Kellermann
2009-01-10 17:39:49 +01:00
parent b7c4b78846
commit 8ebe7bfb25
3 changed files with 42 additions and 25 deletions

View File

@@ -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;