From 8ebe7bfb250f2b1048d6e7f6c2477717daaad8e9 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 10 Jan 2009 17:39:49 +0100 Subject: playlist: pass unsigned integers to playlistInfo() A song index cannot be negative. Also require the second parameter to be valid. --- src/playlist.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'src/playlist.c') 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; -- cgit v1.2.3