playlist.c - cleanups

This commit is contained in:
twinaphex 2016-09-29 10:16:48 +02:00
parent 30a46a5ab9
commit d7a90dd9bb
1 changed files with 11 additions and 11 deletions

View File

@ -184,9 +184,8 @@ void playlist_update(playlist_t *playlist, size_t idx,
const char *db_name) const char *db_name)
{ {
struct playlist_entry *entry = NULL; struct playlist_entry *entry = NULL;
if (!playlist)
return; if (!playlist || idx > playlist->size)
if (idx > playlist->size)
return; return;
entry = &playlist->entries[idx]; entry = &playlist->entries[idx];
@ -245,9 +244,6 @@ bool playlist_push(playlist_t *playlist,
{ {
size_t i; size_t i;
if (!playlist)
return false;
if (string_is_empty(core_path) || string_is_empty(core_name)) if (string_is_empty(core_path) || string_is_empty(core_name))
{ {
if (string_is_empty(core_name) && !string_is_empty(core_path)) if (string_is_empty(core_name) && !string_is_empty(core_path))
@ -271,6 +267,9 @@ bool playlist_push(playlist_t *playlist,
if (string_is_empty(path)) if (string_is_empty(path))
path = NULL; path = NULL;
if (!playlist)
return false;
for (i = 0; i < playlist->size; i++) for (i = 0; i < playlist->size; i++)
{ {
struct playlist_entry tmp; struct playlist_entry tmp;
@ -439,11 +438,9 @@ size_t playlist_size(playlist_t *playlist)
static bool playlist_read_file( static bool playlist_read_file(
playlist_t *playlist, const char *path) playlist_t *playlist, const char *path)
{ {
unsigned i;
char buf[PLAYLIST_ENTRIES][1024] = {{0}}; char buf[PLAYLIST_ENTRIES][1024] = {{0}};
struct playlist_entry *entry = NULL; RFILE *file = filestream_open(
char *last = NULL; path, RFILE_MODE_READ_TEXT, -1);
RFILE *file = filestream_open(path, RFILE_MODE_READ_TEXT, -1);
/* If playlist file does not exist, /* If playlist file does not exist,
* create an empty playlist instead. * create an empty playlist instead.
@ -453,9 +450,12 @@ static bool playlist_read_file(
for (playlist->size = 0; playlist->size < playlist->cap; ) for (playlist->size = 0; playlist->size < playlist->cap; )
{ {
unsigned i;
struct playlist_entry *entry = NULL;
for (i = 0; i < PLAYLIST_ENTRIES; i++) for (i = 0; i < PLAYLIST_ENTRIES; i++)
{ {
*buf[i] = '\0'; char *last = NULL;
*buf[i] = '\0';
if (!filestream_gets(file, buf[i], sizeof(buf[i]))) if (!filestream_gets(file, buf[i], sizeof(buf[i])))
goto end; goto end;