diff options
-rw-r--r-- | src/dbUtils.c | 15 | ||||
-rw-r--r-- | src/directory.c | 21 |
2 files changed, 14 insertions, 22 deletions
diff --git a/src/dbUtils.c b/src/dbUtils.c index ff5f1883e..a9d83eb41 100644 --- a/src/dbUtils.c +++ b/src/dbUtils.c @@ -82,7 +82,8 @@ static int searchInDirectory(Song * song, void *_data) LocateTagItemArray *array = &data->array; if (strstrSearchTags(song, array->numItems, array->items)) - song_print_info(song, fd); + if (song_print_info(song, fd) < 0) + return -1; return 0; } @@ -124,7 +125,8 @@ static int findInDirectory(Song * song, void *_data) LocateTagItemArray *array = &data->array; if (tagItemsFoundAndMatches(song, array->numItems, array->items)) - song_print_info(song, fd); + if (song_print_info(song, fd) < 0) + return -1; return 0; } @@ -217,13 +219,6 @@ int addAllInToStoredPlaylist(const char *name, const char *utf8file) &data); } -static int directoryPrintSongInfo(Song * song, void *data) -{ - song_print_info(song, (int)(size_t)data); - - return 0; -} - static int sumSongTime(Song * song, void *data) { unsigned long *sum_time = (unsigned long *)data; @@ -236,7 +231,7 @@ static int sumSongTime(Song * song, void *data) int printInfoForAllIn(int fd, const char *name) { - return traverseAllIn(name, directoryPrintSongInfo, + return traverseAllIn(name, song_print_info_x, printDirectoryInDirectory, (void*)(size_t)fd); } diff --git a/src/directory.c b/src/directory.c index 57a615cbd..04523ceea 100644 --- a/src/directory.c +++ b/src/directory.c @@ -960,14 +960,11 @@ static int traverseAllInSubDirectory(Directory * directory, void *data) { struct dirvec *dv = &directory->children; - int errFlag = 0; + int err = 0; size_t j; - if (forEachDir) { - errFlag = forEachDir(directory, data); - if (errFlag) - return errFlag; - } + if (forEachDir && (err = forEachDir(directory, data)) < 0) + return err; if (forEachSong) { int i; @@ -976,16 +973,16 @@ static int traverseAllInSubDirectory(Directory * directory, for (i = sv->nr; --i >= 0; ) { Song *song = *sp++; - if ((errFlag = forEachSong(song, data))) - return errFlag; + if ((err = forEachSong(song, data)) < 0) + return err; } } - for (j = 0; !errFlag && j < dv->nr; ++j) - errFlag = traverseAllInSubDirectory(dv->base[j], forEachSong, - forEachDir, data); + for (j = 0; err >= 0 && j < dv->nr; ++j) + err = traverseAllInSubDirectory(dv->base[j], forEachSong, + forEachDir, data); - return errFlag; + return err; } int traverseAllIn(const char *name, |