diff options
author | Eric Wong <normalperson@yhbt.net> | 2008-10-07 22:07:44 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-10-07 22:07:44 +0200 |
commit | 8be60263361fa00e9ea332e64db8122455d234d9 (patch) | |
tree | f3e140ec48a9db851a8148a2f768128f930f9805 /src | |
parent | 45334a23e18da4928f53ccb9ecc7afd5f7eca28e (diff) | |
download | mpd-8be60263361fa00e9ea332e64db8122455d234d9.tar.gz mpd-8be60263361fa00e9ea332e64db8122455d234d9.tar.xz mpd-8be60263361fa00e9ea332e64db8122455d234d9.zip |
dbUtils/directory: traverseAllIn forEachSong returns -1 on error
Being consistent with most UNIX functions...
Diffstat (limited to 'src')
-rw-r--r-- | src/dbUtils.c | 4 | ||||
-rw-r--r-- | src/directory.c | 21 |
2 files changed, 11 insertions, 14 deletions
diff --git a/src/dbUtils.c b/src/dbUtils.c index 29e92494e..3b5d896b6 100644 --- a/src/dbUtils.c +++ b/src/dbUtils.c @@ -83,7 +83,7 @@ static int searchInDirectory(Song * song, void *_data) LocateTagItemArray *array = &data->array; if (strstrSearchTags(song, array->numItems, array->items)) - song_print_info(data->client, song); + return song_print_info(data->client, song); return 0; } @@ -124,7 +124,7 @@ static int findInDirectory(Song * song, void *_data) LocateTagItemArray *array = &data->array; if (tagItemsFoundAndMatches(song, array->numItems, array->items)) - song_print_info(data->client, song); + return song_print_info(data->client, song); return 0; } diff --git a/src/directory.c b/src/directory.c index e38a904f0..2c18c6954 100644 --- a/src/directory.c +++ b/src/directory.c @@ -974,14 +974,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; @@ -990,16 +987,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, |