[vlc-commits] [Git][videolan/vlc][master] control: turn error return values into asserts
Steve Lhomme (@robUx4)
gitlab at videolan.org
Fri Jan 20 07:59:01 UTC 2023
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
b37ec9f1 by Steve Lhomme at 2023-01-20T07:42:31+00:00
control: turn error return values into asserts
All the calls leading to this are calling vlc_playlist_ComputeHasNext(). So
these values should never happen. The size_t return value also means we
should not return an error here.
- - - - -
1 changed file:
- src/playlist/control.c
Changes:
=====================================
src/playlist/control.c
=====================================
@@ -205,12 +205,10 @@ vlc_playlist_NormalOrderGetNextIndex(vlc_playlist_t *playlist)
{
case VLC_PLAYLIST_PLAYBACK_REPEAT_NONE:
case VLC_PLAYLIST_PLAYBACK_REPEAT_CURRENT:
- if (playlist->current >= (ssize_t) playlist->items.size - 1)
- return -1;
+ assert(playlist->current < (ssize_t) playlist->items.size - 1);
return playlist->current + 1;
case VLC_PLAYLIST_PLAYBACK_REPEAT_ALL:
- if (playlist->items.size == 0)
- return -1;
+ assert(playlist->items.size != 0);
return (playlist->current + 1) % playlist->items.size;
default:
vlc_assert_unreachable();
@@ -381,9 +379,7 @@ vlc_playlist_Next(vlc_playlist_t *playlist)
if (!vlc_playlist_ComputeHasNext(playlist))
return VLC_EGENERIC;
- ssize_t index = vlc_playlist_GetNextIndex(playlist);
- assert(index != -1);
-
+ ssize_t index = (ssize_t)vlc_playlist_GetNextIndex(playlist);
int ret = vlc_playlist_SetCurrentMedia(playlist, index);
if (ret != VLC_SUCCESS)
return ret;
@@ -429,7 +425,7 @@ vlc_playlist_GetNextMediaIndex(vlc_playlist_t *playlist)
return playlist->current;
if (!vlc_playlist_ComputeHasNext(playlist))
return -1;
- return vlc_playlist_GetNextIndex(playlist);
+ return (ssize_t)vlc_playlist_GetNextIndex(playlist);
}
input_item_t *
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/b37ec9f16a2ccc006a4dbe1e7c48595e30422f61
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/b37ec9f16a2ccc006a4dbe1e7c48595e30422f61
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list