aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/dbUtils.c4
-rw-r--r--src/directory.c21
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,